deba@337: #ifndef EDGE_MAP_REGISTRY_H deba@337: #define EDGE_MAP_REGISTRY_H deba@337: deba@337: #include deba@337: deba@340: #include "edge_map_base.h" deba@340: deba@337: template deba@337: class EdgeMapRegistry { deba@337: public: deba@337: typedef G Graph; deba@337: typedef E Edge deba@337: deba@340: typedef EdgeMapBase MapBase; deba@337: deba@337: protected: deba@337: typedef std::vector Container; deba@337: deba@337: Container container; deba@337: deba@340: void add(MapBase& map_base) { deba@337: if (map_base.graph) { deba@337: map_base.graph->edge_maps.erase(map_base); deba@337: } deba@337: container.push_back(&map_base); deba@337: map_base.graph = this; deba@337: map_base.graph_index = container.size()-1; deba@337: } deba@337: deba@340: void erase(MapBase& map_base) { deba@337: if (map_base.graph != this) return; deba@337: container.back()->graph_index = map_base.graph_index; deba@337: container[map_base.graph_index] = container.back(); deba@337: container.pop_back(); deba@337: map_base.graph = 0; deba@337: } deba@337: deba@340: void add(Edge& edge) { deba@337: typename Container::iterator it; deba@337: for (it = container.begin(); it != container.end(); ++it) { deba@337: (*it)->add(edge); deba@337: } deba@337: } deba@337: deba@340: void erase(Edge& edge) { deba@337: typename Container::iterator it; deba@337: for (it = container.begin(); it != container.end(); ++it) { deba@337: (*it)->erase(edge); deba@337: } deba@337: } deba@337: deba@340: friend class MapBase; deba@337: }; deba@337: deba@337: #endif