src/hugo/map_defines.h
author alpar
Thu, 02 Sep 2004 17:11:04 +0000
changeset 790 2b9a43c0d64e
parent 782 df2e45e09652
child 822 88226d9fe821
permissions -rw-r--r--
- 'minlengpaths_test.cc' added.
- Path tests in 'minlengpaths_test.cc' are swithced out.
deba@782
     1
// -*- c++ -*-
deba@782
     2
#ifndef MAP_DEFINES_H
deba@782
     3
#define MAP_DEFINES_H
deba@782
     4
alpar@785
     5
///\ingroup graphmapfactory
alpar@785
     6
///\file
alpar@785
     7
///\brief Defines to help creating graph maps.
alpar@785
     8
alpar@785
     9
/// \addtogroup graphmapfactory
alpar@785
    10
/// @{
alpar@785
    11
deba@782
    12
/** Creates the EdgeMapRegistry type an declare a mutable instance 
deba@782
    13
 *  named edge_maps.
deba@782
    14
 */
deba@782
    15
#define CREATE_EDGE_MAP_REGISTRY \
deba@782
    16
typedef MapRegistry<Graph, Edge, EdgeIt> EdgeMapRegistry; \
deba@782
    17
mutable EdgeMapRegistry edge_maps;
deba@782
    18
deba@782
    19
/** Creates the NodeMapRegistry type an declare a mutable instance 
deba@782
    20
 *  named node_maps.
deba@782
    21
 */
deba@782
    22
#define CREATE_NODE_MAP_REGISTRY \
deba@782
    23
typedef MapRegistry<Graph, Node, NodeIt> NodeMapRegistry; \
deba@782
    24
mutable NodeMapRegistry node_maps;
deba@782
    25
deba@782
    26
/** Creates both map registries.
deba@782
    27
 */
deba@782
    28
#define CREATE_MAP_REGISTRIES \
deba@782
    29
CREATE_NODE_MAP_REGISTRY \
deba@782
    30
CREATE_EDGE_MAP_REGISTRY
deba@782
    31
deba@782
    32
/** Creates a concrete factory type from a template map
deba@782
    33
 *  factory to use as node map factory.
deba@782
    34
 */
deba@782
    35
#define CREATE_NODE_MAP_FACTORY(TemplateFactory) \
deba@782
    36
typedef TemplateFactory<NodeMapRegistry> NodeMapFactory;
deba@782
    37
deba@782
    38
/** Creates a concrete factory type from a template map
deba@782
    39
 *  factory to use as edge map factory.
deba@782
    40
 */
deba@782
    41
#define CREATE_EDGE_MAP_FACTORY(TemplateFactory) \
deba@782
    42
typedef TemplateFactory<EdgeMapRegistry> EdgeMapFactory;
deba@782
    43
deba@782
    44
/** Creates both map factories.
deba@782
    45
 */
deba@782
    46
#define CREATE_MAP_FACTORIES(TemplateFactory) \
deba@782
    47
CREATE_NODE_MAP_FACTORY(TemplateFactory) \
deba@782
    48
CREATE_EDGE_MAP_FACTORY(TemplateFactory) 
deba@782
    49
deba@782
    50
/** Import a map from a concrete map factory. The import method is
deba@782
    51
 *  an overloading of the map type.
deba@782
    52
 *  The reason to use these macro is that the c++ does not support
deba@782
    53
 *  the template typedefs. If a future release of the c++ 
deba@782
    54
 *  supports this feature it should be fixed.
deba@782
    55
 */
deba@782
    56
#define IMPORT_NODE_MAP(Factory) \
deba@782
    57
template <typename V> \
deba@782
    58
class NodeMap : public Factory::template Map<V> { \
deba@782
    59
typedef typename Factory::template Map<V> MapImpl; \
deba@782
    60
public: \
deba@782
    61
NodeMap() {} \
deba@782
    62
NodeMap(const Graph& g) : MapImpl(g, g.node_maps) {} \
deba@782
    63
NodeMap(const Graph& g, const V& v) : MapImpl(g, g.node_maps, v) {} \
deba@782
    64
NodeMap(const NodeMap& copy) : MapImpl(static_cast<const MapImpl&>(copy)) {} \
deba@782
    65
template <typename CMap> NodeMap(const CMap& copy) : MapImpl(copy) {} \
deba@782
    66
NodeMap& operator=(const NodeMap& copy) { \
deba@782
    67
  MapImpl::operator=(static_cast<const MapImpl&>(copy));\
deba@782
    68
  return *this; \
deba@782
    69
} \
deba@782
    70
template <typename CMap> NodeMap& operator=(const CMap& copy) { \
deba@782
    71
  MapImpl::operator=(copy);\
deba@782
    72
  return *this; \
deba@782
    73
} \
deba@782
    74
};
deba@782
    75
