alpar@676: // -*- c++ -*- deba@674: #ifndef MAP_DEFINES_H deba@674: #define MAP_DEFINES_H deba@674: deba@701: /** Creates the EdgeMapRegistry type an declare a mutable instance deba@701: * named edge_maps. deba@701: */ deba@674: #define CREATE_EDGE_MAP_REGISTRY \ deba@674: typedef MapRegistry<Graph, Edge, EdgeIt> EdgeMapRegistry; \ deba@701: mutable EdgeMapRegistry edge_maps; deba@674: deba@701: /** Creates the NodeMapRegistry type an declare a mutable instance deba@701: * named node_maps. deba@701: */ deba@674: #define CREATE_NODE_MAP_REGISTRY \ deba@674: typedef MapRegistry<Graph, Node, NodeIt> NodeMapRegistry; \ deba@701: mutable NodeMapRegistry node_maps; deba@674: deba@701: /** Creates both map registries. deba@701: */ deba@674: #define CREATE_MAP_REGISTRIES \ deba@674: CREATE_NODE_MAP_REGISTRY \ deba@674: CREATE_EDGE_MAP_REGISTRY deba@674: deba@701: /** Creates a map a concrete factory type from a template map deba@701: * factory to use as node map factory. deba@701: */ deba@674: #define CREATE_NODE_MAP_FACTORY(TemplateFactory) \ deba@674: typedef TemplateFactory<NodeMapRegistry> NodeMapFactory; deba@674: deba@701: /** Creates a map a concrete factory type from a template map deba@701: * factory to use as edge map factory. deba@701: */ deba@674: #define CREATE_EDGE_MAP_FACTORY(TemplateFactory) \ deba@674: typedef TemplateFactory<EdgeMapRegistry> EdgeMapFactory; deba@674: deba@701: /** Creates both map factories. deba@701: */ deba@674: #define CREATE_MAP_FACTORIES(TemplateFactory) \ deba@674: CREATE_NODE_MAP_FACTORY(TemplateFactory) \ deba@674: CREATE_EDGE_MAP_FACTORY(TemplateFactory) deba@674: deba@701: /** Import a map from a concrete map factory. The import method is deba@701: * an overloading of the map type. deba@701: * The reason to use these macro is that the c++ does not support deba@701: * the template typedefs. If a future release of the c++ deba@701: * supports this feature it should be fixed. deba@701: */ deba@674: #define IMPORT_NODE_MAP(Factory) \ deba@674: template <typename V> \ deba@674: class NodeMap : public Factory::Map<V> { \ deba@674: public: \ deba@674: NodeMap() {} \ deba@701: NodeMap(const Graph& g) : Factory::Map<V>(&g, &(g.node_maps)) {} \ deba@701: NodeMap(const Graph& g, const V& v) : Factory::Map<V>(g, g.node_maps, v) {} \ deba@703: NodeMap(const NodeMap& copy) \ deba@703: : Factory::Map<V>(static_cast<const Factory::Map<V>&>(copy)) {} \ deba@701: template <typename CMap> NodeMap(const CMap& copy) : Factory::Map<V>(copy) {} \ deba@701: NodeMap& operator=(const NodeMap& copy) { \ deba@703: this->Factory::Map<V>::operator=(static_cast<Factory::Map<V>&>(copy)); \ deba@701: return *this; \ deba@701: } \ deba@701: template <typename CMap>NodeMap& operator=(const CMap& copy) { \ deba@783: this->Factory::Map<V>::operator=<CMap>(static_cast<Factory::Map<V>&>(copy));\ deba@701: return *this; \ deba@701: } \ deba@674: }; deba@674: deba@701: /** Import a map from a concrete map factory. The import method is deba@701: * an overloading of the map type. deba@701: * The reason to use these macro is that the c++ does not support deba@701: * the template typedefs. If a future release of the c++ deba@701: * supports this feature it should be fixed. deba@701: */ deba@674: #define IMPORT_EDGE_MAP(Factory) \ deba@674: template <typename V> \ deba@674: class EdgeMap : public Factory::Map<V> { \ deba@674: public: \ deba@674: EdgeMap() {} \ deba@701: EdgeMap(const Graph& g) : Factory::Map<V>(g, g.edge_maps) {} \ deba@701: EdgeMap(const Graph& g, const V& v) : Factory::Map<V>(g, g.node_maps, v) {} \ deba@703: EdgeMap(const EdgeMap& copy) \ deba@703: : Factory::Map<V>(static_cast<Factory::Map<V>&>(copy)) {} \ deba@701: template <typename CMap> EdgeMap(const CMap& copy) : Factory::Map<V>(copy) {} \ deba@701: EdgeMap& operator=(const EdgeMap& copy) { \ deba@703: this->Factory::Map<V>::operator=(static_cast<Factory::Map<V>&>(copy)); \ deba@701: return *this; \ deba@701: } \ deba@701: template <typename CMap>EdgeMap& operator=(const CMap& copy) { \ deba@783: this->Factory::Map<V>::operator=<CMap>(static_cast<Factory::Map<V>&>(copy));\ deba@701: return *this; \ deba@701: } \ deba@674: }; deba@674: deba@701: /** This macro creates both map factories and imports both maps. deba@701: */ deba@674: #define CREATE_MAPS(TemplateFactory) \ deba@674: CREATE_MAP_FACTORIES(TemplateFactory) \ deba@674: IMPORT_NODE_MAP(NodeMapFactory) \ deba@674: IMPORT_EDGE_MAP(EdgeMapFactory) deba@674: deba@674: #endif