1.1 --- a/src/hugo/default_map_factory.h Wed Sep 08 11:58:06 2004 +0000
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,181 +0,0 @@
1.4 -// -*- c++ -*-
1.5 -#ifndef DEFAULT_MAP_FACTORY_H
1.6 -#define DEFAULT_MAP_FACTORY_H
1.7 -
1.8 -
1.9 -#include <hugo/array_map_factory.h>
1.10 -#include <hugo/vector_map_factory.h>
1.11 -
1.12 -///\ingroup graphmapfactory
1.13 -///\file
1.14 -///\brief Graph maps that construates and destruates
1.15 -///their elements dynamically.
1.16 -
1.17 -namespace hugo {
1.18 -
1.19 -/// \addtogroup graphmapfactory
1.20 -/// @{
1.21 -
1.22 -#define DEFAULT_MAP_BODY(Factory, Val) \
1.23 - { \
1.24 - typedef typename Factory<MapRegistry>::template Map<Val> MapImpl; \
1.25 - \
1.26 - public: \
1.27 - \
1.28 - typedef typename MapRegistry::Graph Graph; \
1.29 - typedef typename MapRegistry::KeyType KeyType; \
1.30 - typedef typename MapRegistry::KeyIt KeyIt; \
1.31 - typedef Val Value; \
1.32 - \
1.33 - typedef typename MapRegistry::MapBase MapBase; \
1.34 - \
1.35 - DefaultMap() : MapImpl() {} \
1.36 - \
1.37 - DefaultMap(const Graph& g, MapRegistry& r) : MapImpl(g, r) {} \
1.38 - \
1.39 - DefaultMap(const Graph& g, MapRegistry& r, const Value& v) \
1.40 - : MapImpl(g, r, v) {} \
1.41 - \
1.42 - DefaultMap(const DefaultMap& copy) \
1.43 - : MapImpl(static_cast<const MapImpl&>(copy)) {} \
1.44 - \
1.45 - template <typename CMap> DefaultMap(const CMap& copy) : MapImpl(copy) {} \
1.46 - \
1.47 - DefaultMap& operator=(const DefaultMap& copy) { \
1.48 - MapImpl::operator=(static_cast<const MapImpl&>(copy)); \
1.49 - return *this; \
1.50 - } \
1.51 - \
1.52 - template <typename CMap> DefaultMap& operator=(const CMap& copy) { \
1.53 - MapImpl::operator=(copy); \
1.54 - return *this; \
1.55 - } \
1.56 - \
1.57 - };
1.58 -
1.59 -
1.60 - template <typename MapRegistry, typename Type>
1.61 - class DefaultMap : public ArrayMapFactory<MapRegistry>::template Map<Type>
1.62 - DEFAULT_MAP_BODY(ArrayMapFactory, Type);
1.63 -
1.64 - template <typename MapRegistry>
1.65 - class DefaultMap<MapRegistry, bool>
1.66 - : public VectorMapFactory<MapRegistry>::template Map<bool>
1.67 - DEFAULT_MAP_BODY(VectorMapFactory, bool);
1.68 -
1.69 - template <typename MapRegistry>
1.70 - class DefaultMap<MapRegistry, char>
1.71 - : public VectorMapFactory<MapRegistry>::template Map<char>
1.72 - DEFAULT_MAP_BODY(VectorMapFactory, char);
1.73 -
1.74 - template <typename MapRegistry>
1.75 - class DefaultMap<MapRegistry, int>
1.76 - : public VectorMapFactory<MapRegistry>::template Map<int>
1.77 - DEFAULT_MAP_BODY(VectorMapFactory, int);
1.78 -
1.79 - template <typename MapRegistry>
1.80 - class DefaultMap<MapRegistry, short>
1.81 - : public VectorMapFactory<MapRegistry>::template Map<short>
1.82 - DEFAULT_MAP_BODY(VectorMapFactory, short);
1.83 -
1.84 - template <typename MapRegistry>
1.85 - class DefaultMap<MapRegistry, long>
1.86 - : public VectorMapFactory<MapRegistry>::template Map<long>
1.87 - DEFAULT_MAP_BODY(VectorMapFactory, long);
1.88 -
1.89 - template <typename MapRegistry>
1.90 - class DefaultMap<MapRegistry, float>
1.91 - : public VectorMapFactory<MapRegistry>::template Map<float>
1.92 - DEFAULT_MAP_BODY(VectorMapFactory, float);
1.93 -
1.94 - template <typename MapRegistry>
1.95 - class DefaultMap<MapRegistry, double>
1.96 - : public VectorMapFactory<MapRegistry>::template Map<double>
1.97 - DEFAULT_MAP_BODY(VectorMapFactory, double);
1.98 -
1.99 - template <typename MapRegistry>
1.100 - class DefaultMap<MapRegistry, long double>
1.101 - : public VectorMapFactory<MapRegistry>::template Map<long double>
1.102 - DEFAULT_MAP_BODY(VectorMapFactory, long double);
1.103 -
1.104 - template <typename MapRegistry, typename Type>
1.105 - class DefaultMap<MapRegistry, Type*>
1.106 - : public VectorMapFactory<MapRegistry>::template Map<Type*>
1.107 - DEFAULT_MAP_BODY(VectorMapFactory, Type*);
1.108 -
1.109 -
1.110 - /** The DefaultMapFactory template class is a factory class
1.111 - * to create maps for the edge and nodes. This map factory
1.112 - * uses the VectorMapFactory if the ValueType is a primitive
1.113 - * type and the ArrayMapFactory for the other cases.
1.114 - *
1.115 - * The template parameter is the MapRegistry that the maps
1.116 - * will belong to.
1.117 - */
1.118 -
1.119 - template <typename MapRegistry>
1.120 - class DefaultMapFactory {
1.121 -
1.122 - public:
1.123 - /// The graph type of the maps.
1.124 - typedef typename MapRegistry::Graph Graph;
1.125 - /// The key type of the maps.
1.126 - typedef typename MapRegistry::KeyType KeyType;
1.127 - /// The iterator to iterate on the keys.
1.128 - typedef typename MapRegistry::KeyIt KeyIt;
1.129 -
1.130 - /// The MapBase of the Map which imlements the core regisitry function.
1.131 - typedef typename MapRegistry::MapBase MapBase;
1.132 -
1.133 -
1.134 - /** The template Map type.
1.135 - */
1.136 - template <typename V>
1.137 - class Map : public DefaultMap<MapRegistry, V> {
1.138 -
1.139 - typedef DefaultMap<MapRegistry, V> MapImpl;
1.140 -
1.141 - public:
1.142 -
1.143 - typedef V Value;
1.144 -
1.145 - /** Default constructor for the map.
1.146 - */
1.147 - Map() : MapImpl() {}
1.148 -
1.149 - /** Graph and Registry initialized map constructor.
1.150 - */
1.151 - Map(const Graph& g, MapRegistry& r) : MapImpl(g, r) {}
1.152 -
1.153 - /** Constructor to use default value to initialize the map.
1.154 - */
1.155 - Map(const Graph& g, MapRegistry& r, const Value& v) : MapImpl(g, r, v) {}
1.156 -
1.157 - /** Constructor to copy a map of the same map type.
1.158 - */
1.159 - Map(const Map& copy) : MapImpl(static_cast<const MapImpl&>(copy)) {}
1.160 -
1.161 - /** Constructor to copy a map of an other map type.
1.162 - */
1.163 - template <typename CMap> Map(const CMap& copy) : MapImpl(copy) {}
1.164 -
1.165 - /** Assign operator to copy a map of the same map type.
1.166 - */
1.167 - Map& operator=(const Map& copy) {
1.168 - MapImpl::operator=(static_cast<const MapImpl&>(copy));
1.169 - return *this;
1.170 - }
1.171 -
1.172 - /** Assign operator to copy a map an other map type.
1.173 - */
1.174 - template <typename CMap> Map& operator=(const CMap& copy) {
1.175 - MapImpl::operator=(copy);
1.176 - return *this;
1.177 - }
1.178 -
1.179 - };
1.180 -
1.181 - };
1.182 -}
1.183 -
1.184 -#endif