[782] | 1 | // -*- c++ -*- |
---|
[901] | 2 | #ifndef HUGO_MAP_DEFINES_H |
---|
| 3 | #define HUGO_MAP_DEFINES_H |
---|
[782] | 4 | |
---|
[822] | 5 | ///\ingroup graphmaps |
---|
[785] | 6 | ///\file |
---|
| 7 | ///\brief Defines to help creating graph maps. |
---|
| 8 | |
---|
| 9 | /// \addtogroup graphmapfactory |
---|
| 10 | /// @{ |
---|
| 11 | |
---|
[782] | 12 | /** Creates the EdgeMapRegistry type an declare a mutable instance |
---|
| 13 | * named edge_maps. |
---|
| 14 | */ |
---|
| 15 | #define CREATE_EDGE_MAP_REGISTRY \ |
---|
| 16 | typedef MapRegistry<Graph, Edge, EdgeIt> EdgeMapRegistry; \ |
---|
| 17 | mutable EdgeMapRegistry edge_maps; |
---|
| 18 | |
---|
| 19 | /** Creates the NodeMapRegistry type an declare a mutable instance |
---|
| 20 | * named node_maps. |
---|
| 21 | */ |
---|
| 22 | #define CREATE_NODE_MAP_REGISTRY \ |
---|
| 23 | typedef MapRegistry<Graph, Node, NodeIt> NodeMapRegistry; \ |
---|
| 24 | mutable NodeMapRegistry node_maps; |
---|
| 25 | |
---|
| 26 | /** Creates both map registries. |
---|
| 27 | */ |
---|
| 28 | #define CREATE_MAP_REGISTRIES \ |
---|
| 29 | CREATE_NODE_MAP_REGISTRY \ |
---|
| 30 | CREATE_EDGE_MAP_REGISTRY |
---|
| 31 | |
---|
[822] | 32 | /** Creates a map from a template map. The import method is |
---|
[782] | 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. |
---|
| 37 | */ |
---|
[822] | 38 | #define CREATE_NODE_MAP(DynMap) \ |
---|
| 39 | template <typename Value> \ |
---|
| 40 | class NodeMap : public DynMap<NodeMapRegistry, Value> { \ |
---|
[782] | 41 | public: \ |
---|
[891] | 42 | typedef DynMap<NodeMapRegistry, Value> Parent; \ |
---|
| 43 | NodeMap(const typename Parent::Graph& g) \ |
---|
| 44 | : Parent(g, g.node_maps) {} \ |
---|
| 45 | NodeMap(const typename Parent::Graph& g, const Value& v) \ |
---|
| 46 | : Parent(g, g.node_maps, v) {} \ |
---|
| 47 | NodeMap(const NodeMap& copy) : Parent(static_cast<const Parent&>(copy)) {} \ |
---|
| 48 | template <typename TT> \ |
---|
| 49 | NodeMap(const NodeMap<TT>& copy) \ |
---|
| 50 | : Parent(static_cast<const typename NodeMap<TT>::Parent&>(copy)) {} \ |
---|
[782] | 51 | NodeMap& operator=(const NodeMap& copy) { \ |
---|
[891] | 52 | Parent::operator=(static_cast<const Parent&>(copy));\ |
---|
[782] | 53 | return *this; \ |
---|
| 54 | } \ |
---|
[891] | 55 | template <typename TT> \ |
---|
| 56 | NodeMap& operator=(const NodeMap<TT>& copy) { \ |
---|
| 57 | Parent::operator=(static_cast<const typename NodeMap<TT>::Parent&>(copy));\ |
---|
[782] | 58 | return *this; \ |
---|
| 59 | } \ |
---|
| 60 | }; |
---|
| 61 | |
---|
[822] | 62 | /** Creates a map from a template map. The import method is |
---|
[782] | 63 | * an overloading of the map type. |
---|
| 64 | * The reason to use these macro is that the c++ does not support |
---|
| 65 | * the template typedefs. If a future release of the c++ |
---|
| 66 | * supports this feature it should be fixed. |
---|
| 67 | */ |
---|
[822] | 68 | #define CREATE_EDGE_MAP(DynMap) \ |
---|
| 69 | template <typename Value> \ |
---|
| 70 | class EdgeMap : public DynMap<EdgeMapRegistry, Value> { \ |
---|
[782] | 71 | public: \ |
---|
[891] | 72 | typedef DynMap<EdgeMapRegistry, Value> Parent; \ |
---|
| 73 | \ |
---|
| 74 | EdgeMap(const typename Parent::Graph& g) \ |
---|
| 75 | : Parent(g, g.edge_maps) {} \ |
---|
| 76 | EdgeMap(const typename Parent::Graph& g, const Value& v) \ |
---|
| 77 | : Parent(g, g.edge_maps, v) {} \ |
---|
| 78 | EdgeMap(const EdgeMap& copy) : Parent(static_cast<const Parent&>(copy)) {} \ |
---|
| 79 | template <typename TT> \ |
---|
| 80 | EdgeMap(const EdgeMap<TT>& copy) \ |
---|
| 81 | : Parent(static_cast<const typename EdgeMap<TT>::Parent&>(copy)) {} \ |
---|
[782] | 82 | EdgeMap& operator=(const EdgeMap& copy) { \ |
---|
[891] | 83 | Parent::operator=(static_cast<const Parent&>(copy));\ |
---|
[782] | 84 | return *this; \ |
---|
| 85 | } \ |
---|
[891] | 86 | template <typename TT> \ |
---|
| 87 | EdgeMap& operator=(const EdgeMap<TT>& copy) { \ |
---|
| 88 | Parent::operator=(static_cast<const typename EdgeMap<TT>::Parent&>(copy));\ |
---|
[782] | 89 | return *this; \ |
---|
| 90 | } \ |
---|
| 91 | }; |
---|
| 92 | |
---|
[822] | 93 | /** This macro creates both maps. |
---|
[782] | 94 | */ |
---|
[822] | 95 | #define CREATE_MAPS(DynMap) \ |
---|
| 96 | CREATE_NODE_MAP(DynMap) \ |
---|
| 97 | CREATE_EDGE_MAP(DynMap) |
---|
[782] | 98 | |
---|
| 99 | /** This macro creates MapRegistry for Symmetric Edge Maps. |
---|
| 100 | */ |
---|
| 101 | #define CREATE_SYM_EDGE_MAP_REGISTRY \ |
---|
| 102 | typedef SymEdgeIt<Graph, Edge, EdgeIt> SymEdgeIt; \ |
---|
| 103 | typedef MapRegistry<Graph, Edge, SymEdgeIt> SymEdgeMapRegistry; \ |
---|
[844] | 104 | mutable SymEdgeMapRegistry sym_edge_maps; |
---|
[782] | 105 | |
---|
| 106 | |
---|
[822] | 107 | /** Creates a map from a template map. The import method is |
---|
[782] | 108 | * an overloading of the map type. |
---|
| 109 | * The reason to use these macro is that the c++ does not support |
---|
| 110 | * the template typedefs. If a future release of the c++ |
---|
| 111 | * supports this feature it should be fixed. |
---|
| 112 | */ |
---|
[822] | 113 | #define CREATE_SYM_EDGE_MAP(DynMap) \ |
---|
| 114 | template <typename Value> \ |
---|
| 115 | class SymEdgeMap : public SymMap<DynMap, SymEdgeMapRegistry, Value> { \ |
---|
[891] | 116 | public: \ |
---|
| 117 | typedef SymMap<DynMap, SymEdgeMapRegistry, Value> Parent; \ |
---|
[822] | 118 | \ |
---|
[891] | 119 | SymEdgeMap(const typename Parent::Graph& g) \ |
---|
| 120 | : Parent(g, g.sym_edge_maps) {} \ |
---|
| 121 | SymEdgeMap(const typename Parent::Graph& g, const Value& v) \ |
---|
| 122 | : Parent(g, g.sym_edge_maps, v) {} \ |
---|
| 123 | SymEdgeMap(const SymEdgeMap& copy) \ |
---|
| 124 | : Parent(static_cast<const Parent&>(copy)) {} \ |
---|
| 125 | template <typename TT> \ |
---|
| 126 | SymEdgeMap(const NodeMap<TT>& copy) \ |
---|
| 127 | : Parent(static_cast<const typename SymEdgeMap<TT>::Parent&>(copy)) {} \ |
---|
| 128 | SymEdgeMap& operator=(const SymEdgeMap& copy) { \ |
---|
| 129 | Parent::operator=(static_cast<const Parent&>(copy));\ |
---|
| 130 | return *this; \ |
---|
| 131 | } \ |
---|
| 132 | template <typename TT> \ |
---|
| 133 | SymEdgeMap& operator=(const SymEdgeMap<TT>& copy) { \ |
---|
| 134 | Parent::operator=(static_cast<const typename SymEdgeMap<TT>::Parent&>(copy));\ |
---|
| 135 | return *this; \ |
---|
| 136 | } \ |
---|
[782] | 137 | }; |
---|
| 138 | |
---|
[822] | 139 | /** This is a macro to import an node map into a graph class. |
---|
| 140 | */ |
---|
| 141 | #define IMPORT_NODE_MAP(From, from, To, to) \ |
---|
| 142 | template <typename Value> \ |
---|
[891] | 143 | class NodeMap : public From::template NodeMap<Value> { \ |
---|
[782] | 144 | \ |
---|
[891] | 145 | public: \ |
---|
| 146 | typedef typename From::template NodeMap<Value> Parent; \ |
---|
[782] | 147 | \ |
---|
[891] | 148 | NodeMap(const To& to) \ |
---|
| 149 | : Parent(static_cast<const From&>(from)) { } \ |
---|
| 150 | NodeMap(const To& to, const Value& value) \ |
---|
| 151 | : Parent(static_cast<const From&>(from), value) { } \ |
---|
| 152 | NodeMap(const NodeMap& copy) \ |
---|
| 153 | : Parent(static_cast<const Parent&>(copy)) {} \ |
---|
| 154 | template <typename TT> \ |
---|
| 155 | NodeMap(const NodeMap<TT>& copy) \ |
---|
| 156 | : Parent(static_cast<const typename NodeMap<TT>::Parent&>(copy)) {} \ |
---|
| 157 | NodeMap& operator=(const NodeMap& copy) { \ |
---|
| 158 | Parent::operator=(static_cast<const Parent&>(copy)); \ |
---|
| 159 | return *this; \ |
---|
| 160 | } \ |
---|
| 161 | template <typename TT> \ |
---|
| 162 | NodeMap& operator=(const NodeMap<TT>& copy) { \ |
---|
| 163 | Parent::operator=(static_cast<const typename NodeMap<TT>::Parent&>(copy));\ |
---|
| 164 | return *this; \ |
---|
| 165 | } \ |
---|
[822] | 166 | }; |
---|
[782] | 167 | |
---|
[822] | 168 | /** This is a macro to import an edge map into a graph class. |
---|
| 169 | */ |
---|
| 170 | #define IMPORT_EDGE_MAP(From, from, To, to) \ |
---|
| 171 | template <typename Value> \ |
---|
[891] | 172 | class EdgeMap : public From::template EdgeMap<Value> { \ |
---|
[782] | 173 | \ |
---|
[891] | 174 | public: \ |
---|
| 175 | typedef typename From::template EdgeMap<Value> Parent; \ |
---|
[782] | 176 | \ |
---|
[891] | 177 | EdgeMap(const To& to) \ |
---|
| 178 | : Parent(static_cast<const From&>(from)) { } \ |
---|
| 179 | EdgeMap(const To& to, const Value& value) \ |
---|
| 180 | : Parent(static_cast<const From&>(from), value) { } \ |
---|
| 181 | EdgeMap(const EdgeMap& copy) \ |
---|
| 182 | : Parent(static_cast<const Parent&>(copy)) {} \ |
---|
| 183 | template <typename TT> \ |
---|
| 184 | EdgeMap(const EdgeMap<TT>& copy) \ |
---|
| 185 | : Parent(static_cast<const typename EdgeMap<TT>::Parent&>(copy)) {} \ |
---|
| 186 | EdgeMap& operator=(const EdgeMap& copy) { \ |
---|
| 187 | Parent::operator=(static_cast<const Parent&>(copy)); \ |
---|
| 188 | return *this; \ |
---|
| 189 | } \ |
---|
| 190 | template <typename TT> \ |
---|
| 191 | EdgeMap& operator=(const EdgeMap<TT>& copy) { \ |
---|
| 192 | Parent::operator=(static_cast<const typename EdgeMap<TT>::Parent&>(copy));\ |
---|
| 193 | return *this; \ |
---|
| 194 | } \ |
---|
[822] | 195 | }; |
---|
[782] | 196 | |
---|
[877] | 197 | #define KEEP_EDGE_MAP(From, To) \ |
---|
| 198 | IMPORT_EDGE_MAP(From, graph, To, graph) |
---|
| 199 | |
---|
| 200 | |
---|
| 201 | #define KEEP_NODE_MAP(From, To) \ |
---|
| 202 | IMPORT_NODE_MAP(From, graph, To, graph) |
---|
[822] | 203 | |
---|
| 204 | /** This is a macro to keep the node and edge maps for a graph class. |
---|
| 205 | */ |
---|
| 206 | #define KEEP_MAPS(From, To) \ |
---|
[877] | 207 | KEEP_EDGE_MAP(From, To) \ |
---|
| 208 | KEEP_NODE_MAP(From, To) |
---|
| 209 | |
---|
[785] | 210 | |
---|
| 211 | /// @} |
---|
| 212 | |
---|
[782] | 213 | #endif |
---|