src/hugo/default_map.h
changeset 891 74589d20dbc3
parent 822 88226d9fe821
child 897 ef09eee53b09
     1.1 --- a/src/hugo/default_map.h	Mon Sep 20 17:53:33 2004 +0000
     1.2 +++ b/src/hugo/default_map.h	Mon Sep 20 22:57:48 2004 +0000
     1.3 @@ -29,36 +29,48 @@
     1.4    /** Macro to implement the DefaultMap.
     1.5     */
     1.6  #define DEFAULT_MAP_BODY(DynMap, Value) \
     1.7 -  { \
     1.8 -    typedef DynMap<MapRegistry, Value> MapImpl; \
     1.9 -  \
    1.10 -  public: \
    1.11 -  \
    1.12 -    typedef typename MapRegistry::Graph Graph; \
    1.13 -  \
    1.14 -    DefaultMap() : MapImpl() {} \
    1.15 -  \
    1.16 -    DefaultMap(const Graph& g, MapRegistry& r) : MapImpl(g, r) {} \
    1.17 -  \
    1.18 -    DefaultMap(const Graph& g, MapRegistry& r, const Value& v) \
    1.19 -      : MapImpl(g, r, v) {} \
    1.20 -  \
    1.21 -    DefaultMap(const DefaultMap& copy) \
    1.22 -      : MapImpl(static_cast<const MapImpl&>(copy)) {} \
    1.23 -  \
    1.24 -    template <typename CMap> DefaultMap(const CMap& copy) : MapImpl(copy) {} \
    1.25 -  \
    1.26 -    DefaultMap& operator=(const DefaultMap& copy) { \
    1.27 -      MapImpl::operator=(static_cast<const MapImpl&>(copy)); \
    1.28 -      return *this; \
    1.29 +{ \
    1.30 +\
    1.31 +public: \
    1.32 +\
    1.33 +typedef DynMap<MapRegistry, Value> Parent; \
    1.34 +\
    1.35 +typedef typename MapRegistry::Graph Graph; \
    1.36 +\
    1.37 +DefaultMap() : Parent() {} \
    1.38 +DefaultMap(const Graph& g, MapRegistry& r) : Parent(g, r) {} \
    1.39 +DefaultMap(const Graph& g, MapRegistry& r, const Value& v) \
    1.40 +  : Parent(g, r, v) {} \
    1.41 +DefaultMap(const DefaultMap& copy) \
    1.42 +  : Parent(static_cast<const Parent&>(copy)) {} \
    1.43 +template <typename TT> \
    1.44 +DefaultMap(const DefaultMap<MapRegistry, TT>& copy) { \
    1.45 +  Parent::MapBase::operator= \
    1.46 +    (static_cast<const typename Parent::MapBase&>(copy)); \
    1.47 +  if (Parent::getGraph()) { \
    1.48 +    for (typename Parent::KeyIt it(*Parent::getGraph()); it!=INVALID; ++it) {\
    1.49 +      Parent::add(it); \
    1.50 +      Parent::operator[](it) = copy[it]; \
    1.51      } \
    1.52 -  \
    1.53 -    template <typename CMap> DefaultMap& operator=(const CMap& copy) { \
    1.54 -      MapImpl::operator=(copy); \
    1.55 -      return *this; \
    1.56 +  } \
    1.57 +} \
    1.58 +DefaultMap& operator=(const DefaultMap& copy) { \
    1.59 +  Parent::operator=(static_cast<const Parent&>(copy)); \
    1.60 +  return *this; \
    1.61 +} \
    1.62 +template <typename TT> \
    1.63 +DefaultMap& operator=(const DefaultMap<MapRegistry, TT>& copy) { \
    1.64 +  Parent::clear(); \
    1.65 +  Parent::MapBase::operator=(copy); \
    1.66 +  if (Parent::getGraph()) { \
    1.67 +    for (typename Parent::KeyIt it(*Parent::getGraph()); it!=INVALID; ++it) {\
    1.68 +      Parent::add(it); \
    1.69 +      Parent::operator[](it) = copy[it]; \
    1.70      } \
    1.71 -  \
    1.72 -  };
    1.73 +  } \
    1.74 +  return *this; \
    1.75 +} \
    1.76 +};
    1.77  
    1.78  
    1.79    template <typename MapRegistry, typename Type>