Bug: This file must be updated.
2 #ifndef DEFAULT_MAP_FACTORY_H
3 #define DEFAULT_MAP_FACTORY_H
6 #include <hugo/array_map_factory.h>
7 #include <hugo/vector_map_factory.h>
9 ///\ingroup graphmapfactory
11 ///\brief Graph maps that construates and destruates
12 ///their elements dynamically.
16 /// \addtogroup graphmapfactory
19 #define DEFAULT_MAP_BODY(Factory, Val) \
21 typedef typename Factory<MapRegistry>::template Map<Val> MapImpl; \
25 typedef typename MapRegistry::Graph Graph; \
26 typedef typename MapRegistry::KeyType KeyType; \
27 typedef typename MapRegistry::KeyIt KeyIt; \
30 typedef typename MapRegistry::MapBase MapBase; \
32 DefaultMap() : MapImpl() {} \
34 DefaultMap(const Graph& g, MapRegistry& r) : MapImpl(g, r) {} \
36 DefaultMap(const Graph& g, MapRegistry& r, const Value& v) \
37 : MapImpl(g, r, v) {} \
39 DefaultMap(const DefaultMap& copy) \
40 : MapImpl(static_cast<const MapImpl&>(copy)) {} \
42 template <typename CMap> DefaultMap(const CMap& copy) : MapImpl(copy) {} \
44 DefaultMap& operator=(const DefaultMap& copy) { \
45 MapImpl::operator=(static_cast<const MapImpl&>(copy)); \
49 template <typename CMap> DefaultMap& operator=(const CMap& copy) { \
50 MapImpl::operator=(copy); \
57 template <typename MapRegistry, typename Type>
58 class DefaultMap : public ArrayMapFactory<MapRegistry>::template Map<Type>
59 DEFAULT_MAP_BODY(ArrayMapFactory, Type);
61 template <typename MapRegistry>
62 class DefaultMap<MapRegistry, bool>
63 : public VectorMapFactory<MapRegistry>::template Map<bool>
64 DEFAULT_MAP_BODY(VectorMapFactory, bool);
66 template <typename MapRegistry>
67 class DefaultMap<MapRegistry, char>
68 : public VectorMapFactory<MapRegistry>::template Map<char>
69 DEFAULT_MAP_BODY(VectorMapFactory, char);
71 template <typename MapRegistry>
72 class DefaultMap<MapRegistry, int>
73 : public VectorMapFactory<MapRegistry>::template Map<int>
74 DEFAULT_MAP_BODY(VectorMapFactory, int);
76 template <typename MapRegistry>
77 class DefaultMap<MapRegistry, short>
78 : public VectorMapFactory<MapRegistry>::template Map<short>
79 DEFAULT_MAP_BODY(VectorMapFactory, short);
81 template <typename MapRegistry>
82 class DefaultMap<MapRegistry, long>
83 : public VectorMapFactory<MapRegistry>::template Map<long>
84 DEFAULT_MAP_BODY(VectorMapFactory, long);
86 template <typename MapRegistry>
87 class DefaultMap<MapRegistry, float>
88 : public VectorMapFactory<MapRegistry>::template Map<float>
89 DEFAULT_MAP_BODY(VectorMapFactory, float);
91 template <typename MapRegistry>
92 class DefaultMap<MapRegistry, double>
93 : public VectorMapFactory<MapRegistry>::template Map<double>
94 DEFAULT_MAP_BODY(VectorMapFactory, double);
96 template <typename MapRegistry>
97 class DefaultMap<MapRegistry, long double>
98 : public VectorMapFactory<MapRegistry>::template Map<long double>
99 DEFAULT_MAP_BODY(VectorMapFactory, long double);
101 template <typename MapRegistry, typename Type>
102 class DefaultMap<MapRegistry, Type*>
103 : public VectorMapFactory<MapRegistry>::template Map<Type*>
104 DEFAULT_MAP_BODY(VectorMapFactory, Type*);
107 /** The DefaultMapFactory template class is a factory class
108 * to create maps for the edge and nodes. This map factory
109 * uses the VectorMapFactory if the ValueType is a primitive
110 * type and the ArrayMapFactory for the other cases.
112 * The template parameter is the MapRegistry that the maps
116 template <typename MapRegistry>
117 class DefaultMapFactory {
120 /// The graph type of the maps.
121 typedef typename MapRegistry::Graph Graph;
122 /// The key type of the maps.
123 typedef typename MapRegistry::KeyType KeyType;
124 /// The iterator to iterate on the keys.
125 typedef typename MapRegistry::KeyIt KeyIt;
127 /// The MapBase of the Map which imlements the core regisitry function.
128 typedef typename MapRegistry::MapBase MapBase;
131 /** The template Map type.
133 template <typename V>
134 class Map : public DefaultMap<MapRegistry, V> {
136 typedef DefaultMap<MapRegistry, V> MapImpl;
142 /** Default constructor for the map.
146 /** Graph and Registry initialized map constructor.
148 Map(const Graph& g, MapRegistry& r) : MapImpl(g, r) {}
150 /** Constructor to use default value to initialize the map.
152 Map(const Graph& g, MapRegistry& r, const Value& v) : MapImpl(g, r, v) {}
154 /** Constructor to copy a map of the same map type.
156 Map(const Map& copy) : MapImpl(static_cast<const MapImpl&>(copy)) {}
158 /** Constructor to copy a map of an other map type.
160 template <typename CMap> Map(const CMap& copy) : MapImpl(copy) {}
162 /** Assign operator to copy a map of the same map type.
164 Map& operator=(const Map& copy) {
165 MapImpl::operator=(static_cast<const MapImpl&>(copy));
169 /** Assign operator to copy a map an other map type.
171 template <typename CMap> Map& operator=(const CMap& copy) {
172 MapImpl::operator=(copy);