Copyright header added.
2 * src/hugo/map_defines.h - Part of HUGOlib, a generic C++ optimization library
4 * Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
5 * (Egervary Combinatorial Optimization Research Group, EGRES).
7 * Permission to use, modify and distribute this software is granted
8 * provided that this copyright notice appears in all copies. For
9 * precise terms see the accompanying LICENSE file.
11 * This software is provided "AS IS" with no warranty of any kind,
12 * express or implied, and with no claim as to its suitability for any
17 #ifndef HUGO_MAP_DEFINES_H
18 #define HUGO_MAP_DEFINES_H
22 ///\brief Defines to help creating graph maps.
24 /// \addtogroup graphmapfactory
27 /** Creates the EdgeMapRegistry type an declare a mutable instance
30 #define CREATE_EDGE_MAP_REGISTRY \
31 typedef MapRegistry<Graph, Edge, EdgeIt> EdgeMapRegistry; \
32 mutable EdgeMapRegistry edge_maps;
34 /** Creates the NodeMapRegistry type an declare a mutable instance
37 #define CREATE_NODE_MAP_REGISTRY \
38 typedef MapRegistry<Graph, Node, NodeIt> NodeMapRegistry; \
39 mutable NodeMapRegistry node_maps;
41 /** Creates both map registries.
43 #define CREATE_MAP_REGISTRIES \
44 CREATE_NODE_MAP_REGISTRY \
45 CREATE_EDGE_MAP_REGISTRY
47 /** Creates a map from a template map. The import method is
48 * an overloading of the map type.
49 * The reason to use these macro is that the c++ does not support
50 * the template typedefs. If a future release of the c++
51 * supports this feature it should be fixed.
53 #define CREATE_NODE_MAP(DynMap) \
54 template <typename Value> \
55 class NodeMap : public DynMap<NodeMapRegistry, Value> { \
57 typedef DynMap<NodeMapRegistry, Value> Parent; \
58 NodeMap(const typename Parent::Graph& g) \
59 : Parent(g, g.node_maps) {} \
60 NodeMap(const typename Parent::Graph& g, const Value& v) \
61 : Parent(g, g.node_maps, v) {} \
62 NodeMap(const NodeMap& copy) : Parent(static_cast<const Parent&>(copy)) {} \
63 template <typename TT> \
64 NodeMap(const NodeMap<TT>& copy) \
65 : Parent(static_cast<const typename NodeMap<TT>::Parent&>(copy)) {} \
66 NodeMap& operator=(const NodeMap& copy) { \
67 Parent::operator=(static_cast<const Parent&>(copy));\
70 template <typename TT> \
71 NodeMap& operator=(const NodeMap<TT>& copy) { \
72 Parent::operator=(static_cast<const typename NodeMap<TT>::Parent&>(copy));\
77 /** Creates a map from a template map. The import method is
78 * an overloading of the map type.
79 * The reason to use these macro is that the c++ does not support
80 * the template typedefs. If a future release of the c++
81 * supports this feature it should be fixed.
83 #define CREATE_EDGE_MAP(DynMap) \
84 template <typename Value> \
85 class EdgeMap : public DynMap<EdgeMapRegistry, Value> { \
87 typedef DynMap<EdgeMapRegistry, Value> Parent; \
89 EdgeMap(const typename Parent::Graph& g) \
90 : Parent(g, g.edge_maps) {} \
91 EdgeMap(const typename Parent::Graph& g, const Value& v) \
92 : Parent(g, g.edge_maps, v) {} \
93 EdgeMap(const EdgeMap& copy) : Parent(static_cast<const Parent&>(copy)) {} \
94 template <typename TT> \
95 EdgeMap(const EdgeMap<TT>& copy) \
96 : Parent(static_cast<const typename EdgeMap<TT>::Parent&>(copy)) {} \
97 EdgeMap& operator=(const EdgeMap& copy) { \
98 Parent::operator=(static_cast<const Parent&>(copy));\
101 template <typename TT> \
102 EdgeMap& operator=(const EdgeMap<TT>& copy) { \
103 Parent::operator=(static_cast<const typename EdgeMap<TT>::Parent&>(copy));\
108 /** This macro creates both maps.
110 #define CREATE_MAPS(DynMap) \
111 CREATE_NODE_MAP(DynMap) \
112 CREATE_EDGE_MAP(DynMap)
114 /** This macro creates MapRegistry for Symmetric Edge Maps.
116 #define CREATE_SYM_EDGE_MAP_REGISTRY \
117 typedef SymEdgeIt<Graph, Edge, EdgeIt> SymEdgeIt; \
118 typedef MapRegistry<Graph, Edge, SymEdgeIt> SymEdgeMapRegistry; \
119 mutable SymEdgeMapRegistry sym_edge_maps;
122 /** Creates a map from a template map. The import method is
123 * an overloading of the map type.
124 * The reason to use these macro is that the c++ does not support
125 * the template typedefs. If a future release of the c++
126 * supports this feature it should be fixed.
128 #define CREATE_SYM_EDGE_MAP(DynMap) \
129 template <typename Value> \
130 class SymEdgeMap : public SymMap<DynMap, SymEdgeMapRegistry, Value> { \
132 typedef SymMap<DynMap, SymEdgeMapRegistry, Value> Parent; \
134 SymEdgeMap(const typename Parent::Graph& g) \
135 : Parent(g, g.sym_edge_maps) {} \
136 SymEdgeMap(const typename Parent::Graph& g, const Value& v) \
137 : Parent(g, g.sym_edge_maps, v) {} \
138 SymEdgeMap(const SymEdgeMap& copy) \
139 : Parent(static_cast<const Parent&>(copy)) {} \
140 template <typename TT> \
141 SymEdgeMap(const NodeMap<TT>& copy) \
142 : Parent(static_cast<const typename SymEdgeMap<TT>::Parent&>(copy)) {} \
143 SymEdgeMap& operator=(const SymEdgeMap& copy) { \
144 Parent::operator=(static_cast<const Parent&>(copy));\
147 template <typename TT> \
148 SymEdgeMap& operator=(const SymEdgeMap<TT>& copy) { \
149 Parent::operator=(static_cast<const typename SymEdgeMap<TT>::Parent&>(copy));\
154 /** This is a macro to import an node map into a graph class.
156 #define IMPORT_NODE_MAP(From, from, To, to) \
157 template <typename Value> \
158 class NodeMap : public From::template NodeMap<Value> { \
161 typedef typename From::template NodeMap<Value> Parent; \
163 NodeMap(const To& to) \
164 : Parent(static_cast<const From&>(from)) { } \
165 NodeMap(const To& to, const Value& value) \
166 : Parent(static_cast<const From&>(from), value) { } \
167 NodeMap(const NodeMap& copy) \
168 : Parent(static_cast<const Parent&>(copy)) {} \
169 template <typename TT> \
170 NodeMap(const NodeMap<TT>& copy) \
171 : Parent(static_cast<const typename NodeMap<TT>::Parent&>(copy)) {} \
172 NodeMap& operator=(const NodeMap& copy) { \
173 Parent::operator=(static_cast<const Parent&>(copy)); \
176 template <typename TT> \
177 NodeMap& operator=(const NodeMap<TT>& copy) { \
178 Parent::operator=(static_cast<const typename NodeMap<TT>::Parent&>(copy));\
183 /** This is a macro to import an edge map into a graph class.
185 #define IMPORT_EDGE_MAP(From, from, To, to) \
186 template <typename Value> \
187 class EdgeMap : public From::template EdgeMap<Value> { \
190 typedef typename From::template EdgeMap<Value> Parent; \
192 EdgeMap(const To& to) \
193 : Parent(static_cast<const From&>(from)) { } \
194 EdgeMap(const To& to, const Value& value) \
195 : Parent(static_cast<const From&>(from), value) { } \
196 EdgeMap(const EdgeMap& copy) \
197 : Parent(static_cast<const Parent&>(copy)) {} \
198 template <typename TT> \
199 EdgeMap(const EdgeMap<TT>& copy) \
200 : Parent(static_cast<const typename EdgeMap<TT>::Parent&>(copy)) {} \
201 EdgeMap& operator=(const EdgeMap& copy) { \
202 Parent::operator=(static_cast<const Parent&>(copy)); \
205 template <typename TT> \
206 EdgeMap& operator=(const EdgeMap<TT>& copy) { \
207 Parent::operator=(static_cast<const typename EdgeMap<TT>::Parent&>(copy));\
212 #define KEEP_EDGE_MAP(From, To) \
213 IMPORT_EDGE_MAP(From, graph, To, graph)
216 #define KEEP_NODE_MAP(From, To) \
217 IMPORT_NODE_MAP(From, graph, To, graph)
219 /** This is a macro to keep the node and edge maps for a graph class.
221 #define KEEP_MAPS(From, To) \
222 KEEP_EDGE_MAP(From, To) \
223 KEEP_NODE_MAP(From, To)