src/work/deba/map_defines.h
author deba
Wed, 14 Jul 2004 21:16:10 +0000
changeset 702 4207f82a1778
parent 676 7ec5e7e6c7b4
child 703 32f280a5ed7d
permissions -rw-r--r--
(none)
alpar@676
     1
// -*- c++ -*-
deba@674
     2
#ifndef MAP_DEFINES_H
deba@674
     3
#define MAP_DEFINES_H
deba@674
     4
deba@701
     5
/** Creates the EdgeMapRegistry type an declare a mutable instance 
deba@701
     6
 *  named edge_maps.
deba@701
     7
 */
deba@674
     8
#define CREATE_EDGE_MAP_REGISTRY \
deba@674
     9
typedef MapRegistry<Graph, Edge, EdgeIt> EdgeMapRegistry; \
deba@701
    10
mutable EdgeMapRegistry edge_maps;
deba@674
    11
deba@701
    12
/** Creates the NodeMapRegistry type an declare a mutable instance 
deba@701
    13
 *  named node_maps.
deba@701
    14
 */
deba@674
    15
#define CREATE_NODE_MAP_REGISTRY \
deba@674
    16
typedef MapRegistry<Graph, Node, NodeIt> NodeMapRegistry; \
deba@701
    17
mutable NodeMapRegistry node_maps;
deba@674
    18
deba@701
    19
/** Creates both map registries.
deba@701
    20
 */
deba@674
    21
#define CREATE_MAP_REGISTRIES \
deba@674
    22
CREATE_NODE_MAP_REGISTRY \
deba@674
    23
CREATE_EDGE_MAP_REGISTRY
deba@674
    24
deba@701
    25
/** Creates a map a concrete factory type from a template map
deba@701
    26
 *  factory to use as node map factory.
deba@701
    27
 */
deba@674
    28
#define CREATE_NODE_MAP_FACTORY(TemplateFactory) \
deba@674
    29
typedef TemplateFactory<NodeMapRegistry> NodeMapFactory;
deba@674
    30
deba@701
    31
/** Creates a map a concrete factory type from a template map
deba@701
    32
 *  factory to use as edge map factory.
deba@701
    33
 */
deba@674
    34
#define CREATE_EDGE_MAP_FACTORY(TemplateFactory) \
deba@674
    35
typedef TemplateFactory<EdgeMapRegistry> EdgeMapFactory;
deba@674
    36
deba@701
    37
/** Creates both map factories.
deba@701
    38
 */
deba@674
    39
#define CREATE_MAP_FACTORIES(TemplateFactory) \
deba@674
    40
CREATE_NODE_MAP_FACTORY(TemplateFactory) \
deba@674
    41
CREATE_EDGE_MAP_FACTORY(TemplateFactory) 
deba@674
    42
deba@701
    43
/** Import a map from a concrete map factory. The import method is
deba@701
    44
 *  an overloading of the map type.
deba@701
    45
 *  The reason to use these macro is that the c++ does not support
deba@701
    46
 *  the template typedefs. If a future release of the c++ 
deba@701
    47
 *  supports this feature it should be fixed.
deba@701
    48
 */
deba@674
    49
#define IMPORT_NODE_MAP(Factory) \
deba@674
    50
template <typename V> \
deba@674
    51
class NodeMap : public Factory::Map<V> { \
deba@674
    52
public: \
deba@674
    53
NodeMap() {} \
deba@701
    54
NodeMap(const Graph& g) : Factory::Map<V>(&g, &(g.node_maps)) {} \
deba@701
    55
NodeMap(const Graph& g, const V& v) : Factory::Map<V>(g, g.node_maps, v) {} \
deba@701
    56
NodeMap(const NodeMap& copy) : Factory::Map<V>(copy) {} \
deba@701
    57
template <typename CMap> NodeMap(const CMap& copy) : Factory::Map<V>(copy) {} \
deba@701
    58
NodeMap& operator=(const NodeMap& copy) { \
deba@701
    59
  this->Factory::Map<V>::operator=(copy); \
deba@701
    60
  return *this; \
deba@701
    61
} \
deba@701
    62
template <typename CMap>NodeMap& operator=(const CMap& copy) { \
deba@701
    63
  this->Factory::Map<V>::operator=<CMap>(copy); \
deba@701
    64
  return *this; \
deba@701
    65
} \
deba@674
    66
};
deba@674
    67
deba@701
    68
/** Import a map from a concrete map factory. The import method is
deba@701
    69
 *  an overloading of the map type.
deba@701
    70
 *  The reason to use these macro is that the c++ does not support
deba@701
    71
 *  the template typedefs. If a future release of the c++ 
deba@701
    72
 *  supports this feature it should be fixed.
deba@701
    73
 */
deba@674
    74
#define IMPORT_EDGE_MAP(Factory) \
deba@674
    75
template <typename V> \
deba@674
    76
class EdgeMap : public Factory::Map<V> { \
deba@674
    77
public: \
deba@674
    78
EdgeMap() {} \
deba@701
    79
EdgeMap(const Graph& g) : Factory::Map<V>(g, g.edge_maps) {} \
deba@701
    80
EdgeMap(const Graph& g, const V& v) : Factory::Map<V>(g, g.node_maps, v) {} \
deba@701
    81
EdgeMap(const EdgeMap& copy) : Factory::Map<V>(copy) {} \
deba@701
    82
template <typename CMap> EdgeMap(const CMap& copy) : Factory::Map<V>(copy) {} \
deba@701
    83
EdgeMap& operator=(const EdgeMap& copy) { \
deba@701
    84
  this->Factory::Map<V>::operator=(copy); \
deba@701
    85
  return *this; \
deba@701
    86
} \
deba@701
    87
template <typename CMap>EdgeMap& operator=(const CMap& copy) { \
deba@701
    88
  this->Factory::Map<V>::operator=<CMap>(copy); \
deba@701
    89
  return *this; \
deba@701
    90
} \
deba@674
    91
};
deba@674
    92
deba@701
    93
/** This macro creates both map factories and imports both maps.
deba@701
    94
 */
deba@674
    95
#define CREATE_MAPS(TemplateFactory) \
deba@674
    96
CREATE_MAP_FACTORIES(TemplateFactory) \
deba@674
    97
IMPORT_NODE_MAP(NodeMapFactory) \
deba@674
    98
IMPORT_EDGE_MAP(EdgeMapFactory)
deba@674
    99
deba@674
   100
#endif