deba@782
    76
/** Import a map from a concrete map factory. The import method is
deba@782
    77
 *  an overloading of the map type.
deba@782
    78
 *  The reason to use these macro is that the c++ does not support
deba@782
    79
 *  the template typedefs. If a future release of the c++ 
deba@782
    80
 *  supports this feature it should be fixed.
deba@782
    81
 */
deba@782
    82
#define IMPORT_EDGE_MAP(Factory) \
deba@782
    83
template <typename V> \
deba@782
    84
class EdgeMap : public Factory::template Map<V> { \
deba@782
    85
typedef typename Factory::template Map<V> MapImpl; \
deba@782
    86
public: \
deba@782
    87
EdgeMap() {} \
deba@782
    88
EdgeMap(const Graph& g) : MapImpl(g, g.edge_maps) {} \
deba@782
    89
EdgeMap(const Graph& g, const V& v) : MapImpl(g, g.edge_maps, v) {} \
deba@782
    90
EdgeMap(const EdgeMap& copy) : MapImpl(static_cast<const MapImpl&>(copy)) {} \
deba@782
    91
template <typename CMap> EdgeMap(const CMap& copy) : MapImpl(copy) {} \
deba@782
    92
EdgeMap& operator=(const EdgeMap& copy) { \
deba@782
    93
  MapImpl::operator=(static_cast<const MapImpl&>(copy));\
deba@782
    94
  return *this; \
deba@782
    95
} \
deba@782
    96
template <typename CMap> EdgeMap& operator=(const CMap& copy) { \
deba@782
    97
  MapImpl::operator=(copy);\
deba@782
    98
  return *this; \
deba@782
    99
} \
deba@782
   100
};
deba@782
   101
deba@782
   102
/** This macro creates both map factories and imports both maps.
deba@782
   103
 */
deba@782
   104
#define CREATE_MAPS(TemplateFactory) \
deba@782
   105
CREATE_MAP_FACTORIES(TemplateFactory) \
deba@782
   106
IMPORT_NODE_MAP(NodeMapFactory) \
deba@782
   107
IMPORT_EDGE_MAP(EdgeMapFactory)
deba@782
   108
deba@782
   109
/** This macro creates MapRegistry for Symmetric Edge Maps.
deba@782
   110
 */
deba@782
   111
#define CREATE_SYM_EDGE_MAP_REGISTRY \
deba@782
   112
typedef SymEdgeIt<Graph, Edge, EdgeIt> SymEdgeIt; \
deba@782
   113
typedef MapRegistry<Graph, Edge, SymEdgeIt> SymEdgeMapRegistry; \
deba@782
   114
mutable EdgeMapRegistry sym_edge_maps;
deba@782
   115
deba@782
   116
/** Creates a concrete factory type from a template map
deba@782
   117
 *  factory to use as edge map factory.
deba@782
   118
 */
deba@782
   119
#define CREATE_SYM_EDGE_MAP_FACTORY(TemplateFactory) \
deba@782
   120
typedef SymMapFactory<SymEdgeMapRegistry, TemplateFactory > \
deba@782
   121
SymEdgeMapFactory;
deba@782
   122
deba@782
   123
/** Import a map from a concrete map factory. The import method is
deba@782
   124
 *  an overloading of the map type.
deba@782
   125
 *  The reason to use these macro is that the c++ does not support
deba@782
   126
 *  the template typedefs. If a future release of the c++ 
deba@782
   127
 *  supports this feature it should be fixed.
deba@782
   128
 */
deba@782
   129
#define IMPORT_SYM_EDGE_MAP(Factory) \
deba@782
   130
template <typename V> \
deba@782
   131
