src/work/deba/map_defines.h
author alpar
Thu, 07 Apr 2005 11:30:12 +0000
changeset 1317 83f80464f111
parent 703 32f280a5ed7d
permissions -rw-r--r--
- XMap and YMap added
- Spell checking
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@703
    56
NodeMap(const NodeMap& copy) \
deba@703
    57
  : Factory::Map<V>(static_cast<const Factory::Map<V>&>(copy)) {} \
deba@701
    58
template <typename CMap> NodeMap(const CMap& copy) : Factory::Map<V>(copy) {} \
deba@701
    59
NodeMap& operator=(const NodeMap& copy) { \
deba@703
    60
  this->Factory::Map<V>::operator=(static_cast<Factory::Map<V>&>(copy)); \
deba@701
    61
  return *this; \
deba@701
    62
} \
deba@701
    63
template <typename CMap>NodeMap& operator=(const CMap& copy) { \
deba@783
    64
  this->Factory::Map<V>::operator=<CMap>(static_cast<Factory::Map<V>&>(copy));\
deba@701
    65
  return *this; \
deba@701
    66
} \
deba@674
    67
};
deba@674
    68
deba@701
    69
/** Import a map from a concrete map factory. The import method is
deba@701
    70
 *  an overloading of the map type.
deba@701
    71
 *  The reason to use these macro is that the c++ does not support
deba@701
    72
 *  the template typedefs. If a future release of the c++ 
deba@701
    73
 *  supports this feature it should be fixed.
deba@701
    74
 */
deba@674
    75
#define IMPORT_EDGE_MAP(Factory) \
deba@674
    76
template <typename V> \
deba@674
    77
class EdgeMap : public Factory::Map<V> { \
deba@674
    78
public: \
deba@674
    79
EdgeMap() {} \
deba@701
    80
EdgeMap(const Graph& g) : Factory::Map<V>(g, g.edge_maps) {} \
deba@701
    81
EdgeMap(const Graph& g, const V& v) : Factory::Map<V>(g, g.node_maps, v) {} \
deba@703
    82
EdgeMap(const EdgeMap& copy) \
deba@703
    83
  : Factory::Map<V>(static_cast<Factory::Map<V>&>(copy)) {} \
deba@701
    84
template <typename CMap> EdgeMap(const CMap& copy) : Factory::Map<V>(copy) {} \
deba@701
    85
EdgeMap& operator=(const EdgeMap& copy) { \
deba@703
    86
  this->Factory::Map<V>::operator=(static_cast<Factory::Map<V>&>(copy)); \
deba@701
    87
  return *this; \
deba@701
    88
} \
deba@701
    89
template <typename CMap>EdgeMap& operator=(const CMap& copy) { \
deba@783
    90
  this->Factory::Map<V>::operator=<CMap>(static_cast<Factory::Map<V>&>(copy));\
deba@701
    91
  return *this; \
deba@701
    92
} \
deba@674
    93
};
deba@674
    94
deba@701
    95
/** This macro creates both map factories and imports both maps.
deba@701
    96
 */
deba@674
    97
#define CREATE_MAPS(TemplateFactory) \
deba@674
    98
CREATE_MAP_FACTORIES(TemplateFactory) \
deba@674
    99
IMPORT_NODE_MAP(NodeMapFactory) \
deba@674
   100
IMPORT_EDGE_MAP(EdgeMapFactory)
deba@674
   101
deba@674
   102
#endif