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