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 "Templates/Array.hpp"
#include "Templates/Pointer.hpp"
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  GuiEditor::ObserverT
 
class  GuiEditor::SubjectT
 

Namespaces

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

Enumerations

enum  WindowModDetailE { GuiEditor::WMD_GENERIC, GuiEditor::WMD_HIERARCHY }
 

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.