COIN-OR::LEMON - Graph Library

source: lemon-0.x/src/hugo/map_defines.h @ 901:69a8e672acb1

Last change on this file since 901:69a8e672acb1 was 901:69a8e672acb1, checked in by marci, 20 years ago

correction of HUGO_... preproc defines.

File size: 6.7 KB
Line 
1// -*- c++ -*-
2#ifndef HUGO_MAP_DEFINES_H
3#define HUGO_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(const typename Parent::Graph& g) \
44  : Parent(g, g.node_maps) {} \
45NodeMap(const typename Parent::Graph& g, const Value& v) \
46  : Parent(g, g.node_maps, v) {} \
47NodeMap(const NodeMap& copy) : Parent(static_cast<const Parent&>(copy)) {} \
48template <typename TT> \
49NodeMap(const NodeMap<TT>& copy) \
50  : Parent(static_cast<const typename NodeMap<TT>::Parent&>(copy)) {} \
51NodeMap& operator=(const NodeMap& copy) { \
52  Parent::operator=(static_cast<const Parent&>(copy));\
53  return *this; \
54} \
55template <typename TT> \
56NodeMap& operator=(const NodeMap<TT>& copy) { \
57  Parent::operator=(static_cast<const typename NodeMap<TT>::Parent&>(copy));\
58  return *this; \
59} \
60};
61
62/** Creates a map from a template map. The import method is
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 */
68#define CREATE_EDGE_MAP(DynMap) \
69template <typename Value> \
70class EdgeMap : public DynMap<EdgeMapRegistry, Value> { \
71public: \
72typedef DynMap<EdgeMapRegistry, Value> Parent; \
73\
74EdgeMap(const typename Parent::Graph& g) \
75  : Parent(g, g.edge_maps) {} \
76EdgeMap(const typename Parent::Graph& g, const Value& v) \
77  : Parent(g, g.edge_maps, v) {} \
78EdgeMap(const EdgeMap& copy) : Parent(static_cast<const Parent&>(copy)) {} \
79template <typename TT> \
80EdgeMap(const EdgeMap<TT>& copy) \
81  : Parent(static_cast<const typename EdgeMap<TT>::Parent&>(copy)) {} \
82EdgeMap& operator=(const EdgeMap& copy) { \
83  Parent::operator=(static_cast<const Parent&>(copy));\
84  return *this; \
85} \
86template <typename TT> \
87EdgeMap& operator=(const EdgeMap<TT>& copy) { \
88  Parent::operator=(static_cast<const typename EdgeMap<TT>::Parent&>(copy));\
89  return *this; \
90} \
91};
92
93/** This macro creates both maps.
94 */
95#define CREATE_MAPS(DynMap) \
96CREATE_NODE_MAP(DynMap) \
97CREATE_EDGE_MAP(DynMap)
98
99/** This macro creates MapRegistry for Symmetric Edge Maps.
100 */
101#define CREATE_SYM_EDGE_MAP_REGISTRY \
102typedef SymEdgeIt<Graph, Edge, EdgeIt> SymEdgeIt; \
103typedef MapRegistry<Graph, Edge, SymEdgeIt> SymEdgeMapRegistry; \
104mutable SymEdgeMapRegistry sym_edge_maps;
105
106
107/** Creates a map from a template map. The import method is
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 */
113#define CREATE_SYM_EDGE_MAP(DynMap) \
114template <typename Value> \
115class SymEdgeMap : public SymMap<DynMap, SymEdgeMapRegistry, Value> { \
116public: \
117typedef SymMap<DynMap, SymEdgeMapRegistry, Value> Parent; \
118\
119SymEdgeMap(const typename Parent::Graph& g) \
120  : Parent(g, g.sym_edge_maps) {} \
121SymEdgeMap(const typename Parent::Graph& g, const Value& v) \
122  : Parent(g, g.sym_edge_maps, v) {} \
123SymEdgeMap(const SymEdgeMap& copy) \
124  : Parent(static_cast<const Parent&>(copy)) {} \
125template <typename TT> \
126SymEdgeMap(const NodeMap<TT>& copy) \
127  : Parent(static_cast<const typename SymEdgeMap<TT>::Parent&>(copy)) {} \
128SymEdgeMap& operator=(const SymEdgeMap& copy) { \
129  Parent::operator=(static_cast<const Parent&>(copy));\
130  return *this; \
131} \
132template <typename TT> \
133SymEdgeMap& operator=(const SymEdgeMap<TT>& copy) { \
134  Parent::operator=(static_cast<const typename SymEdgeMap<TT>::Parent&>(copy));\
135  return *this; \
136} \
137};
138
139/** This is a macro to import an node map into a graph class.
140 */
141#define IMPORT_NODE_MAP(From, from, To, to) \
142template <typename Value> \
143class NodeMap : public From::template NodeMap<Value> { \
144\
145public: \
146typedef typename From::template NodeMap<Value> Parent; \
147\
148NodeMap(const To& to) \
149  : Parent(static_cast<const From&>(from)) { } \
150NodeMap(const To& to, const Value& value) \
151  : Parent(static_cast<const From&>(from), value) { } \
152NodeMap(const NodeMap& copy) \
153  : Parent(static_cast<const Parent&>(copy)) {} \
154template <typename TT> \
155NodeMap(const NodeMap<TT>& copy) \
156  : Parent(static_cast<const typename NodeMap<TT>::Parent&>(copy)) {} \
157NodeMap& operator=(const NodeMap& copy) { \
158  Parent::operator=(static_cast<const Parent&>(copy)); \
159  return *this; \
160} \
161template <typename TT> \
162NodeMap& operator=(const NodeMap<TT>& copy) { \
163  Parent::operator=(static_cast<const typename NodeMap<TT>::Parent&>(copy));\
164  return *this; \
165} \
166};
167
168/** This is a macro to import an edge map into a graph class.
169 */
170#define IMPORT_EDGE_MAP(From, from, To, to) \
171template <typename Value> \
172class EdgeMap : public From::template EdgeMap<Value> { \
173\
174public: \
175typedef typename From::template EdgeMap<Value> Parent; \
176\
177EdgeMap(const To& to) \
178  : Parent(static_cast<const From&>(from)) { } \
179EdgeMap(const To& to, const Value& value) \
180  : Parent(static_cast<const From&>(from), value) { } \
181EdgeMap(const EdgeMap& copy) \
182  : Parent(static_cast<const Parent&>(copy)) {} \
183template <typename TT> \
184EdgeMap(const EdgeMap<TT>& copy) \
185  : Parent(static_cast<const typename EdgeMap<TT>::Parent&>(copy)) {} \
186EdgeMap& operator=(const EdgeMap& copy) { \
187  Parent::operator=(static_cast<const Parent&>(copy)); \
188  return *this; \
189} \
190template <typename TT> \
191EdgeMap& operator=(const EdgeMap<TT>& copy) { \
192  Parent::operator=(static_cast<const typename EdgeMap<TT>::Parent&>(copy));\
193  return *this; \
194} \
195};
196
197#define KEEP_EDGE_MAP(From, To) \
198IMPORT_EDGE_MAP(From, graph, To, graph)
199
200
201#define KEEP_NODE_MAP(From, To) \
202IMPORT_NODE_MAP(From, graph, To, graph)
203
204/** This is a macro to keep the node and edge maps for a graph class.
205 */
206#define KEEP_MAPS(From, To) \
207KEEP_EDGE_MAP(From, To) \
208KEEP_NODE_MAP(From, To)
209
210 
211/// @}
212 
213#endif
Note: See TracBrowser for help on using the repository browser.