// -*- c++ -*- #ifndef DEFAULT_MAP_H #define DEFAULT_MAP_H #include #include ///\ingroup graphmaps ///\file ///\brief Graph maps that construates and destruates ///their elements dynamically. namespace hugo { /// \addtogroup graphmaps /// @{ /** The ArrayMap template class is graph map structure what * automatically updates the map when a key is added to or erased from * the map. This map uses the VectorMap if the ValueType is a primitive * type and the ArrayMap for the other cases. * * The template parameter is the MapRegistry that the maps * will belong to and the ValueType. */ /** Macro to implement the DefaultMap. */ #define DEFAULT_MAP_BODY(DynMap, Value) \ { \ typedef DynMap MapImpl; \ \ public: \ \ typedef typename MapRegistry::Graph Graph; \ \ 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 ArrayMap DEFAULT_MAP_BODY(ArrayMap, Type); template class DefaultMap : public VectorMap DEFAULT_MAP_BODY(VectorMap, bool); template class DefaultMap : public VectorMap DEFAULT_MAP_BODY(VectorMap, char); template class DefaultMap : public VectorMap DEFAULT_MAP_BODY(VectorMap, int); template class DefaultMap : public VectorMap DEFAULT_MAP_BODY(VectorMap, short); template class DefaultMap : public VectorMap DEFAULT_MAP_BODY(VectorMap, long); template class DefaultMap : public VectorMap DEFAULT_MAP_BODY(VectorMap, float); template class DefaultMap : public VectorMap DEFAULT_MAP_BODY(VectorMap, double); template class DefaultMap : public VectorMap DEFAULT_MAP_BODY(VectorMap, long double); template class DefaultMap : public VectorMap DEFAULT_MAP_BODY(VectorMap, Type*); } #endif