00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef LEMON_CONCEPT_MATRIX_MAPS_H
00020 #define LEMON_CONCEPT_MATRIX_MAPS_H
00021
00022 #include <lemon/utility.h>
00023 #include <lemon/concept_check.h>
00024
00028
00029 namespace lemon {
00030
00031 namespace concept {
00032
00035
00037 template <typename K1, typename K2, typename V>
00038 class ReadMatrixMap
00039 {
00040 public:
00042 typedef K1 FirstKey;
00044 typedef K2 SecondKey;
00047 typedef V Value;
00048
00049
00051 Value operator()(const FirstKey&, const SecondKey&) const {
00052 return Value();
00053 }
00054
00055 template <typename _ReadMatrixMap>
00056 struct Constraints {
00057
00058 void constraints() {
00059 Value val = m(first_key, second_key);
00060 val = m(first_key, second_key);
00061 typename _ReadMatrixMap::Value own_val =
00062 m(own_first_key, own_second_key);
00063 own_val = m(own_first_key, own_second_key);
00064 ignore_unused_variable_warning(val);
00065 ignore_unused_variable_warning(own_val);
00066 }
00067
00068 FirstKey& first_key;
00069 SecondKey& second_key;
00070 typename _ReadMatrixMap::FirstKey& own_first_key;
00071 typename _ReadMatrixMap::SecondKey& own_second_key;
00072 _ReadMatrixMap& m;
00073 };
00074
00075 };
00076
00077
00079 template <typename K1, typename K2, typename V>
00080 class WriteMatrixMap {
00081 public:
00083 typedef K1 FirstKey;
00085 typedef K2 SecondKey;
00088 typedef V Value;
00089
00091 void set(const FirstKey&, const SecondKey& ,const Value&) {}
00092
00093 template <typename _WriteMatrixMap>
00094 struct Constraints {
00095 void constraints() {
00096
00097 m.set(first_key, second_key, val);
00098 m.set(own_first_key, own_second_key, own_val);
00099 }
00100
00101 Value& val;
00102 typename _WriteMatrixMap::Value own_val;
00103 FirstKey& first_key;
00104 SecondKey& second_key;
00105 typename _WriteMatrixMap::FirstKey& own_first_key;
00106 typename _WriteMatrixMap::SecondKey& own_second_key;
00107 _WriteMatrixMap& m;
00108
00109 };
00110 };
00111
00113 template<typename K1, typename K2, typename V>
00114 class ReadWriteMatrixMap
00115 : public ReadMatrixMap<K1, K2, V>, public WriteMatrixMap<K1, K2, V> {
00116 public:
00118 typedef K1 FirstKey;
00120 typedef K2 SecondKey;
00123 typedef V Value;
00124
00126 Value operator()(const FirstKey&, const SecondKey&) const {
00127 return Value();
00128 }
00130 void set(const FirstKey&, const SecondKey& ,const Value&) {}
00131
00132 template<typename _ReadWriteMatrixMap>
00133 struct Constraints {
00134 void constraints() {
00135 checkConcept<ReadMatrixMap<K1, K2, V>, _ReadWriteMatrixMap >();
00136 checkConcept<WriteMatrixMap<K1, K2, V>, _ReadWriteMatrixMap >();
00137 }
00138 };
00139 };
00140
00141
00143 template<typename K1, typename K2, typename V, typename R, typename CR>
00144 class ReferenceMatrixMap : public ReadWriteMatrixMap<K1, K2, V>
00145 {
00146 public:
00148 typedef True ReferenceMapTag;
00150 typedef K1 FirstKey;
00152 typedef K1 SecondKey;
00154 typedef V Value;
00156 typedef R Reference;
00158 typedef CR ConstReference;
00159
00160 protected:
00161 Value tmp;
00162 public:
00163
00165 Reference operator()(const FirstKey&, const SecondKey&) {
00166 return tmp;
00167 }
00169 ConstReference operator()(const FirstKey&, const SecondKey&) const {
00170 return tmp;
00171 }
00173 void set(const FirstKey&, const SecondKey& ,const Value&) {}
00174
00175
00176 template<typename _ReferenceMatrixMap>
00177 struct ReferenceMapConcept {
00178
00179 void constraints() {
00180 checkConcept<ReadWriteMatrixMap, _ReferenceMatrixMap >();
00181 m(first_key, second_key) = val;
00182 val = m(first_key, second_key);
00183 m(first_key, second_key) = ref;
00184 ref = m(first_key, second_key);
00185 m(own_first_key, own_second_key) = own_val;
00186 own_val = m(own_first_key, own_second_key);
00187 m(own_first_key, own_second_key) = own_ref;
00188 own_ref = m(own_first_key, own_second_key);
00189 }
00190
00191 typename _ReferenceMatrixMap::Key& own_first_key;
00192 typename _ReferenceMatrixMap::Key& own_second_key;
00193 typename _ReferenceMatrixMap::Value& own_val;
00194 typename _ReferenceMatrixMap::Reference& own_ref;
00195 FirstKey& first_key;
00196 SecondKey& second_key;
00197 Value& val;
00198 Reference& ref;
00199 _ReferenceMatrixMap& m;
00200 };
00201 };
00202
00203
00204
00205 }
00206 }
00207 #endif // LEMON_CONCEPT_MATRIX_MAPS_H