core/vgui/vgui_observable.h

Go to the documentation of this file.
00001 // This is core/vgui/vgui_observable.h
00002 #ifndef vgui_observable_h_
00003 #define vgui_observable_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 // \file
00009 // \brief  Base class for classes that want to broadcast messages to observers.
00010 // \author fsm
00011 //
00012 //  Contains class  vgui_observable.
00013 //
00014 // \verbatim
00015 //  Modifications
00016 //   17-Sep-2002 K.Y.McGaul - Added doxygen style comments.
00017 // \endverbatim
00018 
00019 #include <vcl_vector.h>
00020 class vgui_observer;
00021 class vgui_message;
00022 
00023 
00024 //: Base class for classes that want to broadcast messages to observers.
00025 //
00026 //  Objects from classes derived from vgui_observable can broadcast a
00027 //  vgui_message or an update using notify() to all the vgui_observer's
00028 //  attached to themselves.
00029 class vgui_observable
00030 {
00031  public:
00032   //: Constructor - create a default observable.
00033   vgui_observable() { }
00034 
00035   //: Destructor.
00036   virtual ~vgui_observable();
00037 
00038   //: Attach the given observer to receive notify messages.
00039   void attach(vgui_observer*);
00040 
00041   //: Detach the given observer.
00042   void detach(vgui_observer*);
00043 
00044   //: Returns a list of all the observers for this observable.
00045   void get_observers(vcl_vector<vgui_observer*>&) const;
00046 
00047   //: Broadcast an update to all observers of this class.
00048   virtual void notify() const;
00049 
00050   //: Broadcast a message to all observers of this class.
00051   virtual void notify(const vgui_message &) const;
00052 
00053  private:
00054   //: List of all observers for this observable.
00055   vcl_vector<vgui_observer*> observers;
00056 
00057   //: Disallow assignment.
00058   vgui_observable(vgui_observable const&) { }
00059 
00060   //: Disallow assignment.
00061   void operator==(vgui_observable const&) { }
00062 };
00063 
00064 #endif // vgui_observable_h_

Generated on Mon Mar 8 05:12:27 2010 for core/vgui by  doxygen 1.5.1