Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   Related Pages  

ogs::support::Object Class Reference

Base class of all objects in the class hierarchy. More...

#include <Object.h>

Inheritance diagram for ogs::support::Object:

Inheritance graph
[legend]
List of all members.

Public Member Functions

void addObserver (Observer &observer)
 Add an event observer.

void removeObserver (Observer &observer)
 Remove an event observer.

Class getClass () const
 Determine the class of this object.

virtual std::string toString () const
 Format a string representation of this object.


Protected Types

typedef std::list< Observer * > Observers
 A list of observers.


Protected Member Functions

 Object ()
 Create a new object.

Observers getObservers () const
 Retrieve the list of observers.

virtual void notifyObservers (Event &event)
 Notify all observers of an event.


Detailed Description

This class follows the Observer pattern; it can manage and notify observers of events in the Subject or source object.


Constructor & Destructor Documentation

ogs::support::Object::Object  )  [inline, protected]
 

This constructor is protected so it can only be called by derived classes. All that it does is initialize the observers as an empty list.


Member Function Documentation

void Object::addObserver Observer observer  ) 
 

This function adds the observer only if it is not already in the list of observers for this object.

Parameters:
observer An event observer.

Class ogs::support::Object::getClass  )  const [inline]
 

Returns:
Class of this object.

Object::Observers ogs::support::Object::getObservers  )  const [inline, protected]
 

Returns:
List of observers.
Todo:
Change the return type to a const reference?

void Object::notifyObservers Event event  )  [protected, virtual]
 

This method is protected so that subclasses can control when observers are notified of events. Subclasses may expose this method to allow any other class to control when observers are notified.

Parameters:
event The event that occurred.

void Object::removeObserver Observer observer  ) 
 

Parameters:
observer An event observer.

std::string Object::toString  )  const [virtual]
 

The format of the string is "Class@Address" where "Class" is the name of the derived class and "Address" is the pointer to this object.

Returns:
A string representation of this object.
Todo:
Change this function into an operator<< function?

Reimplemented in ogs::core::Modifier, and ogs::core::details::Gender.


The documentation for this class was generated from the following files:
Generated on Sun Apr 20 03:40:58 2003 for Open Gaming System (OGS) by doxygen1.3