27 */ |
27 */ |
28 #define CREATE_MAP_REGISTRIES \ |
28 #define CREATE_MAP_REGISTRIES \ |
29 CREATE_NODE_MAP_REGISTRY \ |
29 CREATE_NODE_MAP_REGISTRY \ |
30 CREATE_EDGE_MAP_REGISTRY |
30 CREATE_EDGE_MAP_REGISTRY |
31 |
31 |
32 /** Creates a concrete factory type from a template map |
32 /** Creates a map from a template map. The import method is |
33 * factory to use as node map factory. |
|
34 */ |
|
35 #define CREATE_NODE_MAP_FACTORY(TemplateFactory) \ |
|
36 typedef TemplateFactory<NodeMapRegistry> NodeMapFactory; |
|
37 |
|
38 /** Creates a concrete factory type from a template map |
|
39 * factory to use as edge map factory. |
|
40 */ |
|
41 #define CREATE_EDGE_MAP_FACTORY(TemplateFactory) \ |
|
42 typedef TemplateFactory<EdgeMapRegistry> EdgeMapFactory; |
|
43 |
|
44 /** Creates both map factories. |
|
45 */ |
|
46 #define CREATE_MAP_FACTORIES(TemplateFactory) \ |
|
47 CREATE_NODE_MAP_FACTORY(TemplateFactory) \ |
|
48 CREATE_EDGE_MAP_FACTORY(TemplateFactory) |
|
49 |
|
50 /** Import a map from a concrete map factory. The import method is |
|
51 * an overloading of the map type. |
33 * an overloading of the map type. |
52 * The reason to use these macro is that the c++ does not support |
34 * The reason to use these macro is that the c++ does not support |
53 * the template typedefs. If a future release of the c++ |
35 * the template typedefs. If a future release of the c++ |
54 * supports this feature it should be fixed. |
36 * supports this feature it should be fixed. |
55 */ |
37 */ |
56 #define IMPORT_NODE_MAP(Factory) \ |
38 #define CREATE_NODE_MAP(DynMap) \ |
57 template <typename V> \ |
39 template <typename Value> \ |
58 class NodeMap : public Factory::template Map<V> { \ |
40 class NodeMap : public DynMap<NodeMapRegistry, Value> { \ |
59 typedef typename Factory::template Map<V> MapImpl; \ |
41 typedef DynMap<NodeMapRegistry, Value> MapImpl; \ |
60 public: \ |
42 public: \ |
61 NodeMap() {} \ |
43 NodeMap() {} \ |
62 NodeMap(const Graph& g) : MapImpl(g, g.node_maps) {} \ |
44 NodeMap(const typename MapImpl::Graph& g) \ |
63 NodeMap(const Graph& g, const V& v) : MapImpl(g, g.node_maps, v) {} \ |
45 : MapImpl(g, g.node_maps) {} \ |
|
46 NodeMap(const typename MapImpl::Graph& g, const Value& v) \ |
|
47 : MapImpl(g, g.node_maps, v) {} \ |
64 NodeMap(const NodeMap& copy) : MapImpl(static_cast<const MapImpl&>(copy)) {} \ |
48 NodeMap(const NodeMap& copy) : MapImpl(static_cast<const MapImpl&>(copy)) {} \ |
65 template <typename CMap> NodeMap(const CMap& copy) : MapImpl(copy) {} \ |
49 template <typename CMap> NodeMap(const CMap& copy) : MapImpl(copy) {} \ |
66 NodeMap& operator=(const NodeMap& copy) { \ |
50 NodeMap& operator=(const NodeMap& copy) { \ |
67 MapImpl::operator=(static_cast<const MapImpl&>(copy));\ |
51 MapImpl::operator=(static_cast<const MapImpl&>(copy));\ |
68 return *this; \ |
52 return *this; \ |
71 MapImpl::operator=(copy);\ |
55 MapImpl::operator=(copy);\ |
72 return *this; \ |
56 return *this; \ |
73 } \ |
57 } \ |
74 }; |
58 }; |
75 |
59 |
76 /** Import a map from a concrete map factory. The import method is |
60 /** Creates a map from a template map. The import method is |
77 * an overloading of the map type. |
61 * an overloading of the map type. |
78 * The reason to use these macro is that the c++ does not support |
62 * The reason to use these macro is that the c++ does not support |
79 * the template typedefs. If a future release of the c++ |
63 * the template typedefs. If a future release of the c++ |
80 * supports this feature it should be fixed. |
64 * supports this feature it should be fixed. |
81 */ |
65 */ |
82 #define IMPORT_EDGE_MAP(Factory) \ |
66 #define CREATE_EDGE_MAP(DynMap) \ |
83 template <typename V> \ |
67 template <typename Value> \ |
84 class EdgeMap : public Factory::template Map<V> { \ |
68 class EdgeMap : public DynMap<EdgeMapRegistry, Value> { \ |
85 typedef typename Factory::template Map<V> MapImpl; \ |
69 typedef DynMap<EdgeMapRegistry, Value> MapImpl; \ |
86 public: \ |
70 public: \ |
87 EdgeMap() {} \ |
71 EdgeMap() {} \ |
88 EdgeMap(const Graph& g) : MapImpl(g, g.edge_maps) {} \ |
72 EdgeMap(const typename MapImpl::Graph& g) \ |
89 EdgeMap(const Graph& g, const V& v) : MapImpl(g, g.edge_maps, v) {} \ |
73 : MapImpl(g, g.edge_maps) {} \ |
|
74 EdgeMap(const typename MapImpl::Graph& g, const Value& v) \ |
|
75 : MapImpl(g, g.edge_maps, v) {} \ |
90 EdgeMap(const EdgeMap& copy) : MapImpl(static_cast<const MapImpl&>(copy)) {} \ |
76 EdgeMap(const EdgeMap& copy) : MapImpl(static_cast<const MapImpl&>(copy)) {} \ |
91 template <typename CMap> EdgeMap(const CMap& copy) : MapImpl(copy) {} \ |
77 template <typename CMap> EdgeMap(const CMap& copy) : MapImpl(copy) {} \ |
92 EdgeMap& operator=(const EdgeMap& copy) { \ |
78 EdgeMap& operator=(const EdgeMap& copy) { \ |
93 MapImpl::operator=(static_cast<const MapImpl&>(copy));\ |
79 MapImpl::operator=(static_cast<const MapImpl&>(copy));\ |
94 return *this; \ |
80 return *this; \ |
97 MapImpl::operator=(copy);\ |
83 MapImpl::operator=(copy);\ |
98 return *this; \ |
84 return *this; \ |
99 } \ |
85 } \ |
100 }; |
86 }; |
101 |
87 |
102 /** This macro creates both map factories and imports both maps. |
88 /** This macro creates both maps. |
103 */ |
89 */ |
104 #define CREATE_MAPS(TemplateFactory) \ |
90 #define CREATE_MAPS(DynMap) \ |
105 CREATE_MAP_FACTORIES(TemplateFactory) \ |
91 CREATE_NODE_MAP(DynMap) \ |
106 IMPORT_NODE_MAP(NodeMapFactory) \ |
92 CREATE_EDGE_MAP(DynMap) |
107 IMPORT_EDGE_MAP(EdgeMapFactory) |
|
108 |
93 |
109 /** This macro creates MapRegistry for Symmetric Edge Maps. |
94 /** This macro creates MapRegistry for Symmetric Edge Maps. |
110 */ |
95 */ |
111 #define CREATE_SYM_EDGE_MAP_REGISTRY \ |
96 #define CREATE_SYM_EDGE_MAP_REGISTRY \ |
112 typedef SymEdgeIt<Graph, Edge, EdgeIt> SymEdgeIt; \ |
97 typedef SymEdgeIt<Graph, Edge, EdgeIt> SymEdgeIt; \ |
113 typedef MapRegistry<Graph, Edge, SymEdgeIt> SymEdgeMapRegistry; \ |
98 typedef MapRegistry<Graph, Edge, SymEdgeIt> SymEdgeMapRegistry; \ |
114 mutable EdgeMapRegistry sym_edge_maps; |
99 mutable EdgeMapRegistry sym_edge_maps; |
115 |
100 |
116 /** Creates a concrete factory type from a template map |
101 |
117 * factory to use as edge map factory. |
102 /** Creates a map from a template map. The import method is |
118 */ |
|
119 #define CREATE_SYM_EDGE_MAP_FACTORY(TemplateFactory) \ |
|
120 typedef SymMapFactory<SymEdgeMapRegistry, TemplateFactory > \ |
|
121 SymEdgeMapFactory; |
|
122 |
|
123 /** Import a map from a concrete map factory. The import method is |
|
124 * an overloading of the map type. |
103 * an overloading of the map type. |
125 * The reason to use these macro is that the c++ does not support |
104 * The reason to use these macro is that the c++ does not support |
126 * the template typedefs. If a future release of the c++ |
105 * the template typedefs. If a future release of the c++ |
127 * supports this feature it should be fixed. |
106 * supports this feature it should be fixed. |
128 */ |
107 */ |
129 #define IMPORT_SYM_EDGE_MAP(Factory) \ |
108 #define CREATE_SYM_EDGE_MAP(DynMap) \ |
130 template <typename V> \ |
109 template <typename Value> \ |
131 class SymEdgeMap : public Factory::template Map<V> { \ |
110 class SymEdgeMap : public SymMap<DynMap, SymEdgeMapRegistry, Value> { \ |
132 typedef typename Factory::template Map<V> MapImpl; \ |
111 typedef SymMap<DynMap, SymEdgeMapRegistry, Value> MapImpl; \ |
133 public: \ |
112 public: \ |
134 SymEdgeMap() {} \ |
113 \ |
135 SymEdgeMap(const Graph& g) : MapImpl(g, g.sym_edge_maps) {} \ |
114 SymEdgeMap() {} \ |
136 SymEdgeMap(const Graph& g, const V& v) : MapImpl(g, g.sym_edge_maps, v) {} \ |
115 \ |
137 SymEdgeMap(const SymEdgeMap& copy) \ |
116 SymEdgeMap(const typename MapImpl::Graph& g) \ |
138 : MapImpl(static_cast<const MapImpl&>(copy)) {} \ |
117 : MapImpl(g, g.sym_edge_maps) {} \ |
139 template <typename CMap> SymEdgeMap(const CMap& copy) : MapImpl(copy) {} \ |
118 \ |
140 SymEdgeMap& operator=(const SymEdgeMap& copy) { \ |
119 SymEdgeMap(const typename MapImpl::Graph& g, const Value& v) \ |
141 MapImpl::operator=(static_cast<const MapImpl&>(copy));\ |
120 : MapImpl(g, g.sym_edge_maps, v) {} \ |
142 return *this; \ |
121 \ |
143 } \ |
122 SymEdgeMap(const SymEdgeMap& copy) \ |
144 template <typename CMap> SymEdgeMap& operator=(const CMap& copy) { \ |
123 : MapImpl(static_cast<const MapImpl&>(copy)) {} \ |
145 MapImpl::operator=(copy);\ |
124 \ |
146 return *this; \ |
125 template <typename CMap> SymEdgeMap(const CMap& copy) : MapImpl(copy) {} \ |
147 } \ |
126 SymEdgeMap& operator=(const SymEdgeMap& copy) { \ |
148 }; |
127 MapImpl::operator=(static_cast<const MapImpl&>(copy));\ |
149 |
128 return *this; \ |
150 |
129 } \ |
151 #define KEEP_NODE_MAP(GraphBase) \ |
130 \ |
152 template <typename V> class NodeMap \ |
131 template <typename CMap> SymEdgeMap& operator=(const CMap& copy) { \ |
153 : public GraphBase::template NodeMap<V> \ |
132 MapImpl::operator=(copy);\ |
154 { \ |
133 return *this; \ |
155 typedef typename GraphBase::template NodeMap<V> MapImpl; \ |
134 } \ |
156 typedef V Value; \ |
135 }; |
157 public: \ |
136 |
158 NodeMap() : MapImpl() {} \ |
137 |
159 \ |
138 /** This is a macro to import an node map into a graph class. |
160 NodeMap(const Graph& graph) \ |
139 */ |
161 : MapImpl(static_cast<const GraphBase&>(graph)) { } \ |
140 #define IMPORT_NODE_MAP(From, from, To, to) \ |
162 \ |
141 template <typename Value> \ |
163 NodeMap(const Graph& graph, const Value& value) \ |
142 class NodeMap \ |
164 : MapImpl(static_cast<const GraphBase&>(graph), value) { } \ |
143 : public From::template NodeMap<Value> { \ |
165 \ |
144 typedef typename From::template NodeMap<Value> MapImpl; \ |
166 NodeMap(const NodeMap& copy) \ |
145 public: \ |
167 : MapImpl(static_cast<const MapImpl&>(copy)) {} \ |
146 NodeMap() : MapImpl() {} \ |
168 \ |
147 \ |
169 template<typename CMap> \ |
148 NodeMap(const To& to) \ |
170 NodeMap(const CMap& copy) \ |
149 : MapImpl(static_cast<const From&>(from)) { } \ |
171 : MapImpl(copy) {} \ |
150 \ |
172 \ |
151 NodeMap(const To& to, const Value& value) \ |
173 NodeMap& operator=(const NodeMap& copy) { \ |
152 : MapImpl(static_cast<const From&>(from), value) { } \ |
174 MapImpl::operator=(static_cast<const MapImpl&>(copy)); \ |
153 \ |
175 return *this; \ |
154 NodeMap(const NodeMap& copy) \ |
176 } \ |
155 : MapImpl(static_cast<const MapImpl&>(copy)) {} \ |
177 \ |
156 \ |
178 template <typename CMap> \ |
157 template<typename CMap> \ |
179 NodeMap& operator=(const CMap& copy) { \ |
158 NodeMap(const CMap& copy) \ |
180 MapImpl::operator=(copy); \ |
159 : MapImpl(copy) {} \ |
181 return *this; \ |
160 \ |
182 } \ |
161 NodeMap& operator=(const NodeMap& copy) { \ |
183 }; |
162 MapImpl::operator=(static_cast<const MapImpl&>(copy)); \ |
184 |
163 return *this; \ |
185 #define KEEP_EDGE_MAP(GraphBase) \ |
164 } \ |
186 template <typename V> class EdgeMap \ |
165 \ |
187 : public GraphBase::template EdgeMap<V> \ |
166 template <typename CMap> \ |
188 { \ |
167 NodeMap& operator=(const CMap& copy) { \ |
189 typedef typename GraphBase::template EdgeMap<V> MapImpl; \ |
168 MapImpl::operator=(copy); \ |
190 typedef V Value; \ |
169 return *this; \ |
191 public: \ |
170 } \ |
192 EdgeMap() : MapImpl() {} \ |
171 }; |
193 \ |
172 |
194 EdgeMap(const Graph& graph) \ |
173 /** This is a macro to import an edge map into a graph class. |
195 : MapImpl(static_cast<const GraphBase&>(graph)) { } \ |
174 */ |
196 \ |
175 #define IMPORT_EDGE_MAP(From, from, To, to) \ |
197 EdgeMap(const Graph& graph, const Value& value) \ |
176 template <typename Value> \ |
198 : MapImpl(static_cast<const GraphBase&>(graph), value) { } \ |
177 class EdgeMap \ |
199 \ |
178 : public From::template EdgeMap<Value> { \ |
200 EdgeMap(const EdgeMap& copy) \ |
179 typedef typename From::template EdgeMap<Value> MapImpl; \ |
201 : MapImpl(static_cast<const MapImpl&>(copy)) {} \ |
180 public: \ |
202 \ |
181 EdgeMap() : MapImpl() {} \ |
203 template<typename CMap> \ |
182 \ |
204 EdgeMap(const CMap& copy) \ |
183 EdgeMap(const To& to) \ |
205 : MapImpl(copy) {} \ |
184 : MapImpl(static_cast<const From&>(from)) { } \ |
206 \ |
185 \ |
207 EdgeMap& operator=(const EdgeMap& copy) { \ |
186 EdgeMap(const To& to, const Value& value) \ |
208 MapImpl::operator=(static_cast<const MapImpl&>(copy)); \ |
187 : MapImpl(static_cast<const From&>(from), value) { } \ |
209 return *this; \ |
188 \ |
210 } \ |
189 EdgeMap(const EdgeMap& copy) \ |
211 \ |
190 : MapImpl(static_cast<const MapImpl&>(copy)) {} \ |
212 template <typename CMap> \ |
191 \ |
213 EdgeMap& operator=(const CMap& copy) { \ |
192 template<typename CMap> \ |
214 MapImpl::operator=(copy); \ |
193 EdgeMap(const CMap& copy) \ |
215 return *this; \ |
194 : MapImpl(copy) {} \ |
216 } \ |
195 \ |
217 }; |
196 EdgeMap& operator=(const EdgeMap& copy) { \ |
218 |
197 MapImpl::operator=(static_cast<const MapImpl&>(copy)); \ |
|
198 return *this; \ |
|
199 } \ |
|
200 \ |
|
201 template <typename CMap> \ |
|
202 EdgeMap& operator=(const CMap& copy) { \ |
|
203 MapImpl::operator=(copy); \ |
|
204 return *this; \ |
|
205 } \ |
|
206 }; |
|
207 |
|
208 |
|
209 /** This is a macro to keep the node and edge maps for a graph class. |
|
210 */ |
|
211 #define KEEP_MAPS(From, To) \ |
|
212 IMPORT_EDGE_MAP(From, graph, To, graph) \ |
|
213 IMPORT_NODE_MAP(From, graph, To, graph) |
219 |
214 |
220 /// @} |
215 /// @} |
221 |
216 |
222 #endif |
217 #endif |