deba@782: // -*- c++ -*- deba@782: #ifndef MAP_DEFINES_H deba@782: #define MAP_DEFINES_H deba@782: alpar@785: ///\ingroup graphmapfactory alpar@785: ///\file alpar@785: ///\brief Defines to help creating graph maps. alpar@785: alpar@785: /// \addtogroup graphmapfactory alpar@785: /// @{ alpar@785: deba@782: /** Creates the EdgeMapRegistry type an declare a mutable instance deba@782: * named edge_maps. deba@782: */ deba@782: #define CREATE_EDGE_MAP_REGISTRY \ deba@782: typedef MapRegistry EdgeMapRegistry; \ deba@782: mutable EdgeMapRegistry edge_maps; deba@782: deba@782: /** Creates the NodeMapRegistry type an declare a mutable instance deba@782: * named node_maps. deba@782: */ deba@782: #define CREATE_NODE_MAP_REGISTRY \ deba@782: typedef MapRegistry NodeMapRegistry; \ deba@782: mutable NodeMapRegistry node_maps; deba@782: deba@782: /** Creates both map registries. deba@782: */ deba@782: #define CREATE_MAP_REGISTRIES \ deba@782: CREATE_NODE_MAP_REGISTRY \ deba@782: CREATE_EDGE_MAP_REGISTRY deba@782: deba@782: /** Creates a concrete factory type from a template map deba@782: * factory to use as node map factory. deba@782: */ deba@782: #define CREATE_NODE_MAP_FACTORY(TemplateFactory) \ deba@782: typedef TemplateFactory NodeMapFactory; deba@782: deba@782: /** Creates a concrete factory type from a template map deba@782: * factory to use as edge map factory. deba@782: */ deba@782: #define CREATE_EDGE_MAP_FACTORY(TemplateFactory) \ deba@782: typedef TemplateFactory EdgeMapFactory; deba@782: deba@782: /** Creates both map factories. deba@782: */ deba@782: #define CREATE_MAP_FACTORIES(TemplateFactory) \ deba@782: CREATE_NODE_MAP_FACTORY(TemplateFactory) \ deba@782: CREATE_EDGE_MAP_FACTORY(TemplateFactory) deba@782: deba@782: /** Import a map from a concrete map factory. The import method is deba@782: * an overloading of the map type. deba@782: * The reason to use these macro is that the c++ does not support deba@782: * the template typedefs. If a future release of the c++ deba@782: * supports this feature it should be fixed. deba@782: */ deba@782: #define IMPORT_NODE_MAP(Factory) \ deba@782: template \ deba@782: class NodeMap : public Factory::template Map { \ deba@782: typedef typename Factory::template Map MapImpl; \ deba@782: public: \ deba@782: NodeMap() {} \ deba@782: NodeMap(const Graph& g) : MapImpl(g, g.node_maps) {} \ deba@782: NodeMap(const Graph& g, const V& v) : MapImpl(g, g.node_maps, v) {} \ deba@782: NodeMap(const NodeMap& copy) : MapImpl(static_cast(copy)) {} \ deba@782: template NodeMap(const CMap& copy) : MapImpl(copy) {} \ deba@782: NodeMap& operator=(const NodeMap& copy) { \ deba@782: MapImpl::operator=(static_cast(copy));\ deba@782: return *this; \ deba@782: } \ deba@782: template NodeMap& operator=(const CMap& copy) { \ deba@782: MapImpl::operator=(copy);\ deba@782: return *this; \ deba@782: } \ deba@782: }; deba@782: deba@782: /** Import a map from a concrete map factory. The import method is deba@782: * an overloading of the map type. deba@782: * The reason to use these macro is that the c++ does not support deba@782: * the template typedefs. If a future release of the c++ deba@782: * supports this feature it should be fixed. deba@782: */ deba@782: #define IMPORT_EDGE_MAP(Factory) \ deba@782: template \ deba@782: class EdgeMap : public Factory::template Map { \ deba@782: typedef typename Factory::template Map MapImpl; \ deba@782: public: \ deba@782: EdgeMap() {} \ deba@782: EdgeMap(const Graph& g) : MapImpl(g, g.edge_maps) {} \ deba@782: EdgeMap(const Graph& g, const V& v) : MapImpl(g, g.edge_maps, v) {} \ deba@782: EdgeMap(const EdgeMap& copy) : MapImpl(static_cast(copy)) {} \ deba@782: template EdgeMap(const CMap& copy) : MapImpl(copy) {} \ deba@782: EdgeMap& operator=(const EdgeMap& copy) { \ deba@782: MapImpl::operator=(static_cast(copy));\ deba@782: return *this; \ deba@782: } \ deba@782: template EdgeMap& operator=(const CMap& copy) { \ deba@782: MapImpl::operator=(copy);\ deba@782: return *this; \ deba@782: } \ deba@782: }; deba@782: deba@782: /** This macro creates both map factories and imports both maps. deba@782: */ deba@782: #define CREATE_MAPS(TemplateFactory) \ deba@782: CREATE_MAP_FACTORIES(TemplateFactory) \ deba@782: IMPORT_NODE_MAP(NodeMapFactory) \ deba@782: IMPORT_EDGE_MAP(EdgeMapFactory) deba@782: deba@782: /** This macro creates MapRegistry for Symmetric Edge Maps. deba@782: */ deba@782: #define CREATE_SYM_EDGE_MAP_REGISTRY \ deba@782: typedef SymEdgeIt SymEdgeIt; \ deba@782: typedef MapRegistry SymEdgeMapRegistry; \ deba@782: mutable EdgeMapRegistry sym_edge_maps; deba@782: deba@782: /** Creates a concrete factory type from a template map deba@782: * factory to use as edge map factory. deba@782: */ deba@782: #define CREATE_SYM_EDGE_MAP_FACTORY(TemplateFactory) \ deba@782: typedef SymMapFactory \ deba@782: SymEdgeMapFactory; deba@782: deba@782: /** Import a map from a concrete map factory. The import method is deba@782: * an overloading of the map type. deba@782: * The reason to use these macro is that the c++ does not support deba@782: * the template typedefs. If a future release of the c++ deba@782: * supports this feature it should be fixed. deba@782: */ deba@782: #define IMPORT_SYM_EDGE_MAP(Factory) \ deba@782: template \ deba@782: class SymEdgeMap : public Factory::template Map { \ deba@782: typedef typename Factory::template Map MapImpl; \ deba@782: public: \ deba@782: SymEdgeMap() {} \ deba@782: SymEdgeMap(const Graph& g) : MapImpl(g, g.sym_edge_maps) {} \ deba@782: SymEdgeMap(const Graph& g, const V& v) : MapImpl(g, g.sym_edge_maps, v) {} \ deba@782: SymEdgeMap(const SymEdgeMap& copy) \ deba@782: : MapImpl(static_cast(copy)) {} \ deba@782: template SymEdgeMap(const CMap& copy) : MapImpl(copy) {} \ deba@782: SymEdgeMap& operator=(const SymEdgeMap& copy) { \ deba@782: MapImpl::operator=(static_cast(copy));\ deba@782: return *this; \ deba@782: } \ deba@782: template SymEdgeMap& operator=(const CMap& copy) { \ deba@782: MapImpl::operator=(copy);\ deba@782: return *this; \ deba@782: } \ deba@782: }; deba@782: deba@782: deba@782: #define KEEP_NODE_MAP(GraphBase) \ deba@782: template class NodeMap \ deba@782: : public GraphBase::template NodeMap \ deba@782: { \ deba@782: typedef typename GraphBase::template NodeMap MapImpl; \ deba@782: typedef V Value; \ deba@782: public: \ deba@782: NodeMap() : MapImpl() {} \ deba@782: \ deba@782: NodeMap(const Graph& graph) \ deba@782: : MapImpl(static_cast(graph)) { } \ deba@782: \ deba@782: NodeMap(const Graph& graph, const Value& value) \ deba@782: : MapImpl(static_cast(graph), value) { } \ deba@782: \ deba@782: NodeMap(const NodeMap& copy) \ deba@782: : MapImpl(static_cast(copy)) {} \ deba@782: \ deba@782: template \ deba@782: NodeMap(const CMap& copy) \ deba@782: : MapImpl(copy) {} \ deba@782: \ deba@782: NodeMap& operator=(const NodeMap& copy) { \ deba@782: MapImpl::operator=(static_cast(copy)); \ deba@782: return *this; \ deba@782: } \ deba@782: \ deba@782: template \ deba@782: NodeMap& operator=(const CMap& copy) { \ deba@782: MapImpl::operator=(copy); \ deba@782: return *this; \ deba@782: } \ deba@782: }; deba@782: deba@782: #define KEEP_EDGE_MAP(GraphBase) \ deba@782: template class EdgeMap \ deba@782: : public GraphBase::template EdgeMap \ deba@782: { \ deba@782: typedef typename GraphBase::template EdgeMap MapImpl; \ deba@782: typedef V Value; \ deba@782: public: \ deba@782: EdgeMap() : MapImpl() {} \ deba@782: \ deba@782: EdgeMap(const Graph& graph) \ deba@782: : MapImpl(static_cast(graph)) { } \ deba@782: \ deba@782: EdgeMap(const Graph& graph, const Value& value) \ deba@782: : MapImpl(static_cast(graph), value) { } \ deba@782: \ deba@782: EdgeMap(const EdgeMap& copy) \ deba@782: : MapImpl(static_cast(copy)) {} \ deba@782: \ deba@782: template \ deba@782: EdgeMap(const CMap& copy) \ deba@782: : MapImpl(copy) {} \ deba@782: \ deba@782: EdgeMap& operator=(const EdgeMap& copy) { \ deba@782: MapImpl::operator=(static_cast(copy)); \ deba@782: return *this; \ deba@782: } \ deba@782: \ deba@782: template \ deba@782: EdgeMap& operator=(const CMap& copy) { \ deba@782: MapImpl::operator=(copy); \ deba@782: return *this; \ deba@782: } \ deba@782: }; deba@782: alpar@785: alpar@785: /// @} alpar@785: deba@782: #endif