1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/hugo/map_defines.h Thu Sep 02 10:07:30 2004 +0000
1.3 @@ -0,0 +1,212 @@
1.4 +// -*- c++ -*-
1.5 +#ifndef MAP_DEFINES_H
1.6 +#define MAP_DEFINES_H
1.7 +
1.8 +/** Creates the EdgeMapRegistry type an declare a mutable instance
1.9 + * named edge_maps.
1.10 + */
1.11 +#define CREATE_EDGE_MAP_REGISTRY \
1.12 +typedef MapRegistry<Graph, Edge, EdgeIt> EdgeMapRegistry; \
1.13 +mutable EdgeMapRegistry edge_maps;
1.14 +
1.15 +/** Creates the NodeMapRegistry type an declare a mutable instance
1.16 + * named node_maps.
1.17 + */
1.18 +#define CREATE_NODE_MAP_REGISTRY \
1.19 +typedef MapRegistry<Graph, Node, NodeIt> NodeMapRegistry; \
1.20 +mutable NodeMapRegistry node_maps;
1.21 +
1.22 +/** Creates both map registries.
1.23 + */
1.24 +#define CREATE_MAP_REGISTRIES \
1.25 +CREATE_NODE_MAP_REGISTRY \
1.26 +CREATE_EDGE_MAP_REGISTRY
1.27 +
1.28 +/** Creates a concrete factory type from a template map
1.29 + * factory to use as node map factory.
1.30 + */
1.31 +#define CREATE_NODE_MAP_FACTORY(TemplateFactory) \
1.32 +typedef TemplateFactory<NodeMapRegistry> NodeMapFactory;
1.33 +
1.34 +/** Creates a concrete factory type from a template map
1.35 + * factory to use as edge map factory.
1.36 + */
1.37 +#define CREATE_EDGE_MAP_FACTORY(TemplateFactory) \
1.38 +typedef TemplateFactory<EdgeMapRegistry> EdgeMapFactory;
1.39 +
1.40 +/** Creates both map factories.
1.41 + */
1.42 +#define CREATE_MAP_FACTORIES(TemplateFactory) \
1.43 +CREATE_NODE_MAP_FACTORY(TemplateFactory) \
1.44 +CREATE_EDGE_MAP_FACTORY(TemplateFactory)
1.45 +
1.46 +/** Import a map from a concrete map factory. The import method is
1.47 + * an overloading of the map type.
1.48 + * The reason to use these macro is that the c++ does not support
1.49 + * the template typedefs. If a future release of the c++
1.50 + * supports this feature it should be fixed.
1.51 + */
1.52 +#define IMPORT_NODE_MAP(Factory) \
1.53 +template <typename V> \
1.54 +class NodeMap : public Factory::template Map<V> { \
1.55 +typedef typename Factory::template Map<V> MapImpl; \
1.56 +public: \
1.57 +NodeMap() {} \
1.58 +NodeMap(const Graph& g) : MapImpl(g, g.node_maps) {} \
1.59 +NodeMap(const Graph& g, const V& v) : MapImpl(g, g.node_maps, v) {} \
1.60 +NodeMap(const NodeMap& copy) : MapImpl(static_cast<const MapImpl&>(copy)) {} \
1.61 +template <typename CMap> NodeMap(const CMap& copy) : MapImpl(copy) {} \
1.62 +NodeMap& operator=(const NodeMap& copy) { \
1.63 + MapImpl::operator=(static_cast<const MapImpl&>(copy));\
1.64 + return *this; \
1.65 +} \
1.66 +template <typename CMap> NodeMap& operator=(const CMap& copy) { \
1.67 + MapImpl::operator=(copy);\
1.68 + return *this; \
1.69 +} \
1.70 +};
1.71 +
1.72 +/** Import a map from a concrete map factory. The import method is
1.73 + * an overloading of the map type.
1.74 + * The reason to use these macro is that the c++ does not support
1.75 + * the template typedefs. If a future release of the c++
1.76 + * supports this feature it should be fixed.
1.77 + */
1.78 +#define IMPORT_EDGE_MAP(Factory) \
1.79 +template <typename V> \
1.80 +class EdgeMap : public Factory::template Map<V> { \
1.81 +typedef typename Factory::template Map<V> MapImpl; \
1.82 +public: \
1.83 +EdgeMap() {} \
1.84 +EdgeMap(const Graph& g) : MapImpl(g, g.edge_maps) {} \
1.85 +EdgeMap(const Graph& g, const V& v) : MapImpl(g, g.edge_maps, v) {} \
1.86 +EdgeMap(const EdgeMap& copy) : MapImpl(static_cast<const MapImpl&>(copy)) {} \
1.87 +template <typename CMap> EdgeMap(const CMap& copy) : MapImpl(copy) {} \
1.88 +EdgeMap& operator=(const EdgeMap& copy) { \
1.89 + MapImpl::operator=(static_cast<const MapImpl&>(copy));\
1.90 + return *this; \
1.91 +} \
1.92 +template <typename CMap> EdgeMap& operator=(const CMap& copy) { \
1.93 + MapImpl::operator=(copy);\
1.94 + return *this; \
1.95 +} \
1.96 +};
1.97 +
1.98 +/** This macro creates both map factories and imports both maps.
1.99 + */
1.100 +#define CREATE_MAPS(TemplateFactory) \
1.101 +CREATE_MAP_FACTORIES(TemplateFactory) \
1.102 +IMPORT_NODE_MAP(NodeMapFactory) \
1.103 +IMPORT_EDGE_MAP(EdgeMapFactory)
1.104 +
1.105 +/** This macro creates MapRegistry for Symmetric Edge Maps.
1.106 + */
1.107 +#define CREATE_SYM_EDGE_MAP_REGISTRY \
1.108 +typedef SymEdgeIt<Graph, Edge, EdgeIt> SymEdgeIt; \
1.109 +typedef MapRegistry<Graph, Edge, SymEdgeIt> SymEdgeMapRegistry; \
1.110 +mutable EdgeMapRegistry sym_edge_maps;
1.111 +
1.112 +/** Creates a concrete factory type from a template map
1.113 + * factory to use as edge map factory.
1.114 + */
1.115 +#define CREATE_SYM_EDGE_MAP_FACTORY(TemplateFactory) \
1.116 +typedef SymMapFactory<SymEdgeMapRegistry, TemplateFactory > \
1.117 +SymEdgeMapFactory;
1.118 +
1.119 +/** Import a map from a concrete map factory. The import method is
1.120 + * an overloading of the map type.
1.121 + * The reason to use these macro is that the c++ does not support
1.122 + * the template typedefs. If a future release of the c++
1.123 + * supports this feature it should be fixed.
1.124 + */
1.125 +#define IMPORT_SYM_EDGE_MAP(Factory) \
1.126 +template <typename V> \
1.127 +class SymEdgeMap : public Factory::template Map<V> { \
1.128 +typedef typename Factory::template Map<V> MapImpl; \
1.129 +public: \
1.130 +SymEdgeMap() {} \
1.131 +SymEdgeMap(const Graph& g) : MapImpl(g, g.sym_edge_maps) {} \
1.132 +SymEdgeMap(const Graph& g, const V& v) : MapImpl(g, g.sym_edge_maps, v) {} \
1.133 +SymEdgeMap(const SymEdgeMap& copy) \
1.134 + : MapImpl(static_cast<const MapImpl&>(copy)) {} \
1.135 +template <typename CMap> SymEdgeMap(const CMap& copy) : MapImpl(copy) {} \
1.136 +SymEdgeMap& operator=(const SymEdgeMap& copy) { \
1.137 + MapImpl::operator=(static_cast<const MapImpl&>(copy));\
1.138 + return *this; \
1.139 +} \
1.140 +template <typename CMap> SymEdgeMap& operator=(const CMap& copy) { \
1.141 + MapImpl::operator=(copy);\
1.142 + return *this; \
1.143 +} \
1.144 +};
1.145 +
1.146 +
1.147 +#define KEEP_NODE_MAP(GraphBase) \
1.148 + template <typename V> class NodeMap \
1.149 + : public GraphBase::template NodeMap<V> \
1.150 + { \
1.151 + typedef typename GraphBase::template NodeMap<V> MapImpl; \
1.152 + typedef V Value; \
1.153 + public: \
1.154 + NodeMap() : MapImpl() {} \
1.155 +\
1.156 + NodeMap(const Graph& graph) \
1.157 + : MapImpl(static_cast<const GraphBase&>(graph)) { } \
1.158 +\
1.159 + NodeMap(const Graph& graph, const Value& value) \
1.160 + : MapImpl(static_cast<const GraphBase&>(graph), value) { } \
1.161 +\
1.162 + NodeMap(const NodeMap& copy) \
1.163 + : MapImpl(static_cast<const MapImpl&>(copy)) {} \
1.164 +\
1.165 + template<typename CMap> \
1.166 + NodeMap(const CMap& copy) \
1.167 + : MapImpl(copy) {} \
1.168 +\
1.169 + NodeMap& operator=(const NodeMap& copy) { \
1.170 + MapImpl::operator=(static_cast<const MapImpl&>(copy)); \
1.171 + return *this; \
1.172 + } \
1.173 +\
1.174 + template <typename CMap> \
1.175 + NodeMap& operator=(const CMap& copy) { \
1.176 + MapImpl::operator=(copy); \
1.177 + return *this; \
1.178 + } \
1.179 + };
1.180 +
1.181 +#define KEEP_EDGE_MAP(GraphBase) \
1.182 + template <typename V> class EdgeMap \
1.183 + : public GraphBase::template EdgeMap<V> \
1.184 + { \
1.185 + typedef typename GraphBase::template EdgeMap<V> MapImpl; \
1.186 + typedef V Value; \
1.187 + public: \
1.188 + EdgeMap() : MapImpl() {} \
1.189 +\
1.190 + EdgeMap(const Graph& graph) \
1.191 + : MapImpl(static_cast<const GraphBase&>(graph)) { } \
1.192 +\
1.193 + EdgeMap(const Graph& graph, const Value& value) \
1.194 + : MapImpl(static_cast<const GraphBase&>(graph), value) { } \
1.195 +\
1.196 + EdgeMap(const EdgeMap& copy) \
1.197 + : MapImpl(static_cast<const MapImpl&>(copy)) {} \
1.198 +\
1.199 + template<typename CMap> \
1.200 + EdgeMap(const CMap& copy) \
1.201 + : MapImpl(copy) {} \
1.202 +\
1.203 + EdgeMap& operator=(const EdgeMap& copy) { \
1.204 + MapImpl::operator=(static_cast<const MapImpl&>(copy)); \
1.205 + return *this; \
1.206 + } \
1.207 +\
1.208 + template <typename CMap> \
1.209 + EdgeMap& operator=(const CMap& copy) { \
1.210 + MapImpl::operator=(copy); \
1.211 + return *this; \
1.212 + } \
1.213 + };
1.214 +
1.215 +#endif