Source: lycad_chargen/event.h


Annotated List
Files
Globals
Hierarchy
Index
/***************************************************************************
                          event.h  -  description
                             -------------------
    begin                : Tue Nov 13 2001
    copyright            : (C) 2001 by Sheldon Lee Wen
    email                : tormak@home.com
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef EVENT_H
#define EVENT_H

#include         /* STL vector class */
#include "eventgenerator.h"
#include "staticdata.h"

class event_generator;
class event_listener;

/**Rough list of possible event types, can add event types as required, but
   should be careful removing types in case they are referenced elsewhere in
   the code.
 **/
/*
typedef enum event_t {  EVENT_UNDEFINED,
			EVENT_TICK,
			EVENT_MINUTE,
                        EVENT_DAY,
                        EVENT_NIGHT,
                        EVENT_ENCOUNTER,
                        EVENT_WEATHER,
                        EVENT_DARK,
                        EVENT_LIGHT,
                        EVENT_MAGIC,
                        EVENT_COMBAT
} EVENT_TYPE;
*/

/**Base class for an event. It should never be
    directly instantiated, only inherited. Also,
    a copy constructor must be defined in all
    derived classes.

    All events should be derived from this base class and then passed via
    the event_generator class'  fireEvent method to it's respective listeners.

  *@author Rob Boyd
  */

class event {
protected:

  EVENT_TYPE type;           // for event identification
  event_generator *source;   // pointer to the source of the event

public:

  event() { type = EVENT_UNDEFINED;
                source = NULL; }
  virtual ~event() {}

  // public methods

  // Pure virtual create methods, these will be specific to the type of event
  // being generated so must be implemented in any derived classes.

  // accessor methods

  EVENT_TYPE       getType()   { return type; }
  event_generator *getSource() { return source; }

  // mutator methods
  void setSource(event_generator *src) { source = src; }

};

class event_generator {

protected:
  EVENT_TYPE type; // for keeping track of the type of events being generated

  // NEEDs in derived classes
  //vector ****Listeners;

 public:

  event_generator() { type = EVENT_UNDEFINED; }
  virtual ~event_generator() {};

  // public methods
  EVENT_TYPE getGeneratorType() { return type; }

  // NEED to be declared in derived classes
  // void add****Listener(event_listener *l);
  // void remove****Listener(event_listener *l);
  // void fire****Event(event evt);

 private:
  //  int find****Listener(event_listener *l);

};

class event_listener {

protected:

  EVENT_TYPE type;  // for keeping track of the type of listener

  // NEEDS to be defined in all derived classes
  // vector ****Generators;

public:

  event_listener() { type = EVENT_UNDEFINED; }
  virtual ~event_listener() {};

  EVENT_TYPE getListenerType() { return type; }

  // NEEDS to be defined in derived classes
  // virtual void handle****Event()

 private:

  // NEED to be defined in derived classes
  // int  find****Generator(event_generator *g);
  // void add****Generator(event_generator *g);
  // void remove****Generator(event_generator *g);

  friend event_generator;

};

#endif

Generated by: sheldonl on cr595811-a on Fri Nov 30 10:24:34 2001, using kdoc 2.0a53.