default_map.h

Go to the documentation of this file.
00001 /* -*- C++ -*- 00002 * src/lemon/default_map.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_DEFAULT_MAP_H 00018 #define LEMON_DEFAULT_MAP_H 00019 00020 00021 #include <lemon/array_map.h> 00022 #include <lemon/vector_map.h> 00023 00028 00029 namespace lemon { 00030 00033 00046 #define DEFAULT_MAP_BODY(DynMap, Value) \ 00047 { \ 00048 \ 00049 public: \ 00050 \ 00051 typedef DynMap<MapRegistry, Value> Parent; \ 00052 \ 00053 typedef typename MapRegistry::Graph Graph; \ 00054 \ 00055 DefaultMap(const Graph& g, MapRegistry& r) : Parent(g, r) {} \ 00056 DefaultMap(const Graph& g, MapRegistry& r, const Value& v) \ 00057 : Parent(g, r, v) {} \ 00058 DefaultMap(const DefaultMap& copy) \ 00059 : Parent(static_cast<const Parent&>(copy)) {} \ 00060 template <typename TT> \ 00061 DefaultMap(const DefaultMap<MapRegistry, TT>& copy) \ 00062 : { \ 00063 Parent::MapBase::operator= \ 00064 (static_cast<const typename Parent::MapBase&>(copy)); \ 00065 if (Parent::getGraph()) { \ 00066 for (typename Parent::KeyIt it(*Parent::getGraph()); it!=INVALID; ++it) {\ 00067 Parent::add(it); \ 00068 Parent::operator[](it) = copy[it]; \ 00069 } \ 00070 } \ 00071 } \ 00072 DefaultMap& operator=(const DefaultMap& copy) { \ 00073 Parent::operator=(static_cast<const Parent&>(copy)); \ 00074 return *this; \ 00075 } \ 00076 template <typename TT> \ 00077 DefaultMap& operator=(const DefaultMap<MapRegistry, TT>& copy) { \ 00078 if (Parent::getGraph() != copy.getGraph()) { \ 00079 Parent::clear(); \ 00080 Parent::MapBase::operator=(copy); \ 00081 Parent::construct(); \ 00082 } \ 00083 if (Parent::getGraph()) { \ 00084 for (typename Parent::KeyIt it(*Parent::getGraph()); it!=INVALID; ++it) {\ 00085 Parent::operator[](it) = copy[it]; \ 00086 } \ 00087 } \ 00088 return *this; \ 00089 } \ 00090 }; 00091 00092 00093 template <typename MapRegistry, typename Type> 00094 class DefaultMap : public ArrayMap<MapRegistry, Type> 00095 DEFAULT_MAP_BODY(ArrayMap, Type); 00096 00097 template <typename MapRegistry> 00098 class DefaultMap<MapRegistry, bool> 00099 : public VectorMap<MapRegistry, bool> 00100 DEFAULT_MAP_BODY(VectorMap, bool); 00101 00102 template <typename MapRegistry> 00103 class DefaultMap<MapRegistry, char> 00104 : public VectorMap<MapRegistry, char> 00105 DEFAULT_MAP_BODY(VectorMap, char); 00106 00107 template <typename MapRegistry> 00108 class DefaultMap<MapRegistry, int> 00109 : public VectorMap<MapRegistry, int> 00110 DEFAULT_MAP_BODY(VectorMap, int); 00111 00112 template <typename MapRegistry> 00113 class DefaultMap<MapRegistry, short> 00114 : public VectorMap<MapRegistry, short> 00115 DEFAULT_MAP_BODY(VectorMap, short); 00116 00117 template <typename MapRegistry> 00118 class DefaultMap<MapRegistry, long> 00119 : public VectorMap<MapRegistry, long> 00120 DEFAULT_MAP_BODY(VectorMap, long); 00121 00122 template <typename MapRegistry> 00123 class DefaultMap<MapRegistry, float> 00124 : public VectorMap<MapRegistry, float> 00125 DEFAULT_MAP_BODY(VectorMap, float); 00126 00127 template <typename MapRegistry> 00128 class DefaultMap<MapRegistry, double> 00129 : public VectorMap<MapRegistry, double> 00130 DEFAULT_MAP_BODY(VectorMap, double); 00131 00132 template <typename MapRegistry> 00133 class DefaultMap<MapRegistry, long double> 00134 : public VectorMap<MapRegistry, long double> 00135 DEFAULT_MAP_BODY(VectorMap, long double); 00136 00137 template <typename MapRegistry, typename Type> 00138 class DefaultMap<MapRegistry, Type*> 00139 : public VectorMap<MapRegistry, Type*> 00140 DEFAULT_MAP_BODY(VectorMap, Type*); 00141 00142 } 00143 00144 #endif

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