COIN-OR::LEMON - Graph Library

source: lemon-0.x/src/hugo/default_map_factory.h @ 798:6d1abeb62dd3

Last change on this file since 798:6d1abeb62dd3 was 798:6d1abeb62dd3, checked in by Balazs Dezso, 16 years ago
File size: 4.0 KB
Line 
1// -*- c++ -*-
2#ifndef DEFAULT_MAP_FACTORY_H
3#define DEFAULT_MAP_FACTORY_H
4
5
6#include <hugo/array_map_factory.h>
7#include <hugo/vector_map_factory.h>
8
9namespace hugo {
10
11#define DEFAULT_MAP_BODY(Factory, Val) \
12  { \
13    typedef typename Factory<MapRegistry>::template Map<Val> MapImpl; \
14  \
15  public: \
16  \
17    typedef typename MapRegistry::Graph Graph; \
18    typedef typename MapRegistry::Key Key; \
19    typedef typename MapRegistry::KeyIt KeyIt; \
20    typedef Val Value; \
21  \
22    typedef typename MapRegistry::MapBase MapBase; \
23  \
24    DefaultMap() : MapImpl() {} \
25  \
26    DefaultMap(const Graph& g, MapRegistry& r) : MapImpl(g, r) {} \
27  \
28    DefaultMap(const Graph& g, MapRegistry& r, const Value& v) \
29      : MapImpl(g, r, v) {} \
30  \
31    DefaultMap(const DefaultMap& copy) \
32      : MapImpl(static_cast<const MapImpl&>(copy)) {} \
33  \
34    template <typename CMap> DefaultMap(const CMap& copy) : MapImpl(copy) {} \
35  \
36    DefaultMap& operator=(const DefaultMap& copy) { \
37      MapImpl::operator=(static_cast<const MapImpl&>(copy)); \
38      return *this; \
39    } \
40  \
41    template <typename CMap> DefaultMap& operator=(const CMap& copy) { \
42      MapImpl::operator=(copy); \
43      return *this; \
44    } \
45  \
46  };
47
48
49  template <typename MapRegistry, typename Type>
50  class DefaultMap : public ArrayMapFactory<MapRegistry>::template Map<Type>
51  DEFAULT_MAP_BODY(ArrayMapFactory, Type);
52
53  template <typename MapRegistry>
54  class DefaultMap<MapRegistry, bool>
55    : public VectorMapFactory<MapRegistry>::template Map<bool>
56  DEFAULT_MAP_BODY(VectorMapFactory, bool);
57
58  template <typename MapRegistry>
59  class DefaultMap<MapRegistry, char>
60    : public VectorMapFactory<MapRegistry>::template Map<char>
61  DEFAULT_MAP_BODY(VectorMapFactory, char);
62
63  template <typename MapRegistry>
64  class DefaultMap<MapRegistry, int>
65    : public VectorMapFactory<MapRegistry>::template Map<int>
66  DEFAULT_MAP_BODY(VectorMapFactory, int);
67
68  template <typename MapRegistry>
69  class DefaultMap<MapRegistry, short>
70    : public VectorMapFactory<MapRegistry>::template Map<short>
71  DEFAULT_MAP_BODY(VectorMapFactory, short);
72
73  template <typename MapRegistry>
74  class DefaultMap<MapRegistry, long>
75    : public VectorMapFactory<MapRegistry>::template Map<long>
76  DEFAULT_MAP_BODY(VectorMapFactory, long);
77
78  template <typename MapRegistry>
79  class DefaultMap<MapRegistry, float>
80    : public VectorMapFactory<MapRegistry>::template Map<float>
81  DEFAULT_MAP_BODY(VectorMapFactory, float);
82
83  template <typename MapRegistry>
84  class DefaultMap<MapRegistry, double>
85    : public VectorMapFactory<MapRegistry>::template Map<double>
86  DEFAULT_MAP_BODY(VectorMapFactory, double);
87
88  template <typename MapRegistry>
89  class DefaultMap<MapRegistry, long double>
90    : public VectorMapFactory<MapRegistry>::template Map<long double>
91  DEFAULT_MAP_BODY(VectorMapFactory, long double);
92
93  template <typename MapRegistry, typename Type>
94  class DefaultMap<MapRegistry, Type*>
95    : public VectorMapFactory<MapRegistry>::template Map<Type*>
96  DEFAULT_MAP_BODY(VectorMapFactory, Type*);
97
98  template <typename MapRegistry>
99  class DefaultMapFactory {
100               
101  public:
102               
103    typedef typename MapRegistry::Graph Graph;
104    typedef typename MapRegistry::Key Key;
105    typedef typename MapRegistry::KeyIt KeyIt;
106
107    typedef typename MapRegistry::MapBase MapBase;
108
109    template <typename V>
110    class Map : public DefaultMap<MapRegistry, V> {
111
112      typedef DefaultMap<MapRegistry, V> MapImpl;
113
114    public:
115     
116      typedef V Value;
117
118      Map() : MapImpl() {}
119
120      Map(const Graph& g, MapRegistry& r) : MapImpl(g, r) {}
121
122      Map(const Graph& g, MapRegistry& r, const Value& v) : MapImpl(g, r, v) {}
123
124      Map(const Map& copy) : MapImpl(static_cast<const MapImpl&>(copy)) {}
125
126      template <typename CMap> Map(const CMap& copy) : MapImpl(copy) {}
127
128      Map& operator=(const Map& copy) {
129        MapImpl::operator=(static_cast<const MapImpl&>(copy));
130        return *this;
131      }
132
133      template <typename CMap> Map& operator=(const CMap& copy) {
134        MapImpl::operator=(copy);
135        return *this;
136      }
137
138    };
139
140  };
141}
142
143#endif
Note: See TracBrowser for help on using the repository browser.