COIN-OR::LEMON - Graph Library

source: lemon-0.x/src/hugo/map_defines.h @ 892:004636791dd7

Last change on this file since 892:004636791dd7 was 891:74589d20dbc3, checked in by Balazs Dezso, 20 years ago

template<typename CMap> Map(const CMap&) like constructors and
assigns are removed.

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