1 // -*- c++ -*- |
1 // -*- c++ -*- |
2 #ifndef MAP_DEFINES_H |
2 #ifndef MAP_DEFINES_H |
3 #define MAP_DEFINES_H |
3 #define MAP_DEFINES_H |
4 |
4 |
|
5 /** Creates the EdgeMapRegistry type an declare a mutable instance |
|
6 * named edge_maps. |
|
7 */ |
5 #define CREATE_EDGE_MAP_REGISTRY \ |
8 #define CREATE_EDGE_MAP_REGISTRY \ |
6 typedef MapRegistry<Graph, Edge, EdgeIt> EdgeMapRegistry; \ |
9 typedef MapRegistry<Graph, Edge, EdgeIt> EdgeMapRegistry; \ |
7 EdgeMapRegistry edge_maps; |
10 mutable EdgeMapRegistry edge_maps; |
8 |
11 |
|
12 /** Creates the NodeMapRegistry type an declare a mutable instance |
|
13 * named node_maps. |
|
14 */ |
9 #define CREATE_NODE_MAP_REGISTRY \ |
15 #define CREATE_NODE_MAP_REGISTRY \ |
10 typedef MapRegistry<Graph, Node, NodeIt> NodeMapRegistry; \ |
16 typedef MapRegistry<Graph, Node, NodeIt> NodeMapRegistry; \ |
11 NodeMapRegistry node_maps; |
17 mutable NodeMapRegistry node_maps; |
12 |
18 |
|
19 /** Creates both map registries. |
|
20 */ |
13 #define CREATE_MAP_REGISTRIES \ |
21 #define CREATE_MAP_REGISTRIES \ |
14 CREATE_NODE_MAP_REGISTRY \ |
22 CREATE_NODE_MAP_REGISTRY \ |
15 CREATE_EDGE_MAP_REGISTRY |
23 CREATE_EDGE_MAP_REGISTRY |
16 |
24 |
|
25 /** Creates a map a concrete factory type from a template map |
|
26 * factory to use as node map factory. |
|
27 */ |
17 #define CREATE_NODE_MAP_FACTORY(TemplateFactory) \ |
28 #define CREATE_NODE_MAP_FACTORY(TemplateFactory) \ |
18 typedef TemplateFactory<NodeMapRegistry> NodeMapFactory; |
29 typedef TemplateFactory<NodeMapRegistry> NodeMapFactory; |
19 |
30 |
|
31 /** Creates a map a concrete factory type from a template map |
|
32 * factory to use as edge map factory. |
|
33 */ |
20 #define CREATE_EDGE_MAP_FACTORY(TemplateFactory) \ |
34 #define CREATE_EDGE_MAP_FACTORY(TemplateFactory) \ |
21 typedef TemplateFactory<EdgeMapRegistry> EdgeMapFactory; |
35 typedef TemplateFactory<EdgeMapRegistry> EdgeMapFactory; |
22 |
36 |
|
37 /** Creates both map factories. |
|
38 */ |
23 #define CREATE_MAP_FACTORIES(TemplateFactory) \ |
39 #define CREATE_MAP_FACTORIES(TemplateFactory) \ |
24 CREATE_NODE_MAP_FACTORY(TemplateFactory) \ |
40 CREATE_NODE_MAP_FACTORY(TemplateFactory) \ |
25 CREATE_EDGE_MAP_FACTORY(TemplateFactory) |
41 CREATE_EDGE_MAP_FACTORY(TemplateFactory) |
26 |
42 |
|
43 /** Import a map from a concrete map factory. The import method is |
|
44 * an overloading of the map type. |
|
45 * The reason to use these macro is that the c++ does not support |
|
46 * the template typedefs. If a future release of the c++ |
|
47 * supports this feature it should be fixed. |
|
48 */ |
27 #define IMPORT_NODE_MAP(Factory) \ |
49 #define IMPORT_NODE_MAP(Factory) \ |
28 template <typename V> \ |
50 template <typename V> \ |
29 class NodeMap : public Factory::Map<V> { \ |
51 class NodeMap : public Factory::Map<V> { \ |
30 public: \ |
52 public: \ |
31 NodeMap() {} \ |
53 NodeMap() {} \ |
32 NodeMap(Graph& g) : Factory::Map<V>(g, g.node_maps) {} \ |
54 NodeMap(const Graph& g) : Factory::Map<V>(&g, &(g.node_maps)) {} \ |
|
55 NodeMap(const Graph& g, const V& v) : Factory::Map<V>(g, g.node_maps, v) {} \ |
|
56 NodeMap(const NodeMap& copy) : Factory::Map<V>(copy) {} \ |
|
57 template <typename CMap> NodeMap(const CMap& copy) : Factory::Map<V>(copy) {} \ |
|
58 NodeMap& operator=(const NodeMap& copy) { \ |
|
59 this->Factory::Map<V>::operator=(copy); \ |
|
60 return *this; \ |
|
61 } \ |
|
62 template <typename CMap>NodeMap& operator=(const CMap& copy) { \ |
|
63 this->Factory::Map<V>::operator=<CMap>(copy); \ |
|
64 return *this; \ |
|
65 } \ |
33 }; |
66 }; |
34 |
67 |
|
68 /** Import a map from a concrete map factory. The import method is |
|
69 * an overloading of the map type. |
|
70 * The reason to use these macro is that the c++ does not support |
|
71 * the template typedefs. If a future release of the c++ |
|
72 * supports this feature it should be fixed. |
|
73 */ |
35 #define IMPORT_EDGE_MAP(Factory) \ |
74 #define IMPORT_EDGE_MAP(Factory) \ |
36 template <typename V> \ |
75 template <typename V> \ |
37 class EdgeMap : public Factory::Map<V> { \ |
76 class EdgeMap : public Factory::Map<V> { \ |
38 public: \ |
77 public: \ |
39 EdgeMap() {} \ |
78 EdgeMap() {} \ |
40 EdgeMap(Graph& g) : Factory::Map<V>(g, g.edge_maps) {} \ |
79 EdgeMap(const Graph& g) : Factory::Map<V>(g, g.edge_maps) {} \ |
|
80 EdgeMap(const Graph& g, const V& v) : Factory::Map<V>(g, g.node_maps, v) {} \ |
|
81 EdgeMap(const EdgeMap& copy) : Factory::Map<V>(copy) {} \ |
|
82 template <typename CMap> EdgeMap(const CMap& copy) : Factory::Map<V>(copy) {} \ |
|
83 EdgeMap& operator=(const EdgeMap& copy) { \ |
|
84 this->Factory::Map<V>::operator=(copy); \ |
|
85 return *this; \ |
|
86 } \ |
|
87 template <typename CMap>EdgeMap& operator=(const CMap& copy) { \ |
|
88 this->Factory::Map<V>::operator=<CMap>(copy); \ |
|
89 return *this; \ |
|
90 } \ |
41 }; |
91 }; |
42 |
92 |
|
93 /** This macro creates both map factories and imports both maps. |
|
94 */ |
43 #define CREATE_MAPS(TemplateFactory) \ |
95 #define CREATE_MAPS(TemplateFactory) \ |
44 CREATE_MAP_FACTORIES(TemplateFactory) \ |
96 CREATE_MAP_FACTORIES(TemplateFactory) \ |
45 IMPORT_NODE_MAP(NodeMapFactory) \ |
97 IMPORT_NODE_MAP(NodeMapFactory) \ |
46 IMPORT_EDGE_MAP(EdgeMapFactory) |
98 IMPORT_EDGE_MAP(EdgeMapFactory) |
47 |
99 |