// -*- c++ -*- #ifndef DEFAULT_MAP_FACTORY_H #define DEFAULT_MAP_FACTORY_H #include #include ///\ingroup graphmapfactory ///\file ///\brief Graph maps that construates and destruates ///their elements dynamically. namespace hugo { /// \addtogroup graphmapfactory /// @{ #define DEFAULT_MAP_BODY(Factory, Val) \ { \ typedef typename Factory::template Map MapImpl; \ \ public: \ \ typedef typename MapRegistry::Graph Graph; \ typedef typename MapRegistry::KeyType KeyType; \ typedef typename MapRegistry::KeyIt KeyIt; \ typedef Val Value; \ \ typedef typename MapRegistry::MapBase MapBase; \ \ DefaultMap() : MapImpl() {} \ \ DefaultMap(const Graph& g, MapRegistry& r) : MapImpl(g, r) {} \ \ DefaultMap(const Graph& g, MapRegistry& r, const Value& v) \ : MapImpl(g, r, v) {} \ \ DefaultMap(const DefaultMap& copy) \ : MapImpl(static_cast(copy)) {} \ \ template DefaultMap(const CMap& copy) : MapImpl(copy) {} \ \ DefaultMap& operator=(const DefaultMap& copy) { \ MapImpl::operator=(static_cast(copy)); \ return *this; \ } \ \ template DefaultMap& operator=(const CMap& copy) { \ MapImpl::operator=(copy); \ return *this; \ } \ \ }; template class DefaultMap : public ArrayMapFactory::template Map DEFAULT_MAP_BODY(ArrayMapFactory, Type); template class DefaultMap : public VectorMapFactory::template Map DEFAULT_MAP_BODY(VectorMapFactory, bool); template class DefaultMap : public VectorMapFactory::template Map DEFAULT_MAP_BODY(VectorMapFactory, char); template class DefaultMap : public VectorMapFactory::template Map DEFAULT_MAP_BODY(VectorMapFactory, int); template class DefaultMap : public VectorMapFactory::template Map DEFAULT_MAP_BODY(VectorMapFactory, short); template class DefaultMap : public VectorMapFactory::template Map DEFAULT_MAP_BODY(VectorMapFactory, long); template class DefaultMap : public VectorMapFactory::template Map DEFAULT_MAP_BODY(VectorMapFactory, float); template class DefaultMap : public VectorMapFactory::template Map DEFAULT_MAP_BODY(VectorMapFactory, double); template class DefaultMap : public VectorMapFactory::template Map DEFAULT_MAP_BODY(VectorMapFactory, long double); template class DefaultMap : public VectorMapFactory::template Map DEFAULT_MAP_BODY(VectorMapFactory, Type*); /** The DefaultMapFactory template class is a factory class * to create maps for the edge and nodes. This map factory * uses the VectorMapFactory if the ValueType is a primitive * type and the ArrayMapFactory for the other cases. * * The template parameter is the MapRegistry that the maps * will belong to. */ template class DefaultMapFactory { public: /// The graph type of the maps. typedef typename MapRegistry::Graph Graph; /// The key type of the maps. typedef typename MapRegistry::KeyType KeyType; /// The iterator to iterate on the keys. typedef typename MapRegistry::KeyIt KeyIt; /// The MapBase of the Map which imlements the core regisitry function. typedef typename MapRegistry::MapBase MapBase; /** The template Map type. */ template class Map : public DefaultMap { typedef DefaultMap MapImpl; public: typedef V Value; /** Default constructor for the map. */ Map() : MapImpl() {} /** Graph and Registry initialized map constructor. */ Map(const Graph& g, MapRegistry& r) : MapImpl(g, r) {} /** Constructor to use default value to initialize the map. */ Map(const Graph& g, MapRegistry& r, const Value& v) : MapImpl(g, r, v) {} /** Constructor to copy a map of the same map type. */ Map(const Map& copy) : MapImpl(static_cast(copy)) {} /** Constructor to copy a map of an other map type. */ template Map(const CMap& copy) : MapImpl(copy) {} /** Assign operator to copy a map of the same map type. */ Map& operator=(const Map& copy) { MapImpl::operator=(static_cast(copy)); return *this; } /** Assign operator to copy a map an other map type. */ template Map& operator=(const CMap& copy) { MapImpl::operator=(copy); return *this; } }; }; } #endif