1.1 --- a/src/lemon/Makefile.am Thu Dec 16 12:15:02 2004 +0000
1.2 +++ b/src/lemon/Makefile.am Thu Dec 16 12:26:57 2004 +0000
1.3 @@ -14,7 +14,7 @@
1.4 invalid.h \
1.5 kruskal.h \
1.6 list_graph.h \
1.7 - alteration_observer_registry.h \
1.8 + alteration_notifier.h \
1.9 maps.h \
1.10 min_cost_flow.h \
1.11 suurballe.h \
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/src/lemon/alteration_notifier.h Thu Dec 16 12:26:57 2004 +0000
2.3 @@ -0,0 +1,384 @@
2.4 +/* -*- C++ -*-
2.5 + * src/lemon/notifier.h - Part of LEMON, a generic C++ optimization library
2.6 + *
2.7 + * Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
2.8 + * (Egervary Combinatorial Optimization Research Group, EGRES).
2.9 + *
2.10 + * Permission to use, modify and distribute this software is granted
2.11 + * provided that this copyright notice appears in all copies. For
2.12 + * precise terms see the accompanying LICENSE file.
2.13 + *
2.14 + * This software is provided "AS IS" with no warranty of any kind,
2.15 + * express or implied, and with no claim as to its suitability for any
2.16 + * purpose.
2.17 + *
2.18 + */
2.19 +
2.20 +#ifndef LEMON_ALTERATION_OBSERVER_REGISTRY_H
2.21 +#define LEMON_ALTERATION_OBSERVER_REGISTRY_H
2.22 +
2.23 +#include <vector>
2.24 +#include <algorithm>
2.25 +
2.26 +///\ingroup graphmaps
2.27 +///\file
2.28 +///\brief Observer registry for graph alteration observers.
2.29 +
2.30 +using namespace std;
2.31 +
2.32 +namespace lemon {
2.33 +
2.34 + /// \addtogroup graphmaps
2.35 + /// @{
2.36 +
2.37 + /// Registry class to register objects observes alterations in the graph.
2.38 +
2.39 + /// This class is a registry for the objects which observe the
2.40 + /// alterations in a container. The alteration observers can be attached
2.41 + /// to and detached from the registry. The observers have to inherit
2.42 + /// from the \ref AlterationNotifier::ObserverBase and override
2.43 + /// the virtual functions in that.
2.44 + ///
2.45 + /// The most important application of the alteration observing is the
2.46 + /// dynamic map implementation when the observers are observing the
2.47 + /// alterations in the graph.
2.48 + ///
2.49 + /// \param _Item The item type what the observers are observing, usually
2.50 + /// edge or node.
2.51 + ///
2.52 + /// \author Balazs Dezso
2.53 +
2.54 + template <typename _Item>
2.55 + class AlterationNotifier {
2.56 + public:
2.57 + typedef _Item Item;
2.58 +
2.59 + /// ObserverBase is the base class for the observers.
2.60 +
2.61 + /// ObserverBase is the abstract base class for the observers.
2.62 + /// It will be notified about an item was inserted into or
2.63 + /// erased from the graph.
2.64 + ///
2.65 + /// The observer interface contains some pure virtual functions
2.66 + /// to override. The add() and erase() functions are
2.67 + /// to notify the oberver when one item is added or
2.68 + /// erased.
2.69 + ///
2.70 + /// The build() and clear() members are to notify the observer
2.71 + /// about the container is builded from an empty container or
2.72 + /// is cleared to an empty container.
2.73 + ///
2.74 + /// \author Balazs Dezso
2.75 +
2.76 + class ObserverBase {
2.77 + protected:
2.78 + typedef AlterationNotifier Registry;
2.79 +
2.80 + friend class AlterationNotifier;
2.81 +
2.82 + /// Default constructor.
2.83 +
2.84 + /// Default constructor for ObserverBase.
2.85 + ///
2.86 + ObserverBase() : registry(0) {}
2.87 +
2.88 + virtual ~ObserverBase() {}
2.89 +
2.90 + /// Attaches the observer into an AlterationNotifier.
2.91 +
2.92 + /// This member attaches the observer into an AlterationNotifier.
2.93 + ///
2.94 + void attach(AlterationNotifier& r) {
2.95 + registry = &r;
2.96 + registry->attach(*this);
2.97 + }
2.98 +
2.99 + /// Detaches the observer into an AlterationNotifier.
2.100 +
2.101 + /// This member detaches the observer from an AlterationNotifier.
2.102 + ///
2.103 + void detach() {
2.104 + if (registry) {
2.105 + registry->detach(*this);
2.106 + }
2.107 + }
2.108 +
2.109 +
2.110 + /// Gives back a pointer to the registry what the map attached into.
2.111 +
2.112 + /// This function gives back a pointer to the registry what the map
2.113 + /// attached into.
2.114 + ///
2.115 + Registry* getRegistry() const { return const_cast<Registry*>(registry); }
2.116 +
2.117 + /// Gives back true when the observer is attached into a registry.
2.118 + bool attached() const { return registry != 0; }
2.119 +
2.120 + private:
2.121 +
2.122 + ObserverBase(const ObserverBase& copy);
2.123 + ObserverBase& operator=(const ObserverBase& copy);
2.124 +
2.125 + protected:
2.126 +
2.127 + Registry* registry;
2.128 + int registry_index;
2.129 +
2.130 + public:
2.131 +
2.132 + /// \brief The member function to notificate the observer about an
2.133 + /// item is added to the container.
2.134 + ///
2.135 + /// The add() member function notificates the observer about an item
2.136 + /// is added to the container. It have to be overrided in the
2.137 + /// subclasses.
2.138 +
2.139 + virtual void add(const Item&) = 0;
2.140 +
2.141 +
2.142 + /// \brief The member function to notificate the observer about an
2.143 + /// item is erased from the container.
2.144 + ///
2.145 + /// The erase() member function notificates the observer about an
2.146 + /// item is erased from the container. It have to be overrided in
2.147 + /// the subclasses.
2.148 +
2.149 + virtual void erase(const Item&) = 0;
2.150 +
2.151 + /// \brief The member function to notificate the observer about the
2.152 + /// container is builded.
2.153 + ///
2.154 + /// The build() member function notificates the observer about the
2.155 + /// container is builded from an empty container. It have to be
2.156 + /// overrided in the subclasses.
2.157 +
2.158 + virtual void build() = 0;
2.159 +
2.160 + /// \brief The member function to notificate the observer about all
2.161 + /// items are erased from the container.
2.162 + ///
2.163 + /// The clear() member function notificates the observer about all
2.164 + /// items are erased from the container. It have to be overrided in
2.165 + /// the subclasses.
2.166 +
2.167 + virtual void clear() = 0;
2.168 +
2.169 + };
2.170 +
2.171 + protected:
2.172 +
2.173 +
2.174 + typedef std::vector<ObserverBase*> Container;
2.175 +
2.176 + Container container;
2.177 +
2.178 +
2.179 + public:
2.180 +
2.181 + /// Default constructor.
2.182 +
2.183 + ///
2.184 + /// The default constructor of the AlterationNotifier.
2.185 + /// It creates an empty registry.
2.186 + AlterationNotifier() {}
2.187 +
2.188 + /// Copy Constructor of the AlterationNotifier.
2.189 +
2.190 + /// Copy constructor of the AlterationNotifier.
2.191 + /// It creates only an empty registry because the copiable
2.192 + /// registry's observers have to be registered still into that registry.
2.193 + AlterationNotifier(const AlterationNotifier&) {}
2.194 +
2.195 + /// Assign operator.
2.196 +
2.197 + /// Assign operator for the AlterationNotifier.
2.198 + /// It makes the registry only empty because the copiable
2.199 + /// registry's observers have to be registered still into that registry.
2.200 + AlterationNotifier& operator=(const AlterationNotifier&) {
2.201 + typename Container::iterator it;
2.202 + for (it = container.begin(); it != container.end(); ++it) {
2.203 + (*it)->registry = 0;
2.204 + }
2.205 + }
2.206 +
2.207 + /// Destructor.
2.208 +
2.209 + /// Destructor of the AlterationNotifier.
2.210 + ///
2.211 + ~AlterationNotifier() {
2.212 + typename Container::iterator it;
2.213 + for (it = container.begin(); it != container.end(); ++it) {
2.214 + (*it)->registry = 0;
2.215 + }
2.216 + }
2.217 +
2.218 +
2.219 + protected:
2.220 +
2.221 + void attach(ObserverBase& observer) {
2.222 + container.push_back(&observer);
2.223 + observer.registry = this;
2.224 + observer.registry_index = container.size()-1;
2.225 + }
2.226 +
2.227 + void detach(ObserverBase& base) {
2.228 + container.back()->registry_index = base.registry_index;
2.229 + container[base.registry_index] = container.back();
2.230 + container.pop_back();
2.231 + base.registry = 0;
2.232 + }
2.233 +
2.234 + public:
2.235 +
2.236 + /// Notifies all the registered observers about an Item added to the container.
2.237 +
2.238 + /// It notifies all the registered observers about an Item added to the container.
2.239 + ///
2.240 + void add(const Item& key) {
2.241 + typename Container::iterator it;
2.242 + for (it = container.begin(); it != container.end(); ++it) {
2.243 + (*it)->add(key);
2.244 + }
2.245 + }
2.246 +
2.247 + /// Notifies all the registered observers about an Item erased from the container.
2.248 +
2.249 + /// It notifies all the registered observers about an Item erased from the container.
2.250 + ///
2.251 + void erase(const Item& key) {
2.252 + typename Container::iterator it;
2.253 + for (it = container.begin(); it != container.end(); ++it) {
2.254 + (*it)->erase(key);
2.255 + }
2.256 + }
2.257 +
2.258 +
2.259 + /// Notifies all the registered observers about the container is builded.
2.260 +
2.261 + /// Notifies all the registered observers about the container is builded
2.262 + /// from an empty container.
2.263 + void build() {
2.264 + typename Container::iterator it;
2.265 + for (it = container.begin(); it != container.end(); ++it) {
2.266 + (*it)->build();
2.267 + }
2.268 + }
2.269 +
2.270 +
2.271 + /// Notifies all the registered observers about all Items are erased.
2.272 +
2.273 + /// Notifies all the registered observers about all Items are erased
2.274 + /// from the container.
2.275 + void clear() {
2.276 + typename Container::iterator it;
2.277 + for (it = container.begin(); it != container.end(); ++it) {
2.278 + (*it)->clear();
2.279 + }
2.280 + }
2.281 + };
2.282 +
2.283 +
2.284 + /// \brief Class to extend a graph with the functionality of alteration
2.285 + /// observing.
2.286 + ///
2.287 + /// AlterableGraphExtender extends the _Base graphs functionality with
2.288 + /// the possibility of alteration observing. It defines two observer
2.289 + /// registrys for the nodes and mapes.
2.290 + ///
2.291 + /// \todo Document what "alteration observing" is. And probably find a
2.292 + /// better (shorter) name.
2.293 + ///
2.294 + /// \param _Base is the base class to extend.
2.295 + ///
2.296 + /// \pre _Base is conform to the BaseGraphComponent concept.
2.297 + ///
2.298 + /// \post AlterableGraphExtender<_Base> is conform to the
2.299 + /// AlterableGraphComponent concept.
2.300 + ///
2.301 + /// \author Balazs Dezso
2.302 +
2.303 + template <typename _Base>
2.304 + class AlterableGraphExtender : public _Base {
2.305 + public:
2.306 +
2.307 + typedef AlterableGraphExtender Graph;
2.308 + typedef _Base Parent;
2.309 +
2.310 + typedef typename Parent::Node Node;
2.311 + typedef typename Parent::Edge Edge;
2.312 +
2.313 + /// The edge observer registry.
2.314 + typedef AlterationNotifier<Edge> EdgeNotifier;
2.315 + /// The node observer registry.
2.316 + typedef AlterationNotifier<Node> NodeNotifier;
2.317 +
2.318 +
2.319 + protected:
2.320 +
2.321 + mutable EdgeNotifier edge_observers;
2.322 +
2.323 + mutable NodeNotifier node_observers;
2.324 +
2.325 + public:
2.326 +
2.327 + EdgeNotifier& getNotifier(Edge = INVALID) const {
2.328 + return edge_observers;
2.329 + }
2.330 +
2.331 + NodeNotifier& getNotifier(Node = INVALID) const {
2.332 + return node_observers;
2.333 + }
2.334 +
2.335 + ~AlterableGraphExtender() {
2.336 + node_observers.clear();
2.337 + edge_observers.clear();
2.338 + }
2.339 +
2.340 + };
2.341 +
2.342 + /// \brief Class to extend an undirected graph with the functionality of
2.343 + /// alteration observing.
2.344 + ///
2.345 + /// \todo Document.
2.346 + ///
2.347 + /// \sa AlterableGraphExtender
2.348 + ///
2.349 + /// \bug This should be done some other way. Possibilities: template
2.350 + /// specialization (not very easy, if at all possible); some kind of
2.351 + /// enable_if boost technique?
2.352 +
2.353 + template <typename _Base>
2.354 + class AlterableUndirGraphExtender
2.355 + : public AlterableGraphExtender<_Base> {
2.356 + public:
2.357 +
2.358 + typedef AlterableUndirGraphExtender Graph;
2.359 + typedef AlterableGraphExtender<_Base> Parent;
2.360 +
2.361 + typedef typename Parent::UndirEdge UndirEdge;
2.362 +
2.363 + /// The edge observer registry.
2.364 + typedef AlterationNotifier<UndirEdge> UndirEdgeNotifier;
2.365 +
2.366 + protected:
2.367 +
2.368 + mutable UndirEdgeNotifier undir_edge_observers;
2.369 +
2.370 + public:
2.371 +
2.372 + using Parent::getNotifier;
2.373 + UndirEdgeNotifier& getNotifier(UndirEdge) const {
2.374 + return undir_edge_observers;
2.375 + }
2.376 +
2.377 + ~AlterableUndirGraphExtender() {
2.378 + undir_edge_observers.clear();
2.379 + }
2.380 + };
2.381 +
2.382 +/// @}
2.383 +
2.384 +
2.385 +}
2.386 +
2.387 +#endif
3.1 --- a/src/lemon/alteration_observer_registry.h Thu Dec 16 12:15:02 2004 +0000
3.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
3.3 @@ -1,384 +0,0 @@
3.4 -/* -*- C++ -*-
3.5 - * src/lemon/notifier.h - Part of LEMON, a generic C++ optimization library
3.6 - *
3.7 - * Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
3.8 - * (Egervary Combinatorial Optimization Research Group, EGRES).
3.9 - *
3.10 - * Permission to use, modify and distribute this software is granted
3.11 - * provided that this copyright notice appears in all copies. For
3.12 - * precise terms see the accompanying LICENSE file.
3.13 - *
3.14 - * This software is provided "AS IS" with no warranty of any kind,
3.15 - * express or implied, and with no claim as to its suitability for any
3.16 - * purpose.
3.17 - *
3.18 - */
3.19 -
3.20 -#ifndef LEMON_ALTERATION_OBSERVER_REGISTRY_H
3.21 -#define LEMON_ALTERATION_OBSERVER_REGISTRY_H
3.22 -
3.23 -#include <vector>
3.24 -#include <algorithm>
3.25 -
3.26 -///\ingroup graphmaps
3.27 -///\file
3.28 -///\brief Observer registry for graph alteration observers.
3.29 -
3.30 -using namespace std;
3.31 -
3.32 -namespace lemon {
3.33 -
3.34 - /// \addtogroup graphmaps
3.35 - /// @{
3.36 -
3.37 - /// Registry class to register objects observes alterations in the graph.
3.38 -
3.39 - /// This class is a registry for the objects which observe the
3.40 - /// alterations in a container. The alteration observers can be attached
3.41 - /// to and detached from the registry. The observers have to inherit
3.42 - /// from the \ref AlterationNotifier::ObserverBase and override
3.43 - /// the virtual functions in that.
3.44 - ///
3.45 - /// The most important application of the alteration observing is the
3.46 - /// dynamic map implementation when the observers are observing the
3.47 - /// alterations in the graph.
3.48 - ///
3.49 - /// \param _Item The item type what the observers are observing, usually
3.50 - /// edge or node.
3.51 - ///
3.52 - /// \author Balazs Dezso
3.53 -
3.54 - template <typename _Item>
3.55 - class AlterationNotifier {
3.56 - public:
3.57 - typedef _Item Item;
3.58 -
3.59 - /// ObserverBase is the base class for the observers.
3.60 -
3.61 - /// ObserverBase is the abstract base class for the observers.
3.62 - /// It will be notified about an item was inserted into or
3.63 - /// erased from the graph.
3.64 - ///
3.65 - /// The observer interface contains some pure virtual functions
3.66 - /// to override. The add() and erase() functions are
3.67 - /// to notify the oberver when one item is added or
3.68 - /// erased.
3.69 - ///
3.70 - /// The build() and clear() members are to notify the observer
3.71 - /// about the container is builded from an empty container or
3.72 - /// is cleared to an empty container.
3.73 - ///
3.74 - /// \author Balazs Dezso
3.75 -
3.76 - class ObserverBase {
3.77 - protected:
3.78 - typedef AlterationNotifier Registry;
3.79 -
3.80 - friend class AlterationNotifier;
3.81 -
3.82 - /// Default constructor.
3.83 -
3.84 - /// Default constructor for ObserverBase.
3.85 - ///
3.86 - ObserverBase() : registry(0) {}
3.87 -
3.88 - virtual ~ObserverBase() {}
3.89 -
3.90 - /// Attaches the observer into an AlterationNotifier.
3.91 -
3.92 - /// This member attaches the observer into an AlterationNotifier.
3.93 - ///
3.94 - void attach(AlterationNotifier& r) {
3.95 - registry = &r;
3.96 - registry->attach(*this);
3.97 - }
3.98 -
3.99 - /// Detaches the observer into an AlterationNotifier.
3.100 -
3.101 - /// This member detaches the observer from an AlterationNotifier.
3.102 - ///
3.103 - void detach() {
3.104 - if (registry) {
3.105 - registry->detach(*this);
3.106 - }
3.107 - }
3.108 -
3.109 -
3.110 - /// Gives back a pointer to the registry what the map attached into.
3.111 -
3.112 - /// This function gives back a pointer to the registry what the map
3.113 - /// attached into.
3.114 - ///
3.115 - Registry* getRegistry() const { return const_cast<Registry*>(registry); }
3.116 -
3.117 - /// Gives back true when the observer is attached into a registry.
3.118 - bool attached() const { return registry != 0; }
3.119 -
3.120 - private:
3.121 -
3.122 - ObserverBase(const ObserverBase& copy);
3.123 - ObserverBase& operator=(const ObserverBase& copy);
3.124 -
3.125 - protected:
3.126 -
3.127 - Registry* registry;
3.128 - int registry_index;
3.129 -
3.130 - public:
3.131 -
3.132 - /// \brief The member function to notificate the observer about an
3.133 - /// item is added to the container.
3.134 - ///
3.135 - /// The add() member function notificates the observer about an item
3.136 - /// is added to the container. It have to be overrided in the
3.137 - /// subclasses.
3.138 -
3.139 - virtual void add(const Item&) = 0;
3.140 -
3.141 -
3.142 - /// \brief The member function to notificate the observer about an
3.143 - /// item is erased from the container.
3.144 - ///
3.145 - /// The erase() member function notificates the observer about an
3.146 - /// item is erased from the container. It have to be overrided in
3.147 - /// the subclasses.
3.148 -
3.149 - virtual void erase(const Item&) = 0;
3.150 -
3.151 - /// \brief The member function to notificate the observer about the
3.152 - /// container is builded.
3.153 - ///
3.154 - /// The build() member function notificates the observer about the
3.155 - /// container is builded from an empty container. It have to be
3.156 - /// overrided in the subclasses.
3.157 -
3.158 - virtual void build() = 0;
3.159 -
3.160 - /// \brief The member function to notificate the observer about all
3.161 - /// items are erased from the container.
3.162 - ///
3.163 - /// The clear() member function notificates the observer about all
3.164 - /// items are erased from the container. It have to be overrided in
3.165 - /// the subclasses.
3.166 -
3.167 - virtual void clear() = 0;
3.168 -
3.169 - };
3.170 -
3.171 - protected:
3.172 -
3.173 -
3.174 - typedef std::vector<ObserverBase*> Container;
3.175 -
3.176 - Container container;
3.177 -
3.178 -
3.179 - public:
3.180 -
3.181 - /// Default constructor.
3.182 -
3.183 - ///
3.184 - /// The default constructor of the AlterationNotifier.
3.185 - /// It creates an empty registry.
3.186 - AlterationNotifier() {}
3.187 -
3.188 - /// Copy Constructor of the AlterationNotifier.
3.189 -
3.190 - /// Copy constructor of the AlterationNotifier.
3.191 - /// It creates only an empty registry because the copiable
3.192 - /// registry's observers have to be registered still into that registry.
3.193 - AlterationNotifier(const AlterationObserverRegistry&) {}
3.194 -
3.195 - /// Assign operator.
3.196 -
3.197 - /// Assign operator for the AlterationNotifier.
3.198 - /// It makes the registry only empty because the copiable
3.199 - /// registry's observers have to be registered still into that registry.
3.200 - AlterationNotifier& operator=(const AlterationObserverRegistry&) {
3.201 - typename Container::iterator it;
3.202 - for (it = container.begin(); it != container.end(); ++it) {
3.203 - (*it)->registry = 0;
3.204 - }
3.205 - }
3.206 -
3.207 - /// Destructor.
3.208 -
3.209 - /// Destructor of the AlterationNotifier.
3.210 - ///
3.211 - ~AlterationNotifier() {
3.212 - typename Container::iterator it;
3.213 - for (it = container.begin(); it != container.end(); ++it) {
3.214 - (*it)->registry = 0;
3.215 - }
3.216 - }
3.217 -
3.218 -
3.219 - protected:
3.220 -
3.221 - void attach(ObserverBase& observer) {
3.222 - container.push_back(&observer);
3.223 - observer.registry = this;
3.224 - observer.registry_index = container.size()-1;
3.225 - }
3.226 -
3.227 - void detach(ObserverBase& base) {
3.228 - container.back()->registry_index = base.registry_index;
3.229 - container[base.registry_index] = container.back();
3.230 - container.pop_back();
3.231 - base.registry = 0;
3.232 - }
3.233 -
3.234 - public:
3.235 -
3.236 - /// Notifies all the registered observers about an Item added to the container.
3.237 -
3.238 - /// It notifies all the registered observers about an Item added to the container.
3.239 - ///
3.240 - void add(const Item& key) {
3.241 - typename Container::iterator it;
3.242 - for (it = container.begin(); it != container.end(); ++it) {
3.243 - (*it)->add(key);
3.244 - }
3.245 - }
3.246 -
3.247 - /// Notifies all the registered observers about an Item erased from the container.
3.248 -
3.249 - /// It notifies all the registered observers about an Item erased from the container.
3.250 - ///
3.251 - void erase(const Item& key) {
3.252 - typename Container::iterator it;
3.253 - for (it = container.begin(); it != container.end(); ++it) {
3.254 - (*it)->erase(key);
3.255 - }
3.256 - }
3.257 -
3.258 -
3.259 - /// Notifies all the registered observers about the container is builded.
3.260 -
3.261 - /// Notifies all the registered observers about the container is builded
3.262 - /// from an empty container.
3.263 - void build() {
3.264 - typename Container::iterator it;
3.265 - for (it = container.begin(); it != container.end(); ++it) {
3.266 - (*it)->build();
3.267 - }
3.268 - }
3.269 -
3.270 -
3.271 - /// Notifies all the registered observers about all Items are erased.
3.272 -
3.273 - /// Notifies all the registered observers about all Items are erased
3.274 - /// from the container.
3.275 - void clear() {
3.276 - typename Container::iterator it;
3.277 - for (it = container.begin(); it != container.end(); ++it) {
3.278 - (*it)->clear();
3.279 - }
3.280 - }
3.281 - };
3.282 -
3.283 -
3.284 - /// \brief Class to extend a graph with the functionality of alteration
3.285 - /// observing.
3.286 - ///
3.287 - /// AlterableGraphExtender extends the _Base graphs functionality with
3.288 - /// the possibility of alteration observing. It defines two observer
3.289 - /// registrys for the nodes and mapes.
3.290 - ///
3.291 - /// \todo Document what "alteration observing" is. And probably find a
3.292 - /// better (shorter) name.
3.293 - ///
3.294 - /// \param _Base is the base class to extend.
3.295 - ///
3.296 - /// \pre _Base is conform to the BaseGraphComponent concept.
3.297 - ///
3.298 - /// \post AlterableGraphExtender<_Base> is conform to the
3.299 - /// AlterableGraphComponent concept.
3.300 - ///
3.301 - /// \author Balazs Dezso
3.302 -
3.303 - template <typename _Base>
3.304 - class AlterableGraphExtender : public _Base {
3.305 - public:
3.306 -
3.307 - typedef AlterableGraphExtender Graph;
3.308 - typedef _Base Parent;
3.309 -
3.310 - typedef typename Parent::Node Node;
3.311 - typedef typename Parent::Edge Edge;
3.312 -
3.313 - /// The edge observer registry.
3.314 - typedef AlterationNotifier<Edge> EdgeObserverRegistry;
3.315 - /// The node observer registry.
3.316 - typedef AlterationNotifier<Node> NodeObserverRegistry;
3.317 -
3.318 -
3.319 - protected:
3.320 -
3.321 - mutable EdgeNotifier edge_observers;
3.322 -
3.323 - mutable NodeNotifier node_observers;
3.324 -
3.325 - public:
3.326 -
3.327 - EdgeNotifier& getObserverRegistry(Edge = INVALID) const {
3.328 - return edge_observers;
3.329 - }
3.330 -
3.331 - NodeNotifier& getObserverRegistry(Node = INVALID) const {
3.332 - return node_observers;
3.333 - }
3.334 -
3.335 - ~AlterableGraphExtender() {
3.336 - node_observers.clear();
3.337 - edge_observers.clear();
3.338 - }
3.339 -
3.340 - };
3.341 -
3.342 - /// \brief Class to extend an undirected graph with the functionality of
3.343 - /// alteration observing.
3.344 - ///
3.345 - /// \todo Document.
3.346 - ///
3.347 - /// \sa AlterableGraphExtender
3.348 - ///
3.349 - /// \bug This should be done some other way. Possibilities: template
3.350 - /// specialization (not very easy, if at all possible); some kind of
3.351 - /// enable_if boost technique?
3.352 -
3.353 - template <typename _Base>
3.354 - class AlterableUndirGraphExtender
3.355 - : public AlterableGraphExtender<_Base> {
3.356 - public:
3.357 -
3.358 - typedef AlterableUndirGraphExtender Graph;
3.359 - typedef AlterableGraphExtender<_Base> Parent;
3.360 -
3.361 - typedef typename Parent::UndirEdge UndirEdge;
3.362 -
3.363 - /// The edge observer registry.
3.364 - typedef AlterationNotifier<UndirEdge> UndirEdgeObserverRegistry;
3.365 -
3.366 - protected:
3.367 -
3.368 - mutable UndirEdgeNotifier undir_edge_observers;
3.369 -
3.370 - public:
3.371 -
3.372 - using Parent::getNotifier;
3.373 - UndirEdgeNotifier& getObserverRegistry(UndirEdge) const {
3.374 - return undir_edge_observers;
3.375 - }
3.376 -
3.377 - ~AlterableUndirGraphExtender() {
3.378 - undir_edge_observers.clear();
3.379 - }
3.380 - };
3.381 -
3.382 -/// @}
3.383 -
3.384 -
3.385 -}
3.386 -
3.387 -#endif
4.1 --- a/src/lemon/array_map.h Thu Dec 16 12:15:02 2004 +0000
4.2 +++ b/src/lemon/array_map.h Thu Dec 16 12:26:57 2004 +0000
4.3 @@ -43,7 +43,7 @@
4.4 typename _Item,
4.5 typename _ItemIt,
4.6 typename _Value>
4.7 - class ArrayMap : public AlterationObserverRegistry<_Item>::ObserverBase {
4.8 + class ArrayMap : public AlterationNotifier<_Item>::ObserverBase {
4.9
4.10 public:
4.11
4.12 @@ -52,7 +52,7 @@
4.13 /// The key type of the maps.
4.14 typedef _Item Key;
4.15
4.16 - typedef AlterationObserverRegistry<_Item> Registry;
4.17 + typedef AlterationNotifier<_Item> Registry;
4.18
4.19 private:
4.20 /// The iterator to iterate on the keys.
4.21 @@ -88,7 +88,7 @@
4.22 /** Graph and Registry initialized map constructor.
4.23 */
4.24 ArrayMap(const Graph& _g) : graph(&_g) {
4.25 - attach(_g.getObserverRegistry(_Item()));
4.26 + attach(_g.getNotifier(_Item()));
4.27 allocate_memory();
4.28 for (KeyIt it(*graph); it != INVALID; ++it) {
4.29 int id = graph->id(it);;
4.30 @@ -101,7 +101,7 @@
4.31 /// It constrates a map and initialize all of the the map.
4.32
4.33 ArrayMap(const Graph& _g, const Value& _v) : graph(&_g) {
4.34 - attach(_g.getObserverRegistry(_Item()));
4.35 + attach(_g.getNotifier(_Item()));
4.36 allocate_memory();
4.37 for (KeyIt it(*graph); it != INVALID; ++it) {
4.38 int id = graph->id(it);;
4.39 @@ -336,11 +336,11 @@
4.40
4.41 typedef typename Parent::Node Node;
4.42 typedef typename Parent::NodeIt NodeIt;
4.43 - typedef typename Parent::NodeObserverRegistry NodeObserverRegistry;
4.44 + typedef typename Parent::NodeNotifier NodeObserverRegistry;
4.45
4.46 typedef typename Parent::Edge Edge;
4.47 typedef typename Parent::EdgeIt EdgeIt;
4.48 - typedef typename Parent::EdgeObserverRegistry EdgeObserverRegistry;
4.49 + typedef typename Parent::EdgeNotifier EdgeObserverRegistry;
4.50
4.51
4.52
5.1 --- a/src/lemon/clearable_graph_extender.h Thu Dec 16 12:15:02 2004 +0000
5.2 +++ b/src/lemon/clearable_graph_extender.h Thu Dec 16 12:26:57 2004 +0000
5.3 @@ -18,8 +18,8 @@
5.4 typedef typename Parent::Edge Edge;
5.5
5.6 void clear() {
5.7 - Parent::getObserverRegistry(Node()).clear();
5.8 - Parent::getObserverRegistry(Edge()).clear();
5.9 + Parent::getNotifier(Node()).clear();
5.10 + Parent::getNotifier(Edge()).clear();
5.11 Parent::clear();
5.12 }
5.13
5.14 @@ -36,9 +36,9 @@
5.15 typedef typename Parent::Edge Edge;
5.16
5.17 void clear() {
5.18 - Parent::getObserverRegistry(Node()).clear();
5.19 - Parent::getObserverRegistry(UndirEdge()).clear();
5.20 - Parent::getObserverRegistry(Edge()).clear();
5.21 + Parent::getNotifier(Node()).clear();
5.22 + Parent::getNotifier(UndirEdge()).clear();
5.23 + Parent::getNotifier(Edge()).clear();
5.24 Parent::clear();
5.25 }
5.26
6.1 --- a/src/lemon/erasable_graph_extender.h Thu Dec 16 12:15:02 2004 +0000
6.2 +++ b/src/lemon/erasable_graph_extender.h Thu Dec 16 12:26:57 2004 +0000
6.3 @@ -32,12 +32,12 @@
6.4 Parent::firstIn(edge, node);
6.5 }
6.6
6.7 - Parent::getObserverRegistry(Node()).erase(node);
6.8 + Parent::getNotifier(Node()).erase(node);
6.9 Parent::erase(node);
6.10 }
6.11
6.12 void erase(const Edge& edge) {
6.13 - Parent::getObserverRegistry(Edge()).erase(edge);
6.14 + Parent::getNotifier(Edge()).erase(edge);
6.15 Parent::erase(edge);
6.16 }
6.17
6.18 @@ -62,14 +62,14 @@
6.19 Parent::firstOut(edge, node);
6.20 }
6.21
6.22 - Parent::getObserverRegistry(Node()).erase(node);
6.23 + Parent::getNotifier(Node()).erase(node);
6.24 Parent::erase(node);
6.25 }
6.26
6.27 void erase(const UndirEdge& uedge) {
6.28 - Parent::getObserverRegistry(Edge()).erase(Edge(uedge,true));
6.29 - Parent::getObserverRegistry(Edge()).erase(Edge(uedge,false));
6.30 - Parent::getObserverRegistry(UndirEdge()).erase(uedge);
6.31 + Parent::getNotifier(Edge()).erase(Edge(uedge,true));
6.32 + Parent::getNotifier(Edge()).erase(Edge(uedge,false));
6.33 + Parent::getNotifier(UndirEdge()).erase(uedge);
6.34 Parent::erase(uedge);
6.35 }
6.36
7.1 --- a/src/lemon/extendable_graph_extender.h Thu Dec 16 12:15:02 2004 +0000
7.2 +++ b/src/lemon/extendable_graph_extender.h Thu Dec 16 12:26:57 2004 +0000
7.3 @@ -17,13 +17,13 @@
7.4
7.5 Node addNode() {
7.6 Node node = Parent::addNode();
7.7 - Parent::getObserverRegistry(Node()).add(node);
7.8 + Parent::getNotifier(Node()).add(node);
7.9 return node;
7.10 }
7.11
7.12 Edge addEdge(const Node& from, const Node& to) {
7.13 Edge edge = Parent::addEdge(from, to);
7.14 - Parent::getObserverRegistry(Edge()).add(edge);
7.15 + Parent::getNotifier(Edge()).add(edge);
7.16 return edge;
7.17 }
7.18
7.19 @@ -42,18 +42,18 @@
7.20
7.21 Node addNode() {
7.22 Node node = Parent::addNode();
7.23 - Parent::getObserverRegistry(Node()).add(node);
7.24 + Parent::getNotifier(Node()).add(node);
7.25 return node;
7.26 }
7.27
7.28 UndirEdge addEdge(const Node& from, const Node& to) {
7.29 UndirEdge uedge = Parent::addEdge(from, to);
7.30 - Parent::getObserverRegistry(UndirEdge()).add(uedge);
7.31 + Parent::getNotifier(UndirEdge()).add(uedge);
7.32
7.33 Edge edge_forward(uedge, true);
7.34 Edge edge_backward(uedge, false);
7.35 - Parent::getObserverRegistry(Edge()).add(edge_forward);
7.36 - Parent::getObserverRegistry(Edge()).add(edge_backward);
7.37 + Parent::getNotifier(Edge()).add(edge_forward);
7.38 + Parent::getNotifier(Edge()).add(edge_backward);
7.39
7.40 return uedge;
7.41 }
8.1 --- a/src/lemon/full_graph.h Thu Dec 16 12:15:02 2004 +0000
8.2 +++ b/src/lemon/full_graph.h Thu Dec 16 12:26:57 2004 +0000
8.3 @@ -21,7 +21,7 @@
8.4
8.5
8.6 #include <lemon/iterable_graph_extender.h>
8.7 -#include <lemon/alteration_observer_registry.h>
8.8 +#include <lemon/alteration_notifier.h>
8.9 #include <lemon/default_map.h>
8.10
8.11 #include <lemon/invalid.h>
9.1 --- a/src/lemon/list_graph.h Thu Dec 16 12:15:02 2004 +0000
9.2 +++ b/src/lemon/list_graph.h Thu Dec 16 12:26:57 2004 +0000
9.3 @@ -25,7 +25,7 @@
9.4 #include <lemon/clearable_graph_extender.h>
9.5 #include <lemon/extendable_graph_extender.h>
9.6 #include <lemon/iterable_graph_extender.h>
9.7 -#include <lemon/alteration_observer_registry.h>
9.8 +#include <lemon/alteration_notifier.h>
9.9 #include <lemon/default_map.h>
9.10
9.11 #include <lemon/undir_graph_extender.h>
9.12 @@ -399,8 +399,8 @@
9.13 ///\warning SnapShots cannot be nested.
9.14 ///\ingroup graphs
9.15 ///\todo \c SnapShot or \c Snapshot?
9.16 - class SnapShot : protected AlterationObserverRegistry<Node>::ObserverBase,
9.17 - protected AlterationObserverRegistry<Edge>::ObserverBase
9.18 + class SnapShot : protected AlterationNotifier<Node>::ObserverBase,
9.19 + protected AlterationNotifier<Edge>::ObserverBase
9.20 {
9.21 protected:
9.22
9.23 @@ -430,16 +430,16 @@
9.24
9.25 void regist(ListGraph &_g) {
9.26 g=&_g;
9.27 - AlterationObserverRegistry<Node>::ObserverBase::
9.28 + AlterationNotifier<Node>::ObserverBase::
9.29 attach(g->node_observers);
9.30 - AlterationObserverRegistry<Edge>::ObserverBase::
9.31 + AlterationNotifier<Edge>::ObserverBase::
9.32 attach(g->edge_observers);
9.33 }
9.34
9.35 void deregist() {
9.36 - AlterationObserverRegistry<Node>::ObserverBase::
9.37 + AlterationNotifier<Node>::ObserverBase::
9.38 detach();
9.39 - AlterationObserverRegistry<Edge>::ObserverBase::
9.40 + AlterationNotifier<Edge>::ObserverBase::
9.41 detach();
9.42 g=0;
9.43 }
10.1 --- a/src/lemon/smart_graph.h Thu Dec 16 12:15:02 2004 +0000
10.2 +++ b/src/lemon/smart_graph.h Thu Dec 16 12:26:57 2004 +0000
10.3 @@ -28,7 +28,7 @@
10.4 #include <lemon/clearable_graph_extender.h>
10.5 #include <lemon/extendable_graph_extender.h>
10.6 #include <lemon/iterable_graph_extender.h>
10.7 -#include <lemon/alteration_observer_registry.h>
10.8 +#include <lemon/alteration_notifier.h>
10.9 #include <lemon/default_map.h>
10.10
10.11 #include <lemon/undir_graph_extender.h>
11.1 --- a/src/lemon/vector_map.h Thu Dec 16 12:15:02 2004 +0000
11.2 +++ b/src/lemon/vector_map.h Thu Dec 16 12:26:57 2004 +0000
11.3 @@ -20,7 +20,7 @@
11.4 #include <vector>
11.5 #include <algorithm>
11.6
11.7 -#include <lemon/alteration_observer_registry.h>
11.8 +#include <lemon/alteration_notifier.h>
11.9
11.10 ///\ingroup graphmaps
11.11 ///\file
11.12 @@ -37,7 +37,7 @@
11.13 /// the container functionality. This map factory
11.14 /// uses the std::vector to implement the container function.
11.15 ///
11.16 - /// \param Registry The AlterationObserverRegistry that will notify this map.
11.17 + /// \param Registry The AlterationNotifier that will notify this map.
11.18 /// \param IdMap The IdMap type of the graph items.
11.19 /// \param Value The value type of the map.
11.20 ///
11.21 @@ -47,7 +47,7 @@
11.22 template <typename _Graph,
11.23 typename _Item,
11.24 typename _Value>
11.25 - class VectorMap : public AlterationObserverRegistry<_Item>::ObserverBase {
11.26 + class VectorMap : public AlterationNotifier<_Item>::ObserverBase {
11.27 public:
11.28
11.29 /// The graph type of the map.
11.30 @@ -55,7 +55,7 @@
11.31 /// The key type of the map.
11.32 typedef _Item Key;
11.33 /// The id map type of the map.
11.34 - typedef AlterationObserverRegistry<_Item> Registry;
11.35 + typedef AlterationNotifier<_Item> Registry;
11.36 /// The value type of the map.
11.37 typedef _Value Value;
11.38
11.39 @@ -89,7 +89,7 @@
11.40 /// It adds all the items of the graph to the map.
11.41
11.42 VectorMap(const Graph& _g) : graph(&_g) {
11.43 - attach(_g.getObserverRegistry(_Item()));
11.44 + attach(_g.getNotifier(_Item()));
11.45 build();
11.46 }
11.47
11.48 @@ -99,7 +99,7 @@
11.49 /// It adds all the items of the graph to the map.
11.50
11.51 VectorMap(const Graph& _g, const Value& _v) : graph(&_g) {
11.52 - attach(_g.getObserverRegistry(_Item()));
11.53 + attach(_g.getNotifier(_Item()));
11.54 container.resize(graph->maxId(_Item()) + 1, _v);
11.55 }
11.56
11.57 @@ -224,12 +224,12 @@
11.58 typedef typename Parent::Node Node;
11.59 typedef typename Parent::NodeIt NodeIt;
11.60 typedef typename Parent::NodeIdMap NodeIdMap;
11.61 - typedef typename Parent::NodeObserverRegistry NodeObserverRegistry;
11.62 + typedef typename Parent::NodeNotifier NodeObserverRegistry;
11.63
11.64 typedef typename Parent::Edge Edge;
11.65 typedef typename Parent::EdgeIt EdgeIt;
11.66 typedef typename Parent::EdgeIdMap EdgeIdMap;
11.67 - typedef typename Parent::EdgeObserverRegistry EdgeObserverRegistry;
11.68 + typedef typename Parent::EdgeNotifier EdgeObserverRegistry;
11.69
11.70
11.71