Cafu Engine
ObserverPattern.hpp File Reference

This file provides the classes for the Observer pattern as described in the book by the GoF. More...

#include "Math3D/BoundingBox.hpp"
#include "Templates/Array.hpp"
#include "Templates/Pointer.hpp"
#include "wx/string.h"
Include dependency graph for ObserverPattern.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  ObserverT
 
class  SubjectT
 

Namespaces

 cf::TypeSys
 The TypeSys ("type system") namespace provides classes for two related, but entirely independent concepts:
 

Enumerations

enum  MapElemModDetailE {
  MEMD_GENERIC, MEMD_TRANSFORM, MEMD_PRIMITIVE_PROPS_CHANGED, MEMD_SURFACE_INFO_CHANGED,
  MEMD_ASSIGN_PRIM_TO_ENTITY, MEMD_VISIBILITY
}
 
enum  EntityModDetailE { EMD_COMPONENTS, EMD_HIERARCHY }
 
enum  MapDocOtherDetailT { UPDATE_GRID, UPDATE_POINTFILE, UPDATE_GLOBALOPTIONS }
 

Detailed Description

This file provides the classes for the Observer pattern as described in the book by the GoF.

Note that implementations of ObserverT normally maintain a pointer to the subject(s) that they observe, e.g. in order to be able to redraw themselves also outside of and independent from the NotifySubjectChanged() method. This however in turn creates problems when the life of the observer begins before or ends after the life of the observed subject(s). In fact, it seems that the observers have to maintain lists of valid, observed subjects as the subjects maintain lists of observers. Fortunately, these possibly tough problems can (and apparently must) be addressed by the concrete implementation classes of observers and subjects, not by the base classes that the Observer pattern describes and provided herein.

Enumeration Type Documentation

Enumerator
EMD_COMPONENTS 

The set of components has changed (e.g. added, deleted, order changed).

EMD_HIERARCHY 

The position of an entity in the entity hierarchy has changed.

Enumerator
MEMD_GENERIC 

Generic change of map elements (useful if the subject doesn't know what exactly has been changed).

MEMD_TRANSFORM 

A map element has been transformed.

MEMD_PRIMITIVE_PROPS_CHANGED 

The properties of a map primitive have been modified.

MEMD_SURFACE_INFO_CHANGED 

The surface info of a map element has changed. Note that surface info changes also include the selection of faces.

MEMD_ASSIGN_PRIM_TO_ENTITY 

A map primitive has been assigned to another entity (the world or any custom entity).

MEMD_VISIBILITY 

The visibility of a map element has changed.