Changes in src/Patterns/Observer.hpp [033a05:cd5047]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Patterns/Observer.hpp
r033a05 rcd5047 11 11 #include <map> 12 12 #include <set> 13 #include <string> 14 #include <sstream> 13 15 14 16 /** … … 28 30 */ 29 31 32 // Deactivate any logging when we are not in debug mode 33 #ifdef NDEBUG 34 #undef LOG_OBSERVER 35 #endif 36 30 37 class Observable; 31 38 class Notification; … … 35 42 // identification process 36 43 typedef Notification *const Notification_ptr; 44 45 template<class _Set> 46 class ObservedIterator; 37 47 38 48 /** … … 53 63 friend class Observable; 54 64 friend class Notification; 55 public: 56 Observer(); 65 template<class> friend class ObservedIterator; 66 67 // indicates the constructor called from Observables 68 struct BaseConstructor{}; 69 70 public: 71 Observer(BaseConstructor); 72 Observer(std::string); 57 73 virtual ~Observer(); 58 74 … … 86 102 class Observable : public Observer { 87 103 public: 88 Observable( );104 Observable(std::string _name); 89 105 virtual ~Observable(); 90 106 … … 152 168 static std::set<Observable*> busyObservables; 153 169 154 155 170 //! @cond 156 171 // Structure for RAII-Style notification … … 164 179 public: 165 180 _Observable_protector(Observable *); 181 _Observable_protector(const _Observable_protector&); 166 182 ~_Observable_protector(); 167 183 private: … … 187 203 }; 188 204 205 #ifdef LOG_OBSERVER 206 207 /** 208 * This class is used to log the working of the observer mechanism 209 * 210 * TODO: make this conditional dependent on compiler Flag. 211 */ 212 class ObserverLog{ 213 friend class Observable; 214 friend class Observer; 215 template <typename> friend class Cacheable; 216 public: 217 ObserverLog(); 218 ~ObserverLog(); 219 std::string getLog(); // get everything that has been logged 220 std::string getName(void*); // get the name of an actor 221 bool isObservable(void*); 222 private: 223 int count; // number to reference each actor in this framework 224 std::map<void*,std::string> names; // List of names assigned to actors 225 std::set<void*> observables; // List of pointers to Observables. Needed to distinguish Observers and Observables 226 void addName(void*, std::string); // Assign a name to an Actor 227 void addObservable(void*); 228 void deleteName(void*); // delete the name of an Actor 229 void deleteObservable(void*); 230 std::stringstream &addMessage(int depth=0); // Add a Message to the logging 231 std::stringstream log; // The internal log object 232 }; 233 234 ObserverLog &observerLog(); 235 236 #endif 237 189 238 // extra macro is necessary to work with __LINE__ 190 239 #define PASTE(a,b) PASTE_HELPER(a,b)
Note:
See TracChangeset
for help on using the changeset viewer.