Cross references turned off.
7 ///\ingroup graphmapfactory
9 ///\brief Map registry for graph maps.
15 /// \addtogroup graphmapfactory
19 * Registry class to register edge or node maps into the graph. The
20 * registry helps you to implement an observer pattern. If you add
21 * or erase an edge or node you must notify all the maps about the
24 template <typename G, typename K, typename KIt>
32 * MapBase is the base class of the registered maps.
33 * It defines the core modification operations on the maps and
34 * implements some helper functions.
42 typedef MapRegistry<G, K, KIt> Registry;
44 friend class MapRegistry<G, K, KIt>;
47 * Default constructor for MapBase.
50 MapBase() : graph(0), registry(0) {}
53 * Simple constructor to register into a graph registry.
56 MapBase(const Graph& g, Registry& r) : graph(&g), registry(0) {
61 * Copy constructor to register into the registry.
64 MapBase(const MapBase& copy) : graph(copy.graph), registry(0) {
66 copy.registry->attach(*this);
74 const MapBase& operator=(const MapBase& copy) {
76 registry->detach(*this);
80 copy.registry->attach(*this);
92 registry->detach(*this);
97 * Returns the graph that the map belongs to.
100 const Graph* getGraph() const { return graph; }
112 Helper function to implement constructors in the subclasses.
115 virtual void init() {
116 for (KeyIt it(*graph); it != INVALID; ++it) {
122 Helper function to implement the destructor in the subclasses.
125 virtual void destroy() {
126 for (KeyIt it(*getGraph()); it != INVALID; ++it) {
132 The add member function should be overloaded in the subclasses.
133 \e Add extends the map with the new node.
136 virtual void add(const KeyType&) = 0;
138 The erase member function should be overloaded in the subclasses.
139 \e Erase removes the node from the map.
142 virtual void erase(const KeyType&) = 0;
145 * The clear member function should be overloaded in the subclasses.
146 * \e Clear makes empty the data structure.
149 virtual void clear() = 0;
152 Exception class to throw at unsupported operation.
155 class NotSupportedOperationException {};
162 * The container type of the maps.
164 typedef std::vector<MapBase*> Container;
167 * The container of the registered maps.
175 * Default Constructor of the MapRegistry. It creates an empty registry.
180 * Copy Constructor of the MapRegistry. The new registry does not steal
181 * the maps from the right value. The new registry will be an empty.
183 MapRegistry(const MapRegistry&) {}
186 * Assign operator. The left value does not steal the maps
187 * from the right value. The left value will be an empty registry.
189 MapRegistry& operator=(const MapRegistry&) {
190 typename Container::iterator it;
191 for (it = container.begin(); it != container.end(); ++it) {
199 * Destructor of the MapRegistry.
202 typename Container::iterator it;
203 for (it = container.begin(); it != container.end(); ++it) {
214 * Attach a map into thr registry. If the map has been attached
215 * into an other registry it is detached from that automaticly.
217 void attach(MapBase& map) {
219 map.registry->detach(map);
221 container.push_back(&map);
223 map.registry_index = container.size()-1;
227 * Detach the map from the registry.
229 void detach(MapBase& map) {
230 container.back()->registry_index = map.registry_index;
231 container[map.registry_index] = container.back();
232 container.pop_back();
239 * Notify all the registered maps about a Key added.
241 void add(KeyType& key) {
242 typename Container::iterator it;
243 for (it = container.begin(); it != container.end(); ++it) {
249 * Notify all the registered maps about a Key erased.
251 void erase(KeyType& key) {
252 typename Container::iterator it;
253 for (it = container.begin(); it != container.end(); ++it) {
259 * Notify all the registered maps about the map should be cleared.
262 typename Container::iterator it;
263 for (it = container.begin(); it != container.end(); ++it) {