COIN-OR::LEMON - Graph Library

source: lemon-0.x/src/work/deba/map_defines.h @ 701:c03e073b8394

Last change on this file since 701:c03e073b8394 was 701:c03e073b8394, checked in by Balazs Dezso, 20 years ago
File size: 3.2 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 map 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 map 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::Map<V> { \
52public: \
53NodeMap() {} \
54NodeMap(const Graph& g) : Factory::Map<V>(&g, &(g.node_maps)) {} \
55NodeMap(const Graph& g, const V& v) : Factory::Map<V>(g, g.node_maps, v) {} \
56NodeMap(const NodeMap& copy) : Factory::Map<V>(copy) {} \
57template <typename CMap> NodeMap(const CMap& copy) : Factory::Map<V>(copy) {} \
58NodeMap& operator=(const NodeMap& copy) { \
59  this->Factory::Map<V>::operator=(copy); \
60  return *this; \
61} \
62template <typename CMap>NodeMap& operator=(const CMap& copy) { \
63  this->Factory::Map<V>::operator=<CMap>(copy); \
64  return *this; \
65} \
66};
67
68/** Import a map from a concrete map factory. The import method is
69 *  an overloading of the map type.
70 *  The reason to use these macro is that the c++ does not support
71 *  the template typedefs. If a future release of the c++
72 *  supports this feature it should be fixed.
73 */
74#define IMPORT_EDGE_MAP(Factory) \
75template <typename V> \
76class EdgeMap : public Factory::Map<V> { \
77public: \
78EdgeMap() {} \
79EdgeMap(const Graph& g) : Factory::Map<V>(g, g.edge_maps) {} \
80EdgeMap(const Graph& g, const V& v) : Factory::Map<V>(g, g.node_maps, v) {} \
81EdgeMap(const EdgeMap& copy) : Factory::Map<V>(copy) {} \
82template <typename CMap> EdgeMap(const CMap& copy) : Factory::Map<V>(copy) {} \
83EdgeMap& operator=(const EdgeMap& copy) { \
84  this->Factory::Map<V>::operator=(copy); \
85  return *this; \
86} \
87template <typename CMap>EdgeMap& operator=(const CMap& copy) { \
88  this->Factory::Map<V>::operator=<CMap>(copy); \
89  return *this; \
90} \
91};
92
93/** This macro creates both map factories and imports both maps.
94 */
95#define CREATE_MAPS(TemplateFactory) \
96CREATE_MAP_FACTORIES(TemplateFactory) \
97IMPORT_NODE_MAP(NodeMapFactory) \
98IMPORT_EDGE_MAP(EdgeMapFactory)
99
100#endif
Note: See TracBrowser for help on using the repository browser.