src/hugo/map_defines.h
author marci
Thu, 16 Sep 2004 10:59:52 +0000
changeset 862 732f2acb7239
parent 822 88226d9fe821
child 877 66dd225ca128
permissions -rw-r--r--
bug correction
deba@782
     1
// -*- c++ -*-
deba@782
     2
#ifndef MAP_DEFINES_H
deba@782
     3
#define MAP_DEFINES_H
deba@782
     4
deba@822
     5
///\ingroup graphmaps
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@822
    32
/** Creates a map from a template map. The import method is
deba@782
    33
 *  an overloading of the map type.
deba@782
    34
 *  The reason to use these macro is that the c++ does not support
deba@782
    35
 *  the template typedefs. If a future release of the c++ 
deba@782
    36
 *  supports this feature it should be fixed.
deba@782
    37
 */
deba@822
    38
#define CREATE_NODE_MAP(DynMap) \
deba@822
    39
template <typename Value> \
deba@822
    40
class NodeMap : public DynMap<NodeMapRegistry, Value> { \
deba@822
    41
typedef DynMap<NodeMapRegistry, Value> MapImpl; \
deba@782
    42
public: \
deba@782
    43
NodeMap() {} \
deba@822
    44
NodeMap(const typename MapImpl::Graph& g) \
deba@822
    45
  : MapImpl(g, g.node_maps) {} \
deba@822
    46
NodeMap(const typename MapImpl::Graph& g, const Value& v) \
deba@822
    47
  : MapImpl(g, g.node_maps, v) {} \
deba@782
    48
NodeMap(const NodeMap& copy) : MapImpl(static_cast<const MapImpl&>(copy)) {} \
deba@782
    49
template <typename CMap> NodeMap(const CMap& copy) : MapImpl(copy) {} \
deba@782
    50
NodeMap& operator=(const NodeMap& copy) { \
deba@782
    51
  MapImpl::operator=(static_cast<const MapImpl&>(copy));\
deba@782
    52
  return *this; \
deba@782
    53
} \
deba@782
    54
template <typename CMap> NodeMap& operator=(const CMap& copy) { \
deba@782
    55
  MapImpl::operator=(copy);\
deba@782
    56
  return *this; \
deba@782
    57
} \
deba@782
    58
};
deba@782
    59
deba@822
    60
/** Creates a map from a template map. The import method is
deba@782
    61
 *  an overloading of the map type.
deba@782
    62
 *  The reason to use these macro is that the c++ does not support
deba@782
    63
 *  the template typedefs. If a future release of the c++ 
deba@782
    64
 *  supports this feature it should be fixed.
deba@782
    65
 */
deba@822
    66
#define CREATE_EDGE_MAP(DynMap) \
deba@822
    67
template <typename Value> \
deba@822
    68
class EdgeMap : public DynMap<EdgeMapRegistry, Value> { \
deba@822
    69
typedef DynMap<EdgeMapRegistry, Value> MapImpl; \
deba@782
    70
public: \
deba@782
    71
EdgeMap() {} \
deba@822
    72
EdgeMap(const typename MapImpl::Graph& g) \
deba@822
    73
  : MapImpl(g, g.edge_maps) {} \
deba@822
    74
EdgeMap(const typename MapImpl::Graph& g, const Value& v) \
deba@822
    75
  : MapImpl(g, g.edge_maps, v) {} \
deba@782
    76
EdgeMap(const EdgeMap& copy) : MapImpl(static_cast<const MapImpl&>(copy)) {} \
deba@782
    77
template <typename CMap> EdgeMap(const CMap& copy) : MapImpl(copy) {} \
deba@782
    78
EdgeMap& operator=(const EdgeMap& copy) { \
deba@782
    79
  MapImpl::operator=(static_cast<const MapImpl&>(copy));\
deba@782
    80
  return *this; \
deba@782
    81
} \
deba@782
    82
template <typename CMap> EdgeMap& operator=(const CMap& copy) { \
deba@782
    83
  MapImpl::operator=(copy);\
deba@782
    84
  return *this; \
deba@782
    85
} \
deba@782
    86
};
deba@782
    87
deba@822
    88
/** This macro creates both maps.
deba@782
    89
 */
deba@822
    90
#define CREATE_MAPS(DynMap) \
deba@822
    91
CREATE_NODE_MAP(DynMap) \
deba@822
    92
CREATE_EDGE_MAP(DynMap)
deba@782
    93
deba@782
    94
/** This macro creates MapRegistry for Symmetric Edge Maps.
deba@782
    95
 */
deba@782
    96
#define CREATE_SYM_EDGE_MAP_REGISTRY \
deba@782
    97
typedef SymEdgeIt<Graph, Edge, EdgeIt> SymEdgeIt; \
deba@782
    98
typedef MapRegistry<Graph, Edge, SymEdgeIt> SymEdgeMapRegistry; \
deba@844
    99
mutable SymEdgeMapRegistry sym_edge_maps;
deba@782
   100
deba@782
   101
deba@822
   102
/** Creates a map from a template map. The import method is
deba@782
   103
 *  an overloading of the map type.
deba@782
   104
 *  The reason to use these macro is that the c++ does not support
deba@782
   105
 *  the template typedefs. If a future release of the c++ 
deba@782
   106
 *  supports this feature it should be fixed.
deba@782
   107
 */
deba@822
   108
#define CREATE_SYM_EDGE_MAP(DynMap) \
deba@822
   109
template <typename Value> \
deba@822
   110
