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