COIN-OR::LEMON - Graph Library

source: lemon-0.x/src/hugo/map_defines.h @ 782:df2e45e09652

Last change on this file since 782:df2e45e09652 was 782:df2e45e09652, checked in by Balazs Dezso, 20 years ago

--This line, and those below, will be ignored--

A hugo/sym_map_factory.h
M hugo/list_graph.h
A hugo/array_map_factory.h
A hugo/map_registry.h
M hugo/smart_graph.h
A hugo/map_defines.h
A hugo/extended_pair.h
M hugo/full_graph.h
A hugo/vector_map_factory.h

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