src/hugo/map_defines.h
author alpar
Thu, 23 Sep 2004 15:09:55 +0000
changeset 907 df8472ab5d4a
parent 901 69a8e672acb1
child 909 6a22e0dfd453
permissions -rw-r--r--
I forgot to apply
for i in `ls *.h`; do rpl template.h $i $i; done
in src/hugo/attic
alpar@906
     1
/* -*- C++ -*-
alpar@906
     2
 * src/hugo/map_defines.h - Part of HUGOlib, a generic C++ optimization library
alpar@906
     3
 *
alpar@906
     4
 * Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
alpar@906
     5
 * (Egervary Combinatorial Optimization Research Group, EGRES).
alpar@906
     6
 *
alpar@906
     7
 * Permission to use, modify and distribute this software is granted
alpar@906
     8
 * provided that this copyright notice appears in all copies. For
alpar@906
     9
 * precise terms see the accompanying LICENSE file.
alpar@906
    10
 *
alpar@906
    11
 * This software is provided "AS IS" with no warranty of any kind,
alpar@906
    12
 * express or implied, and with no claim as to its suitability for any
alpar@906
    13
 * purpose.
alpar@906
    14
 *
alpar@906
    15
 */
alpar@906
    16
marci@901
    17
#ifndef HUGO_MAP_DEFINES_H
marci@901
    18
#define HUGO_MAP_DEFINES_H
deba@782
    19
deba@822
    20
///\ingroup graphmaps
alpar@785
    21
///\file
alpar@785
    22
///\brief Defines to help creating graph maps.
alpar@785
    23
alpar@785
    24
/// \addtogroup graphmapfactory
alpar@785
    25
/// @{
alpar@785
    26
deba@782
    27
/** Creates the EdgeMapRegistry type an declare a mutable instance 
deba@782
    28
 *  named edge_maps.
deba@782
    29
 */
deba@782
    30
#define CREATE_EDGE_MAP_REGISTRY \
deba@782
    31
typedef MapRegistry<Graph, Edge, EdgeIt> EdgeMapRegistry; \
deba@782
    32
mutable EdgeMapRegistry edge_maps;
deba@782
    33
deba@782
    34
/** Creates the NodeMapRegistry type an declare a mutable instance 
deba@782
    35
 *  named node_maps.
deba@782
    36
 */
deba@782
    37
#define CREATE_NODE_MAP_REGISTRY \
deba@782
    38
typedef MapRegistry<Graph, Node, NodeIt> NodeMapRegistry; \
deba@782
    39
mutable NodeMapRegistry node_maps;
deba@782
    40
deba@782
    41
/** Creates both map registries.
deba@782
    42
 */
deba@782
    43
#define CREATE_MAP_REGISTRIES \
deba@782
    44
CREATE_NODE_MAP_REGISTRY \
deba@782
    45
CREATE_EDGE_MAP_REGISTRY
deba@782
    46
deba@822
    47
/** Creates a map from a template map. The import method is
deba@782
    48
 *  an overloading of the map type.
deba@782
    49
 *  The reason to use these macro is that the c++ does not support
deba@782
    50
 *  the template typedefs. If a future release of the c++ 
deba@782
    51
 *  supports this feature it should be fixed.
deba@782
    52
 */
deba@822
    53
#define CREATE_NODE_MAP(DynMap) \
deba@822
    54
template <typename Value> \
deba@822
    55
class NodeMap : public DynMap<NodeMapRegistry, Value> { \
deba@782
    56
public: \
deba@891
    57
typedef DynMap<NodeMapRegistry, Value> Parent; \
deba@891
    58
NodeMap(const typename Parent::Graph& g) \
deba@891
    59
  : Parent(g, g.node_maps) {} \
deba@891
    60
NodeMap(const typename Parent::Graph& g, const Value& v) \
deba@891
    61
  : Parent(g, g.node_maps, v) {} \
deba@891
    62
NodeMap(const NodeMap& copy) : Parent(static_cast<const Parent&>(copy)) {} \
deba@891
    63
template <typename TT> \
deba@891
    64
NodeMap(const NodeMap<TT>& copy) \
deba@891
    65
  : Parent(static_cast<const typename NodeMap<TT>::Parent&>(copy)) {} \
deba@782
    66
NodeMap& operator=(const NodeMap& copy) { \
deba@891
    67
  Parent::operator=(static_cast<const Parent&>(copy));\
deba@782
    68
  return *this; \
deba@782
    69
} \
deba@891
    70
template <typename TT> \
deba@891
    71
NodeMap& operator=(const NodeMap<TT>& copy) { \
deba@891
    72
  Parent::operator=(static_cast<const typename NodeMap<TT>::Parent&>(copy));\
deba@782
    73
  return *this; \
deba@782
    74
} \
deba@782
    75
};
deba@782
    76
