// -*- c++ -*- #ifndef MAP_DEFINES_H #define MAP_DEFINES_H ///\ingroup graphmapfactory ///\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 concrete factory type from a template map * factory to use as node map factory. */ #define CREATE_NODE_MAP_FACTORY(TemplateFactory) \ typedef TemplateFactory NodeMapFactory; /** Creates a concrete factory type from a template map * factory to use as edge map factory. */ #define CREATE_EDGE_MAP_FACTORY(TemplateFactory) \ typedef TemplateFactory EdgeMapFactory; /** Creates both map factories. */ #define CREATE_MAP_FACTORIES(TemplateFactory) \ CREATE_NODE_MAP_FACTORY(TemplateFactory) \ CREATE_EDGE_MAP_FACTORY(TemplateFactory) /** Import a map from a concrete map factory. 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 IMPORT_NODE_MAP(Factory) \ template \ class NodeMap : public Factory::template Map { \ typedef typename Factory::template Map MapImpl; \ public: \ NodeMap() {} \ NodeMap(const Graph& g) : MapImpl(g, g.node_maps) {} \ NodeMap(const Graph& g, const V& 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; \ } \ }; /** Import a map from a concrete map factory. 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 IMPORT_EDGE_MAP(Factory) \ template \ class EdgeMap : public Factory::template Map { \ typedef typename Factory::template Map MapImpl; \ public: \ EdgeMap() {} \ EdgeMap(const Graph& g) : MapImpl(g, g.edge_maps) {} \ EdgeMap(const Graph& g, const V& 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 map factories and imports both maps. */ #define CREATE_MAPS(TemplateFactory) \ CREATE_MAP_FACTORIES(TemplateFactory) \ IMPORT_NODE_MAP(NodeMapFactory) \ IMPORT_EDGE_MAP(EdgeMapFactory) /** 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 concrete factory type from a template map * factory to use as edge map factory. */ #define CREATE_SYM_EDGE_MAP_FACTORY(TemplateFactory) \ typedef SymMapFactory \ SymEdgeMapFactory; /** Import a map from a concrete map factory. 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 IMPORT_SYM_EDGE_MAP(Factory) \ template \ class SymEdgeMap : public Factory::template Map { \ typedef typename Factory::template Map MapImpl; \ public: \ SymEdgeMap() {} \ SymEdgeMap(const Graph& g) : MapImpl(g, g.sym_edge_maps) {} \ SymEdgeMap(const Graph& g, const V& 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; \ } \ }; #define KEEP_NODE_MAP(GraphBase) \ template class NodeMap \ : public GraphBase::template NodeMap \ { \ typedef typename GraphBase::template NodeMap MapImpl; \ typedef V Value; \ public: \ NodeMap() : MapImpl() {} \ \ NodeMap(const Graph& graph) \ : MapImpl(static_cast(graph)) { } \ \ NodeMap(const Graph& graph, const Value& value) \ : MapImpl(static_cast(graph), 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; \ } \ }; #define KEEP_EDGE_MAP(GraphBase) \ template class EdgeMap \ : public GraphBase::template EdgeMap \ { \ typedef typename GraphBase::template EdgeMap MapImpl; \ typedef V Value; \ public: \ EdgeMap() : MapImpl() {} \ \ EdgeMap(const Graph& graph) \ : MapImpl(static_cast(graph)) { } \ \ EdgeMap(const Graph& graph, const Value& value) \ : MapImpl(static_cast(graph), 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; \ } \ }; /// @} #endif