The default constructors are removed from the maps.
The ArrayMap is the map structure of the graphs.
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);
73 const MapBase& operator=(const MapBase& copy) {
75 registry->detach(*this);
79 copy.registry->attach(*this);
91 registry->detach(*this);
96 * Returns the graph that the map belongs to.
99 const Graph* getGraph() const { return graph; }
111 Helper function to implement constructors in the subclasses.
114 virtual void init() {
115 for (KeyIt it(*graph); it != INVALID; ++it) {
121 Helper function to implement the destructor in the subclasses.
124 virtual void destroy() {
125 for (KeyIt it(*getGraph()); it != INVALID; ++it) {
131 The add member function should be overloaded in the subclasses.
132 \e Add extends the map with the new node.
135 virtual void add(const KeyType&) = 0;
137 The erase member function should be overloaded in the subclasses.
138 \e Erase removes the node from the map.
141 virtual void erase(const KeyType&) = 0;
144 * The clear member function should be overloaded in the subclasses.
145 * \e Clear makes empty the data structure.
148 virtual void clear() = 0;
151 Exception class to throw at unsupported operation.
154 class NotSupportedOperationException {};
161 * The container type of the maps.
163 typedef std::vector<MapBase*> Container;
166 * The container of the registered maps.
174 * Default Constructor of the MapRegistry. It creates an empty registry.
179 * Copy Constructor of the MapRegistry. The new registry does not steal
180 * the maps from the right value. The new registry will be an empty.
182 MapRegistry(const MapRegistry&) {}
185 * Assign operator. The left value does not steal the maps
186 * from the right value. The left value will be an empty registry.
188 MapRegistry& operator=(const MapRegistry&) {
189 typename Container::iterator it;
190 for (it = container.begin(); it != container.end(); ++it) {
198 * Destructor of the MapRegistry.
201 typename Container::iterator it;
202 for (it = container.begin(); it != container.end(); ++it) {
213 * Attach a map into thr registry. If the map has been attached
214 * into an other registry it is detached from that automaticly.
216 void attach(MapBase& map) {
218 map.registry->detach(map);
220 container.push_back(&map);
222 map.registry_index = container.size()-1;
226 * Detach the map from the registry.
228 void detach(MapBase& map) {
229 container.back()->registry_index = map.registry_index;
230 container[map.registry_index] = container.back();
231 container.pop_back();
238 * Notify all the registered maps about a Key added.
240 void add(KeyType& key) {
241 typename Container::iterator it;
242 for (it = container.begin(); it != container.end(); ++it) {
248 * Notify all the registered maps about a Key erased.
250 void erase(KeyType& key) {
251 typename Container::iterator it;
252 for (it = container.begin(); it != container.end(); ++it) {
258 * Notify all the registered maps about the map should be cleared.
261 typename Container::iterator it;
262 for (it = container.begin(); it != container.end(); ++it) {