7 ///\brief Defines to help creating graph maps.
9 /// \addtogroup graphmapfactory
12 /** Creates the EdgeMapRegistry type an declare a mutable instance
15 #define CREATE_EDGE_MAP_REGISTRY \
16 typedef MapRegistry<Graph, Edge, EdgeIt> EdgeMapRegistry; \
17 mutable EdgeMapRegistry edge_maps;
19 /** Creates the NodeMapRegistry type an declare a mutable instance
22 #define CREATE_NODE_MAP_REGISTRY \
23 typedef MapRegistry<Graph, Node, NodeIt> NodeMapRegistry; \
24 mutable NodeMapRegistry node_maps;
26 /** Creates both map registries.
28 #define CREATE_MAP_REGISTRIES \
29 CREATE_NODE_MAP_REGISTRY \
30 CREATE_EDGE_MAP_REGISTRY
32 /** Creates a map from a template map. The import method is
33 * an overloading of the map type.
34 * The reason to use these macro is that the c++ does not support
35 * the template typedefs. If a future release of the c++
36 * supports this feature it should be fixed.
38 #define CREATE_NODE_MAP(DynMap) \
39 template <typename Value> \
40 class NodeMap : public DynMap<NodeMapRegistry, Value> { \
41 typedef DynMap<NodeMapRegistry, Value> MapImpl; \
44 NodeMap(const typename MapImpl::Graph& g) \
45 : MapImpl(g, g.node_maps) {} \
46 NodeMap(const typename MapImpl::Graph& g, const Value& v) \
47 : MapImpl(g, g.node_maps, v) {} \
48 NodeMap(const NodeMap& copy) : MapImpl(static_cast<const MapImpl&>(copy)) {} \
49 template <typename CMap> NodeMap(const CMap& copy) : MapImpl(copy) {} \
50 NodeMap& operator=(const NodeMap& copy) { \
51 MapImpl::operator=(static_cast<const MapImpl&>(copy));\
54 template <typename CMap> NodeMap& operator=(const CMap& copy) { \
55 MapImpl::operator=(copy);\
60 /** Creates a map from a template map. The import method is
61 * an overloading of the map type.
62 * The reason to use these macro is that the c++ does not support
63 * the template typedefs. If a future release of the c++
64 * supports this feature it should be fixed.
66 #define CREATE_EDGE_MAP(DynMap) \
67 template <typename Value> \
68 class EdgeMap : public DynMap<EdgeMapRegistry, Value> { \
69 typedef DynMap<EdgeMapRegistry, Value> MapImpl; \
72 EdgeMap(const typename MapImpl::Graph& g) \
73 : MapImpl(g, g.edge_maps) {} \
74 EdgeMap(const typename MapImpl::Graph& g, const Value& v) \
75 : MapImpl(g, g.edge_maps, v) {} \
76 EdgeMap(const EdgeMap& copy) : MapImpl(static_cast<const MapImpl&>(copy)) {} \
77 template <typename CMap> EdgeMap(const CMap& copy) : MapImpl(copy) {} \
78 EdgeMap& operator=(const EdgeMap& copy) { \
79 MapImpl::operator=(static_cast<const MapImpl&>(copy));\
82 template <typename CMap> EdgeMap& operator=(const CMap& copy) { \
83 MapImpl::operator=(copy);\
88 /** This macro creates both maps.
90 #define CREATE_MAPS(DynMap) \
91 CREATE_NODE_MAP(DynMap) \
92 CREATE_EDGE_MAP(DynMap)
94 /** This macro creates MapRegistry for Symmetric Edge Maps.
96 #define CREATE_SYM_EDGE_MAP_REGISTRY \
97 typedef SymEdgeIt<Graph, Edge, EdgeIt> SymEdgeIt; \
98 typedef MapRegistry<Graph, Edge, SymEdgeIt> SymEdgeMapRegistry; \
99 mutable EdgeMapRegistry sym_edge_maps;
102 /** Creates a map from a template map. The import method is
103 * an overloading of the map type.
104 * The reason to use these macro is that the c++ does not support
105 * the template typedefs. If a future release of the c++
106 * supports this feature it should be fixed.
108 #define CREATE_SYM_EDGE_MAP(DynMap) \
109 template <typename Value> \
110 class SymEdgeMap : public SymMap<DynMap, SymEdgeMapRegistry, Value> { \
111 typedef SymMap<DynMap, SymEdgeMapRegistry, Value> MapImpl; \
116 SymEdgeMap(const typename MapImpl::Graph& g) \
117 : MapImpl(g, g.sym_edge_maps) {} \
119 SymEdgeMap(const typename MapImpl::Graph& g, const Value& v) \
120 : MapImpl(g, g.sym_edge_maps, v) {} \
122 SymEdgeMap(const SymEdgeMap& copy) \
123 : MapImpl(static_cast<const MapImpl&>(copy)) {} \
125 template <typename CMap> SymEdgeMap(const CMap& copy) : MapImpl(copy) {} \
126 SymEdgeMap& operator=(const SymEdgeMap& copy) { \
127 MapImpl::operator=(static_cast<const MapImpl&>(copy));\
131 template <typename CMap> SymEdgeMap& operator=(const CMap& copy) { \
132 MapImpl::operator=(copy);\
138 /** This is a macro to import an node map into a graph class.
140 #define IMPORT_NODE_MAP(From, from, To, to) \
141 template <typename Value> \
143 : public From::template NodeMap<Value> { \
144 typedef typename From::template NodeMap<Value> MapImpl; \
146 NodeMap() : MapImpl() {} \
148 NodeMap(const To& to) \
149 : MapImpl(static_cast<const From&>(from)) { } \
151 NodeMap(const To& to, const Value& value) \
152 : MapImpl(static_cast<const From&>(from), value) { } \
154 NodeMap(const NodeMap& copy) \
155 : MapImpl(static_cast<const MapImpl&>(copy)) {} \
157 template<typename CMap> \
158 NodeMap(const CMap& copy) \
161 NodeMap& operator=(const NodeMap& copy) { \
162 MapImpl::operator=(static_cast<const MapImpl&>(copy)); \
166 template <typename CMap> \
167 NodeMap& operator=(const CMap& copy) { \
168 MapImpl::operator=(copy); \
173 /** This is a macro to import an edge map into a graph class.
175 #define IMPORT_EDGE_MAP(From, from, To, to) \
176 template <typename Value> \
178 : public From::template EdgeMap<Value> { \
179 typedef typename From::template EdgeMap<Value> MapImpl; \
181 EdgeMap() : MapImpl() {} \
183 EdgeMap(const To& to) \
184 : MapImpl(static_cast<const From&>(from)) { } \
186 EdgeMap(const To& to, const Value& value) \
187 : MapImpl(static_cast<const From&>(from), value) { } \
189 EdgeMap(const EdgeMap& copy) \
190 : MapImpl(static_cast<const MapImpl&>(copy)) {} \
192 template<typename CMap> \
193 EdgeMap(const CMap& copy) \
196 EdgeMap& operator=(const EdgeMap& copy) { \
197 MapImpl::operator=(static_cast<const MapImpl&>(copy)); \
201 template <typename CMap> \
202 EdgeMap& operator=(const CMap& copy) { \
203 MapImpl::operator=(copy); \
209 /** This is a macro to keep the node and edge maps for a graph class.
211 #define KEEP_MAPS(From, To) \
212 IMPORT_EDGE_MAP(From, graph, To, graph) \
213 IMPORT_NODE_MAP(From, graph, To, graph)