map_defines.h

Go to the documentation of this file.
00001 /* -*- C++ -*- 00002 * src/lemon/map_defines.h - Part of LEMON, a generic C++ optimization library 00003 * 00004 * Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 00005 * (Egervary Combinatorial Optimization Research Group, EGRES). 00006 * 00007 * Permission to use, modify and distribute this software is granted 00008 * provided that this copyright notice appears in all copies. For 00009 * precise terms see the accompanying LICENSE file. 00010 * 00011 * This software is provided "AS IS" with no warranty of any kind, 00012 * express or implied, and with no claim as to its suitability for any 00013 * purpose. 00014 * 00015 */ 00016 00017 #ifndef LEMON_MAP_DEFINES_H 00018 #define LEMON_MAP_DEFINES_H 00019 00023 00026 00030 #define CREATE_EDGE_MAP_REGISTRY \ 00031 typedef MapRegistry<Graph, Edge, EdgeIt> EdgeMapRegistry; \ 00032 mutable EdgeMapRegistry edge_maps; 00033 00037 #define CREATE_NODE_MAP_REGISTRY \ 00038 typedef MapRegistry<Graph, Node, NodeIt> NodeMapRegistry; \ 00039 mutable NodeMapRegistry node_maps; 00040 00043 #define CREATE_MAP_REGISTRIES \ 00044 CREATE_NODE_MAP_REGISTRY \ 00045 CREATE_EDGE_MAP_REGISTRY 00046 00053 #define CREATE_NODE_MAP(DynMap) \ 00054 template <typename Value> \ 00055 class NodeMap : public DynMap<NodeMapRegistry, Value> { \ 00056 public: \ 00057 typedef DynMap<NodeMapRegistry, Value> Parent; \ 00058 NodeMap(const typename Parent::Graph& g) \ 00059 : Parent(g, g.node_maps) {} \ 00060 NodeMap(const typename Parent::Graph& g, const Value& v) \ 00061 : Parent(g, g.node_maps, v) {} \ 00062 NodeMap(const NodeMap& copy) : Parent(static_cast<const Parent&>(copy)) {} \ 00063 template <typename TT> \ 00064 NodeMap(const NodeMap<TT>& copy) \ 00065 : Parent(static_cast<const typename NodeMap<TT>::Parent&>(copy)) {} \ 00066 NodeMap& operator=(const NodeMap& copy) { \ 00067 Parent::operator=(static_cast<const Parent&>(copy));\ 00068 return *this; \ 00069 } \ 00070 template <typename TT> \ 00071 NodeMap& operator=(const NodeMap<TT>& copy) { \ 00072 Parent::operator=(static_cast<const typename NodeMap<TT>::Parent&>(copy));\ 00073 return *this; \ 00074 } \ 00075 }; 00076 00083 #define CREATE_EDGE_MAP(DynMap) \ 00084 template <typename Value> \ 00085 class EdgeMap : public DynMap<EdgeMapRegistry, Value> { \ 00086 public: \ 00087 typedef DynMap<EdgeMapRegistry, Value> Parent; \ 00088 \ 00089 EdgeMap(const typename Parent::Graph& g) \ 00090 : Parent(g, g.edge_maps) {} \ 00091 EdgeMap(const typename Parent::Graph& g, const Value& v) \ 00092 : Parent(g, g.edge_maps, v) {} \ 00093 EdgeMap(const EdgeMap& copy) : Parent(static_cast<const Parent&>(copy)) {} \ 00094 template <typename TT> \ 00095 EdgeMap(const EdgeMap<TT>& copy) \ 00096 : Parent(static_cast<const typename EdgeMap<TT>::Parent&>(copy)) {} \ 00097 EdgeMap& operator=(const EdgeMap& copy) { \ 00098 Parent::operator=(static_cast<const Parent&>(copy));\ 00099 return *this; \ 00100 } \ 00101 template <typename TT> \ 00102 EdgeMap& operator=(const EdgeMap<TT>& copy) { \ 00103 Parent::operator=(static_cast<const typename EdgeMap<TT>::Parent&>(copy));\ 00104 return *this; \ 00105 } \ 00106 }; 00107 00110 #define CREATE_MAPS(DynMap) \ 00111 CREATE_NODE_MAP(DynMap) \ 00112 CREATE_EDGE_MAP(DynMap) 00113 00116 #define CREATE_SYM_EDGE_MAP_REGISTRY \ 00117 typedef SymEdgeIt<Graph, Edge, EdgeIt> SymEdgeIt; \ 00118 typedef MapRegistry<Graph, Edge, SymEdgeIt> SymEdgeMapRegistry; \ 00119 mutable SymEdgeMapRegistry sym_edge_maps; 00120 00121 00128 #define CREATE_SYM_EDGE_MAP(DynMap) \ 00129 template <typename Value> \ 00130 class SymEdgeMap : public SymMap<DynMap, SymEdgeMapRegistry, Value> { \ 00131 public: \ 00132 typedef SymMap<DynMap, SymEdgeMapRegistry, Value> Parent; \ 00133 \ 00134 SymEdgeMap(const typename Parent::Graph& g) \ 00135 : Parent(g, g.sym_edge_maps) {} \ 00136 SymEdgeMap(const typename Parent::Graph& g, const Value& v) \ 00137 : Parent(g, g.sym_edge_maps, v) {} \ 00138 SymEdgeMap(const SymEdgeMap& copy) \ 00139 : Parent(static_cast<const Parent&>(copy)) {} \ 00140 template <typename TT> \ 00141 SymEdgeMap(const NodeMap<TT>& copy) \ 00142 : Parent(static_cast<const typename SymEdgeMap<TT>::Parent&>(copy)) {} \ 00143 SymEdgeMap& operator=(const SymEdgeMap& copy) { \ 00144 Parent::operator=(static_cast<const Parent&>(copy));\ 00145 return *this; \ 00146 } \ 00147 template <typename TT> \ 00148 SymEdgeMap& operator=(const SymEdgeMap<TT>& copy) { \ 00149 Parent::operator=(static_cast<const typename SymEdgeMap<TT>::Parent&>(copy));\ 00150 return *this; \ 00151 } \ 00152 }; 00153 00156 #define IMPORT_NODE_MAP(From, from, To, to) \ 00157 template <typename Value> \ 00158 class NodeMap : public From::template NodeMap<Value> { \ 00159 \ 00160 public: \ 00161 typedef typename From::template NodeMap<Value> Parent; \ 00162 \ 00163 NodeMap(const To& to) \ 00164 : Parent(static_cast<const From&>(from)) { } \ 00165 NodeMap(const To& to, const Value& value) \ 00166 : Parent(static_cast<const From&>(from), value) { } \ 00167 NodeMap(const NodeMap& copy) \ 00168 : Parent(static_cast<const Parent&>(copy)) {} \ 00169 template <typename TT> \ 00170 NodeMap(const NodeMap<TT>& copy) \ 00171 : Parent(static_cast<const typename NodeMap<TT>::Parent&>(copy)) {} \ 00172 NodeMap& operator=(const NodeMap& copy) { \ 00173 Parent::operator=(static_cast<const Parent&>(copy)); \ 00174 return *this; \ 00175 } \ 00176 template <typename TT> \ 00177 NodeMap& operator=(const NodeMap<TT>& copy) { \ 00178 Parent::operator=(static_cast<const typename NodeMap<TT>::Parent&>(copy));\ 00179 return *this; \ 00180 } \ 00181 }; 00182 00185 #define IMPORT_EDGE_MAP(From, from, To, to) \ 00186 template <typename Value> \ 00187 class EdgeMap : public From::template EdgeMap<Value> { \ 00188 \ 00189 public: \ 00190 typedef typename From::template EdgeMap<Value> Parent; \ 00191 \ 00192 EdgeMap(const To& to) \ 00193 : Parent(static_cast<const From&>(from)) { } \ 00194 EdgeMap(const To& to, const Value& value) \ 00195 : Parent(static_cast<const From&>(from), value) { } \ 00196 EdgeMap(const EdgeMap& copy) \ 00197 : Parent(static_cast<const Parent&>(copy)) {} \ 00198 template <typename TT> \ 00199 EdgeMap(const EdgeMap<TT>& copy) \ 00200 : Parent(static_cast<const typename EdgeMap<TT>::Parent&>(copy)) {} \ 00201 EdgeMap& operator=(const EdgeMap& copy) { \ 00202 Parent::operator=(static_cast<const Parent&>(copy)); \ 00203 return *this; \ 00204 } \ 00205 template <typename TT> \ 00206 EdgeMap& operator=(const EdgeMap<TT>& copy) { \ 00207 Parent::operator=(static_cast<const typename EdgeMap<TT>::Parent&>(copy));\ 00208 return *this; \ 00209 } \ 00210 }; 00211 00212 #define KEEP_EDGE_MAP(From, To) \ 00213 IMPORT_EDGE_MAP(From, graph, To, graph) 00214 00215 00216 #define KEEP_NODE_MAP(From, To) \ 00217 IMPORT_NODE_MAP(From, graph, To, graph) 00218 00221 #define KEEP_MAPS(From, To) \ 00222 KEEP_EDGE_MAP(From, To) \ 00223 KEEP_NODE_MAP(From, To) 00224 00225 00227 00228 #endif

Generated on Thu Sep 30 12:18:33 2004 for LEMON by doxygen 1.3.8