class SymEdgeMap : public Factory::template Map<V> { \
deba@782
   132
typedef typename Factory::template Map<V> MapImpl; \
deba@782
   133
public: \
deba@782
   134
SymEdgeMap() {} \
deba@782
   135
SymEdgeMap(const Graph& g) : MapImpl(g, g.sym_edge_maps) {} \
deba@782
   136
SymEdgeMap(const Graph& g, const V& v) : MapImpl(g, g.sym_edge_maps, v) {} \
deba@782
   137
SymEdgeMap(const SymEdgeMap& copy) \
deba@782
   138
  : MapImpl(static_cast<const MapImpl&>(copy)) {} \
deba@782
   139
template <typename CMap> SymEdgeMap(const CMap& copy) : MapImpl(copy) {} \
deba@782
   140
SymEdgeMap& operator=(const SymEdgeMap& copy) { \
deba@782
   141
  MapImpl::operator=(static_cast<const MapImpl&>(copy));\
deba@782
   142
  return *this; \
deba@782
   143
} \
deba@782
   144
template <typename CMap> SymEdgeMap& operator=(const CMap& copy) { \
deba@782
   145
  MapImpl::operator=(copy);\
deba@782
   146
  return *this; \
deba@782
   147
} \
deba@782
   148
};
deba@782
   149
deba@782
   150
deba@782
   151
#define KEEP_NODE_MAP(GraphBase) \
deba@782
   152
    template <typename V> class NodeMap \
deba@782
   153
      : public GraphBase::template NodeMap<V> \
deba@782
   154
    { \
deba@782
   155
      typedef typename GraphBase::template NodeMap<V> MapImpl; \
deba@782
   156
      typedef V Value; \
deba@782
   157
    public: \
deba@782
   158
      NodeMap() : MapImpl() {} \
deba@782
   159
\
deba@782
   160
      NodeMap(const Graph& graph) \
deba@782
   161
	: MapImpl(static_cast<const GraphBase&>(graph)) { } \
deba@782
   162
\
deba@782
   163
      NodeMap(const Graph& graph, const Value& value) \
deba@782
   164
	: MapImpl(static_cast<const GraphBase&>(graph), value) { } \
deba@782
   165
\
deba@782
   166
      NodeMap(const NodeMap& copy) \
deba@782
   167
	: MapImpl(static_cast<const MapImpl&>(copy)) {} \
deba@782
   168
\
deba@782
   169
      template<typename CMap> \
deba@782
   170
      NodeMap(const CMap& copy) \
deba@782
   171
	: MapImpl(copy) {} \
deba@782
   172
\
deba@782
   173
      NodeMap& operator=(const NodeMap& copy) { \
deba@782
   174
	MapImpl::operator=(static_cast<const MapImpl&>(copy)); \
deba@782
   175
	return *this; \
deba@782
   176
      } \
deba@782
   177
\
deba@782
   178
      template <typename CMap> \
deba@782
   179
      NodeMap& operator=(const CMap& copy) { \
deba@782
   180
	MapImpl::operator=(copy); \
deba@782
   181
	return *this; \
deba@782
   182
      } \
deba@782
   183
    };
deba@782
   184
deba@782
   185
#define KEEP_EDGE_MAP(GraphBase) \
deba@782
   186
    template <typename V> class EdgeMap \
deba@782
   187
      : public GraphBase::template EdgeMap<V> \
deba@782
   188
    { \
deba@782
   189
      typedef typename GraphBase::template EdgeMap<V> MapImpl; \
deba@782
   190
      typedef V Value; \
deba@782
   191
    public: \
deba@782
   192
      EdgeMap() : MapImpl() {} \
deba@782
   193
\
deba@782
   194
      EdgeMap(const Graph& graph) \
deba@782
   195
	: MapImpl(static_cast<const GraphBase&>(graph)) { } \
deba@782
   196
\
deba@782
   197
      EdgeMap(const Graph& graph, const Value& value) \
deba@782
   198
	: MapImpl(static_cast<const GraphBase&>(graph), value) { } \
deba@782
   199
\
deba@782
   200
      EdgeMap(const EdgeMap& copy) \
deba@782
   201
	: MapImpl(static_cast<const MapImpl&>(copy)) {} \
deba@782
   202
\
deba@782
   203
      template<typename CMap> \
deba@782
   204
      EdgeMap(const CMap& copy) \
deba@782
   205
	: MapImpl(copy) {} \
deba@782
   206
\
deba@782
   207
      EdgeMap& operator=(const EdgeMap& copy) { \
deba@782
   208
	MapImpl::operator=(static_cast<const MapImpl&>(copy)); \
deba@782
   209
	return *this; \
deba@782
   210
      } \
deba@782
   211
\
deba@782
   212
      template <typename CMap> \
deba@782
   213
      EdgeMap& operator=(const CMap& copy) { \
deba@782
   214
	MapImpl::operator=(copy); \
deba@782
   215
	return *this; \
deba@782
   216
      } \
deba@782
   217
    };
deba@782
   218
alpar@785
   219
  
alpar@785
   220
/// @}
alpar@785
   221
  
deba@782
   222
#endif