src/hugo/default_map.h
changeset 897 ef09eee53b09
parent 891 74589d20dbc3
child 901 69a8e672acb1
equal deleted inserted replaced
1:908fa809fec7 2:6878073ff299
    35 \
    35 \
    36 typedef DynMap<MapRegistry, Value> Parent; \
    36 typedef DynMap<MapRegistry, Value> Parent; \
    37 \
    37 \
    38 typedef typename MapRegistry::Graph Graph; \
    38 typedef typename MapRegistry::Graph Graph; \
    39 \
    39 \
    40 DefaultMap() : Parent() {} \
       
    41 DefaultMap(const Graph& g, MapRegistry& r) : Parent(g, r) {} \
    40 DefaultMap(const Graph& g, MapRegistry& r) : Parent(g, r) {} \
    42 DefaultMap(const Graph& g, MapRegistry& r, const Value& v) \
    41 DefaultMap(const Graph& g, MapRegistry& r, const Value& v) \
    43   : Parent(g, r, v) {} \
    42   : Parent(g, r, v) {} \
    44 DefaultMap(const DefaultMap& copy) \
    43 DefaultMap(const DefaultMap& copy) \
    45   : Parent(static_cast<const Parent&>(copy)) {} \
    44   : Parent(static_cast<const Parent&>(copy)) {} \
    46 template <typename TT> \
    45 template <typename TT> \
    47 DefaultMap(const DefaultMap<MapRegistry, TT>& copy) { \
    46 DefaultMap(const DefaultMap<MapRegistry, TT>& copy) \
       
    47   : { \
    48   Parent::MapBase::operator= \
    48   Parent::MapBase::operator= \
    49     (static_cast<const typename Parent::MapBase&>(copy)); \
    49     (static_cast<const typename Parent::MapBase&>(copy)); \
    50   if (Parent::getGraph()) { \
    50   if (Parent::getGraph()) { \
    51     for (typename Parent::KeyIt it(*Parent::getGraph()); it!=INVALID; ++it) {\
    51     for (typename Parent::KeyIt it(*Parent::getGraph()); it!=INVALID; ++it) {\
    52       Parent::add(it); \
    52       Parent::add(it); \
    58   Parent::operator=(static_cast<const Parent&>(copy)); \
    58   Parent::operator=(static_cast<const Parent&>(copy)); \
    59   return *this; \
    59   return *this; \
    60 } \
    60 } \
    61 template <typename TT> \
    61 template <typename TT> \
    62 DefaultMap& operator=(const DefaultMap<MapRegistry, TT>& copy) { \
    62 DefaultMap& operator=(const DefaultMap<MapRegistry, TT>& copy) { \
    63   Parent::clear(); \
    63   if (Parent::getGraph() != copy.getGraph()) { \
    64   Parent::MapBase::operator=(copy); \
    64     Parent::clear(); \
       
    65     Parent::MapBase::operator=(copy); \
       
    66     Parent::construct(); \
       
    67   } \
    65   if (Parent::getGraph()) { \
    68   if (Parent::getGraph()) { \
    66     for (typename Parent::KeyIt it(*Parent::getGraph()); it!=INVALID; ++it) {\
    69     for (typename Parent::KeyIt it(*Parent::getGraph()); it!=INVALID; ++it) {\
    67       Parent::add(it); \
       
    68       Parent::operator[](it) = copy[it]; \
    70       Parent::operator[](it) = copy[it]; \
    69     } \
    71     } \
    70   } \
    72   } \
    71   return *this; \
    73   return *this; \
    72 } \
    74 } \