// -*- c++ -*- #ifndef MAP_DEFINES_H #define MAP_DEFINES_H ///\ingroup graphmaps ///\file ///\brief Defines to help creating graph maps. /// \addtogroup graphmapfactory /// @{ /** Creates the EdgeMapRegistry type an declare a mutable instance * named edge_maps. */ #define CREATE_EDGE_MAP_REGISTRY \ typedef MapRegistry EdgeMapRegistry; \ mutable EdgeMapRegistry edge_maps; /** Creates the NodeMapRegistry type an declare a mutable instance * named node_maps. */ #define CREATE_NODE_MAP_REGISTRY \ typedef MapRegistry NodeMapRegistry; \ mutable NodeMapRegistry node_maps; /** Creates both map registries. */ #define CREATE_MAP_REGISTRIES \ CREATE_NODE_MAP_REGISTRY \ CREATE_EDGE_MAP_REGISTRY /** Creates a map from a template map. The import method is * an overloading of the map type. * The reason to use these macro is that the c++ does not support * the template typedefs. If a future release of the c++ * supports this feature it should be fixed. */ #define CREATE_NODE_MAP(DynMap) \ template \ class NodeMap : public DynMap { \ typedef DynMap MapImpl; \ public: \ NodeMap() {} \ NodeMap(const typename MapImpl::Graph& g) \ : MapImpl(g, g.node_maps) {} \ NodeMap(const typename MapImpl::Graph& g, const Value& v) \ : MapImpl(g, g.node_maps, v) {} \ NodeMap(const NodeMap& copy) : MapImpl(static_cast(copy)) {} \ template NodeMap(const CMap& copy) : MapImpl(copy) {} \ NodeMap& operator=(const NodeMap& copy) { \ MapImpl::operator=(static_cast(copy));\ return *this; \ } \ template NodeMap& operator=(const CMap& copy) { \ MapImpl::operator=(copy);\ return *this; \ } \ }; /** Creates a map from a template map. The import method is * an overloading of the map type. * The reason to use these macro is that the c++ does not support * the template typedefs. If a future release of the c++ * supports this feature it should be fixed. */ #define CREATE_EDGE_MAP(DynMap) \ template \ class EdgeMap : public DynMap { \ typedef DynMap MapImpl; \ public: \ EdgeMap() {} \ EdgeMap(const typename MapImpl::Graph& g) \ : MapImpl(g, g.edge_maps) {} \ EdgeMap(const typename MapImpl::Graph& g, const Value& v) \ : MapImpl(g, g.edge_maps, v) {} \ EdgeMap(const EdgeMap& copy) : MapImpl(static_cast(copy)) {} \ template EdgeMap(const CMap& copy) : MapImpl(copy) {} \ EdgeMap& operator=(const EdgeMap& copy) { \ MapImpl::operator=(static_cast(copy));\ return *this; \ } \ template EdgeMap& operator=(const CMap& copy) { \ MapImpl::operator=(copy);\ return *this; \ } \ }; /** This macro creates both maps. */ #define CREATE_MAPS(DynMap) \ CREATE_NODE_MAP(DynMap) \ CREATE_EDGE_MAP(DynMap) /** This macro creates MapRegistry for Symmetric Edge Maps. */ #define CREATE_SYM_EDGE_MAP_REGISTRY \ typedef SymEdgeIt SymEdgeIt; \ typedef MapRegistry SymEdgeMapRegistry; \ mutable EdgeMapRegistry sym_edge_maps; /** Creates a map from a template map. The import method is * an overloading of the map type. * The reason to use these macro is that the c++ does not support * the template typedefs. If a future release of the c++ * supports this feature it should be fixed. */ #define CREATE_SYM_EDGE_MAP(DynMap) \ template \ class SymEdgeMap : public SymMap { \ typedef SymMap MapImpl; \ public: \ \ SymEdgeMap() {} \ \ SymEdgeMap(const typename MapImpl::Graph& g) \ : MapImpl(g, g.sym_edge_maps) {} \ \ SymEdgeMap(const typename MapImpl::Graph& g, const Value& v) \ : MapImpl(g, g.sym_edge_maps, v) {} \ \ SymEdgeMap(const SymEdgeMap& copy) \ : MapImpl(static_cast(copy)) {} \ \ template SymEdgeMap(const CMap& copy) : MapImpl(copy) {} \ SymEdgeMap& operator=(const SymEdgeMap& copy) { \ MapImpl::operator=(static_cast(copy));\ return *this; \ } \ \ template SymEdgeMap& operator=(const CMap& copy) { \ MapImpl::operator=(copy);\ return *this; \ } \ }; /** This is a macro to import an node map into a graph class. */ #define IMPORT_NODE_MAP(From, from, To, to) \ template \ class NodeMap \ : public From::template NodeMap { \ typedef typename From::template NodeMap MapImpl; \ public: \ NodeMap() : MapImpl() {} \ \ NodeMap(const To& to) \ : MapImpl(static_cast(from)) { } \ \ NodeMap(const To& to, const Value& value) \ : MapImpl(static_cast(from), value) { } \ \ NodeMap(const NodeMap& copy) \ : MapImpl(static_cast(copy)) {} \ \ template \ NodeMap(const CMap& copy) \ : MapImpl(copy) {} \ \ NodeMap& operator=(const NodeMap& copy) { \ MapImpl::operator=(static_cast(copy)); \ return *this; \ } \ \ template \ NodeMap& operator=(const CMap& copy) { \ MapImpl::operator=(copy); \ return *this; \ } \ }; /** This is a macro to import an edge map into a graph class. */ #define IMPORT_EDGE_MAP(From, from, To, to) \ template \ class EdgeMap \ : public From::template EdgeMap { \ typedef typename From::template EdgeMap MapImpl; \ public: \ EdgeMap() : MapImpl() {} \ \ EdgeMap(const To& to) \ : MapImpl(static_cast(from)) { } \ \ EdgeMap(const To& to, const Value& value) \ : MapImpl(static_cast(from), value) { } \ \ EdgeMap(const EdgeMap& copy) \ : MapImpl(static_cast(copy)) {} \ \ template \ EdgeMap(const CMap& copy) \ : MapImpl(copy) {} \ \ EdgeMap& operator=(const EdgeMap& copy) { \ MapImpl::operator=(static_cast(copy)); \ return *this; \ } \ \ template \ EdgeMap& operator=(const CMap& copy) { \ MapImpl::operator=(copy); \ return *this; \ } \ }; /** This is a macro to keep the node and edge maps for a graph class. */ #define KEEP_MAPS(From, To) \ IMPORT_EDGE_MAP(From, graph, To, graph) \ IMPORT_NODE_MAP(From, graph, To, graph) /// @} #endif