deba@822
    77
/** Creates a map from a template map. The import method is
deba@782
    78
 *  an overloading of the map type.
deba@782
    79
 *  The reason to use these macro is that the c++ does not support
deba@782
    80
 *  the template typedefs. If a future release of the c++ 
deba@782
    81
 *  supports this feature it should be fixed.
deba@782
    82
 */
deba@822
    83
#define CREATE_EDGE_MAP(DynMap) \
deba@822
    84
template <typename Value> \
deba@822
    85
class EdgeMap : public DynMap<EdgeMapRegistry, Value> { \
deba@782
    86
public: \
deba@891
    87
typedef DynMap<EdgeMapRegistry, Value> Parent; \
deba@891
    88
\
deba@891
    89
EdgeMap(const typename Parent::Graph& g) \
deba@891
    90
  : Parent(g, g.edge_maps) {} \
deba@891
    91
EdgeMap(const typename Parent::Graph& g, const Value& v) \
deba@891
    92
  : Parent(g, g.edge_maps, v) {} \
deba@891
    93
EdgeMap(const EdgeMap& copy) : Parent(static_cast<const Parent&>(copy)) {} \
deba@891
    94
template <typename TT> \
deba@891
    95
EdgeMap(const EdgeMap<TT>& copy) \
deba@891
    96
  : Parent(static_cast<const typename EdgeMap<TT>::Parent&>(copy)) {} \
deba@782
    97
EdgeMap& operator=(const EdgeMap& copy) { \
deba@891
    98
  Parent::operator=(static_cast<const Parent&>(copy));\
deba@782
    99
  return *this; \
deba@782
   100
} \
deba@891
   101
template <typename TT> \
deba@891
   102
EdgeMap& operator=(const EdgeMap<TT>& copy) { \
deba@891
   103
  Parent::operator=(static_cast<const typename EdgeMap<TT>::Parent&>(copy));\
deba@782
   104
  return *this; \
deba@782
   105
} \
deba@782
   106
};
deba@782
   107
deba@822
   108
/** This macro creates both maps.
deba@782
   109
 */
deba@822
   110
#define CREATE_MAPS(DynMap) \
deba@822
   111
CREATE_NODE_MAP(DynMap) \
deba@822
   112
CREATE_EDGE_MAP(DynMap)
deba@782
   113
deba@782
   114
/** This macro creates MapRegistry for Symmetric Edge Maps.
deba@782
   115
 */
deba@782
   116
#define CREATE_SYM_EDGE_MAP_REGISTRY \
deba@782
   117
typedef SymEdgeIt<Graph, Edge, EdgeIt> SymEdgeIt; \
deba@782
   118
typedef MapRegistry<Graph, Edge, SymEdgeIt> SymEdgeMapRegistry; \
deba@844
   119
mutable SymEdgeMapRegistry sym_edge_maps;
deba@782
   120
deba@782
   121
deba@822
   122
/** Creates a map from a template map. The import method is
deba@782
   123
 *  an overloading of the map type.
deba@782
   124
 *  The reason to use these macro is that the c++ does not support
deba@782
   125
 *  the template typedefs. If a future release of the c++ 
deba@782
   126
 *  supports this feature it should be fixed.
deba@782
   127
 */
deba@822
   128
#define CREATE_SYM_EDGE_MAP(DynMap) \
deba@822
   129
template <typename Value> \
deba@822
   130
class SymEdgeMap : public SymMap<DynMap, SymEdgeMapRegistry, Value> { \
deba@891
   131
public: \
deba@891
   132
typedef SymMap<DynMap, SymEdgeMapRegistry, Value> Parent; \
deba@822
   133
\
deba@891
   134
SymEdgeMap(const typename Parent::Graph& g) \
deba@891
   135
  : Parent(g, g.sym_edge_maps) {} \
deba@891
   136
SymEdgeMap(const typename Parent::Graph& g, const Value& v) \
deba@891
   137
  : Parent(g, g.sym_edge_maps, v) {} \
deba@891
   138
SymEdgeMap(const SymEdgeMap& copy) \
deba@891
   139
  : Parent(static_cast<const Parent&>(copy)) {} \
deba@891
   140
template <typename TT> \
deba@891
   141
SymEdgeMap(const NodeMap<TT>& copy) \
deba@891
   142
  : Parent(static_cast<const typename SymEdgeMap<TT>::Parent&>(copy)) {} \
deba@891
   143
SymEdgeMap& operator=(const SymEdgeMap& copy) { \
deba@891
   144
  Parent::operator=(static_cast<const Parent&>(copy));\
deba@891
   145
  return *this; \
deba@891
   146
} \
deba@891
   147
template <typename TT> \
deba@891
   148
SymEdgeMap& operator=(const SymEdgeMap<TT>& copy) { \
deba@891
   149
  Parent::operator=(static_cast<const typename SymEdgeMap<TT>::Parent&>(copy));\
deba@891
   150
  return *this; \
deba@891
   151
} \
deba@782
   152
};
deba@782
   153
