// -*- c++ -*- #ifndef MAP_DEFINES_H #define MAP_DEFINES_H /** 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 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 map 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::Map { \ public: \ NodeMap() {} \ NodeMap(const Graph& g) : Factory::Map(&g, &(g.node_maps)) {} \ NodeMap(const Graph& g, const V& v) : Factory::Map(g, g.node_maps, v) {} \ NodeMap(const NodeMap& copy) \ : Factory::Map(static_cast&>(copy)) {} \ template NodeMap(const CMap& copy) : Factory::Map(copy) {} \ NodeMap& operator=(const NodeMap& copy) { \ this->Factory::Map::operator=(static_cast&>(copy)); \ return *this; \ } \ template NodeMap& operator=(const CMap& copy) { \ this->Factory::Map::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::Map { \ public: \ EdgeMap() {} \ EdgeMap(const Graph& g) : Factory::Map(g, g.edge_maps) {} \ EdgeMap(const Graph& g, const V& v) : Factory::Map(g, g.node_maps, v) {} \ EdgeMap(const EdgeMap& copy) \ : Factory::Map(static_cast&>(copy)) {} \ template EdgeMap(const CMap& copy) : Factory::Map(copy) {} \ EdgeMap& operator=(const EdgeMap& copy) { \ this->Factory::Map::operator=(static_cast&>(copy)); \ return *this; \ } \ template EdgeMap& operator=(const CMap& copy) { \ this->Factory::Map::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) #endif