Changeset 1038:ca63ec3424d8 in lemon-0.x
- Timestamp:
- 12/16/04 13:15:02 (18 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1428
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/lemon/alteration_observer_registry.h
r1022 r1038 1 1 /* -*- C++ -*- 2 * src/lemon/ observer_registry.h - Part of LEMON, a generic C++ optimization library2 * src/lemon/notifier.h - Part of LEMON, a generic C++ optimization library 3 3 * 4 4 * Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport … … 37 37 /// alterations in a container. The alteration observers can be attached 38 38 /// to and detached from the registry. The observers have to inherit 39 /// from the \ref Alteration ObserverRegistry::ObserverBase and override39 /// from the \ref AlterationNotifier::ObserverBase and override 40 40 /// the virtual functions in that. 41 41 /// … … 50 50 51 51 template <typename _Item> 52 class Alteration ObserverRegistry{52 class AlterationNotifier { 53 53 public: 54 54 typedef _Item Item; … … 73 73 class ObserverBase { 74 74 protected: 75 typedef Alteration ObserverRegistryRegistry;76 77 friend class Alteration ObserverRegistry;75 typedef AlterationNotifier Registry; 76 77 friend class AlterationNotifier; 78 78 79 79 /// Default constructor. … … 85 85 virtual ~ObserverBase() {} 86 86 87 /// Attaches the observer into an Alteration ObserverRegistry.88 89 /// This member attaches the observer into an Alteration ObserverRegistry.90 /// 91 void attach(Alteration ObserverRegistry& r) {87 /// Attaches the observer into an AlterationNotifier. 88 89 /// This member attaches the observer into an AlterationNotifier. 90 /// 91 void attach(AlterationNotifier& r) { 92 92 registry = &r; 93 93 registry->attach(*this); 94 94 } 95 95 96 /// Detaches the observer into an Alteration ObserverRegistry.97 98 /// This member detaches the observer from an Alteration ObserverRegistry.96 /// Detaches the observer into an AlterationNotifier. 97 98 /// This member detaches the observer from an AlterationNotifier. 99 99 /// 100 100 void detach() { … … 179 179 180 180 /// 181 /// The default constructor of the Alteration ObserverRegistry.181 /// The default constructor of the AlterationNotifier. 182 182 /// It creates an empty registry. 183 Alteration ObserverRegistry() {}184 185 /// Copy Constructor of the Alteration ObserverRegistry.186 187 /// Copy constructor of the Alteration ObserverRegistry.183 AlterationNotifier() {} 184 185 /// Copy Constructor of the AlterationNotifier. 186 187 /// Copy constructor of the AlterationNotifier. 188 188 /// It creates only an empty registry because the copiable 189 189 /// registry's observers have to be registered still into that registry. 190 Alteration ObserverRegistry(const AlterationObserverRegistry&) {}190 AlterationNotifier(const AlterationObserverRegistry&) {} 191 191 192 192 /// Assign operator. 193 193 194 /// Assign operator for the Alteration ObserverRegistry.194 /// Assign operator for the AlterationNotifier. 195 195 /// It makes the registry only empty because the copiable 196 196 /// registry's observers have to be registered still into that registry. 197 Alteration ObserverRegistry& operator=(const AlterationObserverRegistry&) {197 AlterationNotifier& operator=(const AlterationObserverRegistry&) { 198 198 typename Container::iterator it; 199 199 for (it = container.begin(); it != container.end(); ++it) { … … 204 204 /// Destructor. 205 205 206 /// Destructor of the Alteration ObserverRegistry.206 /// Destructor of the AlterationNotifier. 207 207 /// 208 ~Alteration ObserverRegistry() {208 ~AlterationNotifier() { 209 209 typename Container::iterator it; 210 210 for (it = container.begin(); it != container.end(); ++it) { … … 309 309 310 310 /// The edge observer registry. 311 typedef Alteration ObserverRegistry<Edge> EdgeObserverRegistry;311 typedef AlterationNotifier<Edge> EdgeObserverRegistry; 312 312 /// The node observer registry. 313 typedef Alteration ObserverRegistry<Node> NodeObserverRegistry;313 typedef AlterationNotifier<Node> NodeObserverRegistry; 314 314 315 315 316 316 protected: 317 317 318 mutable Edge ObserverRegistryedge_observers;319 320 mutable Node ObserverRegistrynode_observers;321 322 public: 323 324 Edge ObserverRegistry& getObserverRegistry(Edge = INVALID) const {318 mutable EdgeNotifier edge_observers; 319 320 mutable NodeNotifier node_observers; 321 322 public: 323 324 EdgeNotifier& getObserverRegistry(Edge = INVALID) const { 325 325 return edge_observers; 326 326 } 327 327 328 Node ObserverRegistry& getObserverRegistry(Node = INVALID) const {328 NodeNotifier& getObserverRegistry(Node = INVALID) const { 329 329 return node_observers; 330 330 } … … 359 359 360 360 /// The edge observer registry. 361 typedef Alteration ObserverRegistry<UndirEdge> UndirEdgeObserverRegistry;361 typedef AlterationNotifier<UndirEdge> UndirEdgeObserverRegistry; 362 362 363 363 protected: 364 364 365 mutable UndirEdge ObserverRegistryundir_edge_observers;366 367 public: 368 369 using Parent::get ObserverRegistry;370 UndirEdge ObserverRegistry& getObserverRegistry(UndirEdge) const {365 mutable UndirEdgeNotifier undir_edge_observers; 366 367 public: 368 369 using Parent::getNotifier; 370 UndirEdgeNotifier& getObserverRegistry(UndirEdge) const { 371 371 return undir_edge_observers; 372 372 }
Note: See TracChangeset
for help on using the changeset viewer.