Main Page   Namespace List   Class Hierarchy   Data Structures   File List   Namespace Members   Data Fields   Globals   Related Pages  

Observer.h

Go to the documentation of this file.
00001 /*
00002  * Observer.h
00003  *
00004  * Copyright 2003, MobileSpear Inc. (www.mobilespear.com). All rights reserved.
00005  * Copyright 2003, David Resnick. All rights reserved.
00006  *
00007  * See the file doc\license.txt for the terms of usage and distribution.
00008  */
00009 
00010 #ifndef _BOGOTEL_OBSERVER_H
00011 #define _BOGOTEL_OBSERVER_H
00012 
00013 #include <list>
00014 #include <boost/thread/mutex.hpp>
00015 
00016 namespace bogotel {
00017 
00018     class CSubject;
00019 
00020     class CObserver {
00021     public:
00022         virtual ~ CObserver() {};
00023         virtual void update(CSubject* theChangedCSubject) = 0;
00024     protected:
00025         CObserver() {};
00026     };
00027 
00028     class CSubject {
00029     public:
00030         virtual ~CSubject() {};
00031 
00032         virtual void attach(CObserver*);
00033         virtual void detach(CObserver*);
00034         virtual void notify();
00035     protected:
00036         CSubject() {};
00037     private:
00038 
00039         typedef std::list<CObserver*> LIST_OBSERVER;
00040 
00041         // manages multithreaded access to the observer's list
00042         boost::mutex m_mtxListObservers; 
00043 
00044         LIST_OBSERVER m_lstpObservers;
00045     };
00046 
00047 }
00048 
00049 #endif // _BOGOTEL_OBSERVER_H

Generated on Tue Aug 12 12:41:30 2003 for bogotel by doxygen 1.3. Hosted by SourceForge.net Logo