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
RevLine 
[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 \
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
[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) \
39template <typename Value> \
40class NodeMap : public DynMap<NodeMapRegistry, Value> { \
[782]41public: \
[891]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)) {} \
[782]51NodeMap& operator=(const NodeMap& copy) { \
[891]52  Parent::operator=(static_cast<const Parent&>(copy));\
[782]53  return *this; \
54} \
[891]55template <typename TT> \
56NodeMap& 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) \
69template <typename Value> \
70class EdgeMap : public DynMap<EdgeMapRegistry, Value> { \
[782]71public: \
[891]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)) {} \
[782]82EdgeMap& operator=(const EdgeMap& copy) { \
[891]83  Parent::operator=(static_cast<const Parent&>(copy));\
[782]84  return *this; \
85} \
[891]86template <typename TT> \
87EdgeMap& 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) \
96CREATE_NODE_MAP(DynMap) \
97CREATE_EDGE_MAP(DynMap)
[782]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; \
[844]104mutable 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) \
114template <typename Value> \
115class SymEdgeMap : public SymMap<DynMap, SymEdgeMapRegistry, Value> { \
[891]116public: \
117typedef SymMap<DynMap, SymEdgeMapRegistry, Value> Parent; \
[822]118\
[891]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} \
[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) \
142template <typename Value> \
[891]143class NodeMap : public From::template NodeMap<Value> { \
[782]144\
[891]145public: \
146typedef typename From::template NodeMap<Value> Parent; \
[782]147\
[891]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} \
[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) \
171template <typename Value> \
[891]172class EdgeMap : public From::template EdgeMap<Value> { \
[782]173\
[891]174public: \
175typedef typename From::template EdgeMap<Value> Parent; \
[782]176\
[891]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} \
[822]195};
[782]196
[877]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)
[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]207KEEP_EDGE_MAP(From, To) \
208KEEP_NODE_MAP(From, To)
209
[785]210 
211/// @}
212 
[782]213#endif
Note: See TracBrowser for help on using the repository browser.