class SymEdgeMap : public SymMap<DynMap, SymEdgeMapRegistry, Value> { \
deba@822
   111
  typedef SymMap<DynMap, SymEdgeMapRegistry, Value> MapImpl; \
deba@822
   112
 public: \
deba@822
   113
\
deba@822
   114
  SymEdgeMap() {} \
deba@822
   115
\
deba@822
   116
  SymEdgeMap(const typename MapImpl::Graph& g) \
deba@822
   117
    : MapImpl(g, g.sym_edge_maps) {} \
deba@822
   118
\
deba@822
   119
  SymEdgeMap(const typename MapImpl::Graph& g, const Value& v) \
deba@822
   120
    : MapImpl(g, g.sym_edge_maps, v) {} \
deba@822
   121
\
deba@822
   122
  SymEdgeMap(const SymEdgeMap& copy) \
deba@822
   123
    : MapImpl(static_cast<const MapImpl&>(copy)) {} \
deba@822
   124
\
deba@822
   125
  template <typename CMap> SymEdgeMap(const CMap& copy) : MapImpl(copy) {} \
deba@822
   126
  SymEdgeMap& operator=(const SymEdgeMap& copy) { \
deba@822
   127
    MapImpl::operator=(static_cast<const MapImpl&>(copy));\
deba@822
   128
    return *this; \
deba@822
   129
  } \
deba@822
   130
\
deba@822
   131
  template <typename CMap> SymEdgeMap& operator=(const CMap& copy) { \
deba@822
   132
    MapImpl::operator=(copy);\
deba@822
   133
    return *this; \
deba@822
   134
  } \
deba@782
   135
};
deba@782
   136
deba@782
   137
deba@822
   138
/** This is a macro to import an node map into a graph class.
deba@822
   139
 */
deba@822
   140
#define IMPORT_NODE_MAP(From, from, To, to) \
deba@822
   141
template <typename Value> \
deba@822
   142
class NodeMap \
deba@822
   143
  : public From::template NodeMap<Value> { \
deba@822
   144
  typedef typename From::template NodeMap<Value> MapImpl; \
deba@822
   145
 public: \
deba@822
   146
   NodeMap() : MapImpl() {} \
deba@782
   147
\
deba@822
   148
   NodeMap(const To& to) \
deba@822
   149
     : MapImpl(static_cast<const From&>(from)) { } \
deba@782
   150
\
deba@822
   151
   NodeMap(const To& to, const Value& value) \
deba@822
   152
     : MapImpl(static_cast<const From&>(from), value) { } \
deba@782
   153
\
deba@822
   154
   NodeMap(const NodeMap& copy) \
deba@822
   155
     : MapImpl(static_cast<const MapImpl&>(copy)) {} \
deba@782
   156
\
deba@822
   157
   template<typename CMap> \
deba@822
   158
   NodeMap(const CMap& copy) \
deba@822
   159
     : MapImpl(copy) {} \
deba@782
   160
\
deba@822
   161
   NodeMap& operator=(const NodeMap& copy) { \
deba@822
   162
     MapImpl::operator=(static_cast<const MapImpl&>(copy)); \
deba@822
   163
     return *this; \
deba@822
   164
   } \
deba@782
   165
\
deba@822
   166
   template <typename CMap> \
deba@822
   167
   NodeMap& operator=(const CMap& copy) { \
deba@822
   168
     MapImpl::operator=(copy); \
deba@822
   169
     return *this; \
deba@822
   170
   } \
deba@822
   171
};
deba@782
   172
deba@822
   173
/** This is a macro to import an edge map into a graph class.
deba@822
   174
 */
deba@822
   175
#define IMPORT_EDGE_MAP(From, from, To, to) \
deba@822
   176
template <typename Value> \
deba@822
   177
class EdgeMap \
deba@822
   178
  : public From::template EdgeMap<Value> { \
deba@822
   179
  typedef typename From::template EdgeMap<Value> MapImpl; \
deba@822
   180
 public: \
deba@822
   181
   EdgeMap() : MapImpl() {} \
deba@782
   182
\
deba@822
   183
   EdgeMap(const To& to) \
deba@822
   184
     : MapImpl(static_cast<const From&>(from)) { } \
deba@782
   185
\
deba@822
   186
   EdgeMap(const To& to, const Value& value) \
deba@822
   187
     : MapImpl(static_cast<const From&>(from), value) { } \
deba@782
   188
\
deba@822
   189
   EdgeMap(const EdgeMap& copy) \
deba@822
   190
     : MapImpl(static_cast<const MapImpl&>(copy)) {} \
deba@782
   191
\
deba@822
   192
   template<typename CMap> \
deba@822
   193
   EdgeMap(const CMap& copy) \
deba@822
   194
     : MapImpl(copy) {} \
deba@782
   195
\
deba@822
   196
   EdgeMap& operator=(const EdgeMap& copy) { \
deba@822
   197
     MapImpl::operator=(static_cast<const MapImpl&>(copy)); \
deba@822
   198
     return *this; \
deba@822
   199
   } \
deba@782
   200
\
deba@822
   201
   template <typename CMap> \
deba@822
   202
   EdgeMap& operator=(const CMap& copy) { \
deba@822
   203
     MapImpl::operator=(copy); \
deba@822
   204
     return *this; \
deba@822
   205
   } \
deba@822
   206
};
deba@782
   207
deba@822
   208
deba@822
   209
/** This is a macro to keep the node and edge maps for a graph class.
deba@822
   210
 */
deba@822
   211
#define KEEP_MAPS(From, To) \
deba@822
   212
IMPORT_EDGE_MAP(From, graph, To, graph) \
deba@822
   213
IMPORT_NODE_MAP(From, graph, To, graph)
alpar@785
   214
  
alpar@785
   215
/// @}
alpar@785
   216
  
deba@782
   217
#endif