src/hugo/map_defines.h
author marci
Wed, 22 Sep 2004 10:47:59 +0000
changeset 901 69a8e672acb1
parent 897 ef09eee53b09
child 906 17f31d280385
permissions -rw-r--r--
correction of HUGO_... preproc defines.
     1 // -*- c++ -*-
     2 #ifndef HUGO_MAP_DEFINES_H
     3 #define HUGO_MAP_DEFINES_H
     4 
     5 ///\ingroup graphmaps
     6 ///\file
     7 ///\brief Defines to help creating graph maps.
     8 
     9 /// \addtogroup graphmapfactory
    10 /// @{
    11 
    12 /** Creates the EdgeMapRegistry type an declare a mutable instance 
    13  *  named edge_maps.
    14  */
    15 #define CREATE_EDGE_MAP_REGISTRY \
    16 typedef MapRegistry<Graph, Edge, EdgeIt> EdgeMapRegistry; \
    17 mutable EdgeMapRegistry edge_maps;
    18 
    19 /** Creates the NodeMapRegistry type an declare a mutable instance 
    20  *  named node_maps.
    21  */
    22 #define CREATE_NODE_MAP_REGISTRY \
    23 typedef MapRegistry<Graph, Node, NodeIt> NodeMapRegistry; \
    24 mutable NodeMapRegistry node_maps;
    25 
    26 /** Creates both map registries.
    27  */
    28 #define CREATE_MAP_REGISTRIES \
    29 CREATE_NODE_MAP_REGISTRY \
    30 CREATE_EDGE_MAP_REGISTRY
    31 
    32 /** Creates a map from a template map. The import method is
    33  *  an overloading of the map type.
    34  *  The reason to use these macro is that the c++ does not support
    35  *  the template typedefs. If a future release of the c++ 
    36  *  supports this feature it should be fixed.
    37  */
    38 #define CREATE_NODE_MAP(DynMap) \
    39 template <typename Value> \
    40 class NodeMap : public DynMap<NodeMapRegistry, Value> { \
    41 public: \
    42 typedef DynMap<NodeMapRegistry, Value> Parent; \
    43 NodeMap(const typename Parent::Graph& g) \
    44   : Parent(g, g.node_maps) {} \
    45 NodeMap(const typename Parent::Graph& g, const Value& v) \
    46   : Parent(g, g.node_maps, v) {} \
    47 NodeMap(const NodeMap& copy) : Parent(static_cast<const Parent&>(copy)) {} \
    48 template <typename TT> \
    49 NodeMap(const NodeMap<TT>& copy) \
    50   : Parent(static_cast<const typename NodeMap<TT>::Parent&>(copy)) {} \
    51 NodeMap& operator=(const NodeMap& copy) { \
    52   Parent::operator=(static_cast<const Parent&>(copy));\
    53   return *this; \
    54 } \
    55 template <typename TT> \
    56 NodeMap& operator=(const NodeMap<TT>& copy) { \
    57   Parent::operator=(static_cast<const typename NodeMap<TT>::Parent&>(copy));\
    58   return *this; \
    59 } \
    60 };
    61 
    62 /** Creates a map from a template map. The import method is
    63  *  an overloading of the map type.
    64  *  The reason to use these macro is that the c++ does not support
    65  *  the template typedefs. If a future release of the c++ 
    66  *  supports this feature it should be fixed.
    67  */
    68 #define CREATE_EDGE_MAP(DynMap) \
    69 template <typename Value> \
    70 class EdgeMap : public DynMap<EdgeMapRegistry, Value> { \
    71 public: \
    72 typedef DynMap<EdgeMapRegistry, Value> Parent; \
    73 \
    74 EdgeMap(const typename Parent::Graph& g) \
    75   : Parent(g, g.edge_maps) {} \
    76 EdgeMap(const typename Parent::Graph& g, const Value& v) \
    77   : Parent(g, g.edge_maps, v) {} \
    78 EdgeMap(const EdgeMap& copy) : Parent(static_cast<const Parent&>(copy)) {} \
    79 template <typename TT> \
    80 EdgeMap(const EdgeMap<TT>& copy) \
    81   : Parent(static_cast<const typename EdgeMap<TT>::Parent&>(copy)) {} \
    82 EdgeMap& operator=(const EdgeMap& copy) { \
    83   Parent::operator=(static_cast<const Parent&>(copy));\
    84   return *this; \
    85 } \
    86 template <typename TT> \
    87 EdgeMap& operator=(const EdgeMap<TT>& copy) { \
    88   Parent::operator=(static_cast<const typename EdgeMap<TT>::Parent&>(copy));\
    89   return *this; \
    90 } \
    91 };
    92 
    93 /** This macro creates both maps.
    94  */
    95 #define CREATE_MAPS(DynMap) \
    96 CREATE_NODE_MAP(DynMap) \
    97 CREATE_EDGE_MAP(DynMap)
    98 
    99 /** This macro creates MapRegistry for Symmetric Edge Maps.
   100  */
   101 #define CREATE_SYM_EDGE_MAP_REGISTRY \
   102 typedef SymEdgeIt<Graph, Edge, EdgeIt> SymEdgeIt; \
   103 typedef MapRegistry<Graph, Edge, SymEdgeIt> SymEdgeMapRegistry; \
   104 mutable SymEdgeMapRegistry sym_edge_maps;
   105 
   106 
   107 /** Creates a map from a template map. The import method is
   108  *  an overloading of the map type.
   109  *  The reason to use these macro is that the c++ does not support
   110  *  the template typedefs. If a future release of the c++ 
   111  *  supports this feature it should be fixed.
   112  */
   113 #define CREATE_SYM_EDGE_MAP(DynMap) \
   114 template <typename Value> \
   115 class SymEdgeMap : public SymMap<DynMap, SymEdgeMapRegistry, Value> { \
   116 public: \
   117 typedef SymMap<DynMap, SymEdgeMapRegistry, Value> Parent; \
   118 \
   119 SymEdgeMap(const typename Parent::Graph& g) \
   120   : Parent(g, g.sym_edge_maps) {} \
   121 SymEdgeMap(const typename Parent::Graph& g, const Value& v) \
   122   : Parent(g, g.sym_edge_maps, v) {} \
   123 SymEdgeMap(const SymEdgeMap& copy) \
   124   : Parent(static_cast<const Parent&>(copy)) {} \
   125 template <typename TT> \
   126 SymEdgeMap(const NodeMap<TT>& copy) \
   127   : Parent(static_cast<const typename SymEdgeMap<TT>::Parent&>(copy)) {} \
   128 SymEdgeMap& operator=(const SymEdgeMap& copy) { \
   129   Parent::operator=(static_cast<const Parent&>(copy));\
   130   return *this; \
   131 } \
   132 template <typename TT> \
   133 SymEdgeMap& operator=(const SymEdgeMap<TT>& copy) { \
   134   Parent::operator=(static_cast<const typename SymEdgeMap<TT>::Parent&>(copy));\
   135   return *this; \
   136 } \
   137 };
   138 
   139 /** This is a macro to import an node map into a graph class.
   140  */
   141 #define IMPORT_NODE_MAP(From, from, To, to) \
   142 template <typename Value> \
   143 class NodeMap : public From::template NodeMap<Value> { \
   144 \
   145 public: \
   146 typedef typename From::template NodeMap<Value> Parent; \
   147 \
   148 NodeMap(const To& to) \
   149   : Parent(static_cast<const From&>(from)) { } \
   150 NodeMap(const To& to, const Value& value) \
   151   : Parent(static_cast<const From&>(from), value) { } \
   152 NodeMap(const NodeMap& copy) \
   153   : Parent(static_cast<const Parent&>(copy)) {} \
   154 template <typename TT> \
   155 NodeMap(const NodeMap<TT>& copy) \
   156   : Parent(static_cast<const typename NodeMap<TT>::Parent&>(copy)) {} \
   157 NodeMap& operator=(const NodeMap& copy) { \
   158   Parent::operator=(static_cast<const Parent&>(copy)); \
   159   return *this; \
   160 } \
   161 template <typename TT> \
   162 NodeMap& operator=(const NodeMap<TT>& copy) { \
   163   Parent::operator=(static_cast<const typename NodeMap<TT>::Parent&>(copy));\
   164   return *this; \
   165 } \
   166 };
   167 
   168 /** This is a macro to import an edge map into a graph class.
   169  */
   170 #define IMPORT_EDGE_MAP(From, from, To, to) \
   171 template <typename Value> \
   172 class EdgeMap : public From::template EdgeMap<Value> { \
   173 \
   174 public: \
   175 typedef typename From::template EdgeMap<Value> Parent; \
   176 \
   177 EdgeMap(const To& to) \
   178   : Parent(static_cast<const From&>(from)) { } \
   179 EdgeMap(const To& to, const Value& value) \
   180   : Parent(static_cast<const From&>(from), value) { } \
   181 EdgeMap(const EdgeMap& copy) \
   182   : Parent(static_cast<const Parent&>(copy)) {} \
   183 template <typename TT> \
   184 EdgeMap(const EdgeMap<TT>& copy) \
   185   : Parent(static_cast<const typename EdgeMap<TT>::Parent&>(copy)) {} \
   186 EdgeMap& operator=(const EdgeMap& copy) { \
   187   Parent::operator=(static_cast<const Parent&>(copy)); \
   188   return *this; \
   189 } \
   190 template <typename TT> \
   191 EdgeMap& operator=(const EdgeMap<TT>& copy) { \
   192   Parent::operator=(static_cast<const typename EdgeMap<TT>::Parent&>(copy));\
   193   return *this; \
   194 } \
   195 };
   196 
   197 #define KEEP_EDGE_MAP(From, To) \
   198 IMPORT_EDGE_MAP(From, graph, To, graph)
   199 
   200 
   201 #define KEEP_NODE_MAP(From, To) \
   202 IMPORT_NODE_MAP(From, graph, To, graph)
   203 
   204 /** This is a macro to keep the node and edge maps for a graph class.
   205  */
   206 #define KEEP_MAPS(From, To) \
   207 KEEP_EDGE_MAP(From, To) \
   208 KEEP_NODE_MAP(From, To)
   209 
   210   
   211 /// @}
   212   
   213 #endif