deba@822
   154
/** This is a macro to import an node map into a graph class.
deba@822
   155
 */
deba@822
   156
#define IMPORT_NODE_MAP(From, from, To, to) \
deba@822
   157
template <typename Value> \
deba@891
   158
class NodeMap : public From::template NodeMap<Value> { \
deba@782
   159
\
deba@891
   160
public: \
deba@891
   161
typedef typename From::template NodeMap<Value> Parent; \
deba@782
   162
\
deba@891
   163
NodeMap(const To& to) \
deba@891
   164
  : Parent(static_cast<const From&>(from)) { } \
deba@891
   165
NodeMap(const To& to, const Value& value) \
deba@891
   166
  : Parent(static_cast<const From&>(from), value) { } \
deba@891
   167
NodeMap(const NodeMap& copy) \
deba@891
   168
  : Parent(static_cast<const Parent&>(copy)) {} \
deba@891
   169
template <typename TT> \
deba@891
   170
NodeMap(const NodeMap<TT>& copy) \
deba@891
   171
  : Parent(static_cast<const typename NodeMap<TT>::Parent&>(copy)) {} \
deba@891
   172
NodeMap& operator=(const NodeMap& copy) { \
deba@891
   173
  Parent::operator=(static_cast<const Parent&>(copy)); \
deba@891
   174
  return *this; \
deba@891
   175
} \
deba@891
   176
template <typename TT> \
deba@891
   177
NodeMap& operator=(const NodeMap<TT>& copy) { \
deba@891
   178
  Parent::operator=(static_cast<const typename NodeMap<TT>::Parent&>(copy));\
deba@891
   179
  return *this; \
deba@891
   180
} \
deba@822
   181
};
deba@782
   182
deba@822
   183
/** This is a macro to import an edge map into a graph class.
deba@822
   184
 */
deba@822
   185
#define IMPORT_EDGE_MAP(From, from, To, to) \
deba@822
   186
template <typename Value> \
deba@891
   187
class EdgeMap : public From::template EdgeMap<Value> { \
deba@782
   188
\
deba@891
   189
public: \
deba@891
   190
typedef typename From::template EdgeMap<Value> Parent; \
deba@782
   191
\
deba@891
   192
EdgeMap(const To& to) \
deba@891
   193
  : Parent(static_cast<const From&>(from)) { } \
deba@891
   194
EdgeMap(const To& to, const Value& value) \
deba@891
   195
  : Parent(static_cast<const From&>(from), value) { } \
deba@891
   196
EdgeMap(const EdgeMap& copy) \
deba@891
   197
  : Parent(static_cast<const Parent&>(copy)) {} \
deba@891
   198
template <typename TT> \
deba@891
   199
EdgeMap(const EdgeMap<TT>& copy) \
deba@891
   200
  : Parent(static_cast<const typename EdgeMap<TT>::Parent&>(copy)) {} \
deba@891
   201
EdgeMap& operator=(const EdgeMap& copy) { \
deba@891
   202
  Parent::operator=(static_cast<const Parent&>(copy)); \
deba@891
   203
  return *this; \
deba@891
   204
} \
deba@891
   205
template <typename TT> \
deba@891
   206
EdgeMap& operator=(const EdgeMap<TT>& copy) { \
deba@891
   207
  Parent::operator=(static_cast<const typename EdgeMap<TT>::Parent&>(copy));\
deba@891
   208
  return *this; \
deba@891
   209
} \
deba@822
   210
};
deba@782
   211
deba@877
   212
#define KEEP_EDGE_MAP(From, To) \
deba@877
   213
IMPORT_EDGE_MAP(From, graph, To, graph)
deba@877
   214
deba@877
   215
deba@877
   216
#define KEEP_NODE_MAP(From, To) \
deba@877
   217
IMPORT_NODE_MAP(From, graph, To, graph)
deba@822
   218
deba@822
   219
/** This is a macro to keep the node and edge maps for a graph class.
deba@822
   220
 */
deba@822
   221
#define KEEP_MAPS(From, To) \
deba@877
   222
KEEP_EDGE_MAP(From, To) \
deba@877
   223
KEEP_NODE_MAP(From, To)
deba@877
   224
alpar@785
   225
  
alpar@785
   226
/// @}
alpar@785
   227
  
deba@782
   228
#endif