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 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 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 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 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 \ deba@674: class NodeMap : public Factory::Map { \ deba@674: public: \ deba@674: NodeMap() {} \ deba@701: NodeMap(const Graph& g) : Factory::Map(&g, &(g.node_maps)) {} \ deba@701: NodeMap(const Graph& g, const V& v) : Factory::Map(g, g.node_maps, v) {} \ deba@703: NodeMap(const NodeMap& copy) \ deba@703: : Factory::Map(static_cast&>(copy)) {} \ deba@701: template NodeMap(const CMap& copy) : Factory::Map(copy) {} \ deba@701: NodeMap& operator=(const NodeMap& copy) { \ deba@703: this->Factory::Map::operator=(static_cast&>(copy)); \ deba@701: return *this; \ deba@701: } \ deba@701: template NodeMap& operator=(const CMap& copy) { \ deba@701: this->Factory::Map::operator=(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 \ deba@674: class EdgeMap : public Factory::Map { \ deba@674: public: \ deba@674: EdgeMap() {} \ deba@701: EdgeMap(const Graph& g) : Factory::Map(g, g.edge_maps) {} \ deba@701: EdgeMap(const Graph& g, const V& v) : Factory::Map(g, g.node_maps, v) {} \ deba@703: EdgeMap(const EdgeMap& copy) \ deba@703: : Factory::Map(static_cast&>(copy)) {} \ deba@701: template EdgeMap(const CMap& copy) : Factory::Map(copy) {} \ deba@701: EdgeMap& operator=(const EdgeMap& copy) { \ deba@703: this->Factory::Map::operator=(static_cast&>(copy)); \ deba@701: return *this; \ deba@701: } \ deba@701: template EdgeMap& operator=(const CMap& copy) { \ deba@701: this->Factory::Map::operator=(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