Changeset 1705:3f63d9db307b in lemon0.x for lemon/lemon_reader.h
 Timestamp:
 10/05/05 15:18:51 (14 years ago)
 Branch:
 default
 Phase:
 public
 Convert:
 svn:c9d7d8f590d60310b91f818b3a526b0e/lemon/trunk@2232
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

lemon/lemon_reader.h
r1627 r1705 37 37 #include <lemon/bits/item_reader.h> 38 38 39 #include <lemon/xy.h> 40 39 41 #include <lemon/concept_check.h> 40 42 #include <lemon/concept/maps.h> … … 95 97 }; 96 98 97 template <typename M1, typename M2> 98 class WriteComposeMap { 99 template <typename Map> 100 struct Ref { typedef Map& Type; }; 101 template <typename Map> 102 struct Arg { typedef Map& Type; }; 103 104 template <typename Graph, typename Map> 105 class ForwardComposeMap { 99 106 public: 100 typedef True NeedCopy; 107 typedef typename Graph::UndirEdge Key; 108 typedef typename Map::Value Value; 109 110 ForwardComposeMap(const Graph& _graph, typename Arg<Map>::Type _map) 111 : graph(_graph), map(_map) {} 101 112 102 typedef typename M2::Key Key; 103 typedef typename M1::Value Value; 104 105 WriteComposeMap(typename SmartParameter<M1>::Type _m1, const M2& _m2) 106 : m1(_m1), m2(_m2) {} 113 void set(const Key& key, const Value& val) { 114 map.set(graph.direct(key, true), val); 115 } 116 117 private: 118 typename Ref<Map>::Type map; 119 const Graph& graph; 120 }; 121 122 template <typename Graph, typename Map> 123 ForwardComposeMap<Graph, Map> 124 forwardComposeMap(const Graph& graph, const Map& map) { 125 return ForwardComposeMap<Graph, Map>(graph, map); 126 } 127 128 template <typename Graph, typename Map> 129 ForwardComposeMap<Graph, Map> 130 forwardComposeMap(const Graph& graph, Map& map) { 131 return ForwardComposeMap<Graph, Map>(graph, map); 132 } 133 134 template <typename Graph, typename Map> 135 class BackwardComposeMap { 136 public: 137 typedef typename Graph::UndirEdge Key; 138 typedef typename Map::Value Value; 139 140 BackwardComposeMap(const Graph& _graph, typename Arg<Map>::Type _map) 141 : graph(_graph), map(_map) {} 107 142 108 void set(const Key& key, const Value& val ue) {109 m 1.set(m2[key], value);143 void set(const Key& key, const Value& val) { 144 map.set(graph.direct(key, false), val); 110 145 } 111 146 112 147 private: 113 114 typename SmartReference<M1>::Type m1; 115 typename SmartConstReference<M2>::Type m2; 116 117 }; 118 119 template <typename M1, typename M2> 120 WriteComposeMap<M1, M2> writeComposeMap(M1& m1, const M2& m2) { 121 return WriteComposeMap<M1, M2>(m1, m2); 122 } 123 124 template <typename M1, typename M2> 125 WriteComposeMap<M1, M2> writeComposeMap(const M1& m1, const M2& m2) { 126 return WriteComposeMap<M1, M2>(m1, m2); 127 } 128 148 typename Ref<Map>::Type map; 149 const Graph& graph; 150 }; 151 152 153 template <typename Graph, typename Map> 154 BackwardComposeMap<Graph, Map> 155 backwardComposeMap(const Graph& graph, const Map& map) { 156 return BackwardComposeMap<Graph, Map>(graph, map); 157 } 158 159 template <typename Graph, typename Map> 160 BackwardComposeMap<Graph, Map> 161 backwardComposeMap(const Graph& graph, Map& map) { 162 return BackwardComposeMap<Graph, Map>(graph, map); 163 } 164 165 template <typename Graph, typename Map> 166 struct Ref<ForwardComposeMap<Graph, Map> > { 167 typedef ForwardComposeMap<Graph, Map> Type; 168 }; 169 template <typename Graph, typename Map> 170 struct Arg<ForwardComposeMap<Graph, Map> > { 171 typedef const ForwardComposeMap<Graph, Map>& Type; 172 }; 173 174 template <typename Graph, typename Map> 175 struct Ref<BackwardComposeMap<Graph, Map> > { 176 typedef BackwardComposeMap<Graph, Map> Type; 177 }; 178 template <typename Graph, typename Map> 179 struct Arg<BackwardComposeMap<Graph, Map> > { 180 typedef const BackwardComposeMap<Graph, Map>& Type; 181 }; 182 183 template <typename Map> 184 struct Ref<XMap<Map> > { 185 typedef XMap<Map> Type; 186 }; 187 template <typename Map> 188 struct Arg<XMap<Map> > { 189 typedef const XMap<Map>& Type; 190 }; 191 192 template <typename Map> 193 struct Ref<YMap<Map> > { 194 typedef YMap<Map> Type; 195 }; 196 template <typename Map> 197 struct Arg<YMap<Map> > { 198 typedef const YMap<Map>& Type; 199 }; 200 129 201 } 130 202 … … 433 505 typedef std::map<Value, Item, _reader_bits::Less<Value> > Inverse; 434 506 435 typename SmartReference<Map>::Type map;507 typename _reader_bits::Ref<Map>::Type map; 436 508 Reader reader; 437 509 Inverse inverse; 438 510 439 MapReaderInverter(typename SmartParameter<Map>::Type _map,511 MapReaderInverter(typename _reader_bits::Arg<Map>::Type _map, 440 512 const Reader& _reader) 441 513 : map(_map), reader(_reader) {} … … 527 599 typedef _Item Item; 528 600 529 typename SmartReference<Map>::Type map;601 typename _reader_bits::Ref<Map>::Type map; 530 602 Reader reader; 531 603 532 MapReader(typename SmartParameter<Map>::Type _map,604 MapReader(typename _reader_bits::Arg<Map>::Type _map, 533 605 const Reader& _reader) 534 606 : map(_map), reader(_reader) {} … … 660 732 /// the section when the \c section_id and the \c _id are the same. 661 733 NodeSetReader(LemonReader& _reader, 662 typename SmartParameter<Graph>::Type_graph,734 Graph& _graph, 663 735 const std::string& _id = std::string(), 664 736 const DefaultSkipper& _skipper = DefaultSkipper()) … … 689 761 return _readMap< 690 762 typename Traits::template Reader<typename Map::Value>, Map, 691 typename SmartParameter<Map>::Type>(name, map);763 typename _reader_bits::Arg<Map>::Type>(name, map); 692 764 } 693 765 … … 696 768 return _readMap< 697 769 typename Traits::template Reader<typename Map::Value>, Map, 698 typename SmartParameter<Map>::Type>(name, map);770 typename _reader_bits::Arg<Map>::Type>(name, map); 699 771 } 700 772 … … 705 777 NodeSetReader& readNodeMap(std::string name, Map& map, 706 778 const Reader& reader = Reader()) { 707 return _readMap<Reader, Map, typename SmartParameter<Map>::Type>779 return _readMap<Reader, Map, typename _reader_bits::Arg<Map>::Type> 708 780 (name, map, reader); 709 781 } … … 712 784 NodeSetReader& readNodeMap(std::string name, const Map& map, 713 785 const Reader& reader = Reader()) { 714 return _readMap<Reader, Map, typename SmartParameter<Map>::Type>786 return _readMap<Reader, Map, typename _reader_bits::Arg<Map>::Type> 715 787 (name, map, reader); 716 788 } … … 818 890 MapReaders readers; 819 891 820 typename SmartReference<Graph>::Typegraph;892 Graph& graph; 821 893 std::string id; 822 894 SkipReader<Node, DefaultSkipper> skipper; … … 868 940 template <typename NodeIdReader> 869 941 EdgeSetReader(LemonReader& _reader, 870 typename SmartParameter<Graph>::Type_graph,942 Graph& _graph, 871 943 const NodeIdReader& _nodeIdReader, 872 944 const std::string& _id = std::string(), … … 899 971 return _readMap< 900 972 typename Traits::template Reader<typename Map::Value>, Map, 901 typename SmartParameter<Map>::Type>(name, map);973 typename _reader_bits::Arg<Map>::Type>(name, map); 902 974 } 903 975 … … 906 978 return _readMap< 907 979 typename Traits::template Reader<typename Map::Value>, Map, 908 typename SmartParameter<Map>::Type>(name, map);980 typename _reader_bits::Arg<Map>::Type>(name, map); 909 981 } 910 982 … … 916 988 const Reader& reader = Reader()) { 917 989 return _readMap<Reader, Map, 918 typename SmartParameter<Map>::Type>(name, map, reader);990 typename _reader_bits::Arg<Map>::Type>(name, map, reader); 919 991 } 920 992 … … 923 995 const Reader& reader = Reader()) { 924 996 return _readMap<Reader, Map, 925 typename SmartParameter<Map>::Type>(name, map, reader);997 typename _reader_bits::Arg<Map>::Type>(name, map, reader); 926 998 } 927 999 … … 1033 1105 MapReaders readers; 1034 1106 1035 typename SmartReference<Graph>::Typegraph;1107 Graph& graph; 1036 1108 std::string id; 1037 1109 SkipReader<Edge, DefaultSkipper> skipper; … … 1090 1162 template <typename NodeIdReader> 1091 1163 UndirEdgeSetReader(LemonReader& _reader, 1092 typename SmartParameter<Graph>::Type_graph,1164 Graph& _graph, 1093 1165 const NodeIdReader& _nodeIdReader, 1094 1166 const std::string& _id = std::string(), … … 1121 1193 return _readMap< 1122 1194 typename Traits::template Reader<typename Map::Value>, Map, 1123 typename SmartParameter<Map>::Type>(name, map);1195 typename _reader_bits::Arg<Map>::Type>(name, map); 1124 1196 } 1125 1197 … … 1128 1200 return _readMap< 1129 1201 typename Traits::template Reader<typename Map::Value>, Map, 1130 typename SmartParameter<Map>::Type>(name, map);1202 typename _reader_bits::Arg<Map>::Type>(name, map); 1131 1203 } 1132 1204 … … 1137 1209 UndirEdgeSetReader& readUndirEdgeMap(std::string name, Map& map, 1138 1210 const Reader& reader = Reader()) { 1139 return _readMap<Reader, Map, typename SmartParameter<Map>::Type>1211 return _readMap<Reader, Map, typename _reader_bits::Arg<Map>::Type> 1140 1212 (name, map, reader); 1141 1213 } … … 1144 1216 UndirEdgeSetReader& readUndirEdgeMap(std::string name, const Map& map, 1145 1217 const Reader& reader = Reader()) { 1146 return _readMap<Reader, Map, typename SmartParameter<Map>::Type >1218 return _readMap<Reader, Map, typename _reader_bits::Arg<Map>::Type > 1147 1219 (name, map, reader); 1148 1220 } … … 1190 1262 return _readDirMap< 1191 1263 typename Traits::template Reader<typename Map::Value>, Map, 1192 typename SmartParameter<Map>::Type>(name, map);1264 typename _reader_bits::Arg<Map>::Type>(name, map); 1193 1265 } 1194 1266 … … 1197 1269 return _readDirMap< 1198 1270 typename Traits::template Reader<typename Map::Value>, Map, 1199 typename SmartParameter<Map>::Type>(name, map);1271 typename _reader_bits::Arg<Map>::Type>(name, map); 1200 1272 } 1201 1273 … … 1206 1278 UndirEdgeSetReader& readEdgeMap(std::string name, Map& map, 1207 1279 const Reader& reader = Reader()) { 1208 return _readDirMap<Reader, Map, typename SmartParameter<Map>::Type>1280 return _readDirMap<Reader, Map, typename _reader_bits::Arg<Map>::Type> 1209 1281 (name, map, reader); 1210 1282 } … … 1213 1285 UndirEdgeSetReader& readEdgeMap(std::string name, const Map& map, 1214 1286 const Reader& reader = Reader()) { 1215 return _readDirMap<Reader, Map, typename SmartParameter<Map>::Type>1287 return _readDirMap<Reader, Map, typename _reader_bits::Arg<Map>::Type> 1216 1288 (name, map, reader); 1217 1289 } … … 1225 1297 checkConcept<concept::WriteMap<Edge, typename Map::Value>, Map>(); 1226 1298 readMap("+" + name, 1227 _reader_bits:: writeComposeMap(map, forwardMap(graph)), reader);1299 _reader_bits::forwardComposeMap(graph, map), reader); 1228 1300 readMap("" + name, 1229 _reader_bits:: writeComposeMap(map, backwardMap(graph)), reader);1301 _reader_bits::backwardComposeMap(graph, map), reader); 1230 1302 return *this; 1231 1303 } … … 1337 1409 MapReaders readers; 1338 1410 1339 typename SmartReference<Graph>::Typegraph;1411 Graph& graph; 1340 1412 std::string id; 1341 1413 SkipReader<UndirEdge, DefaultSkipper> skipper;
Note: See TracChangeset
for help on using the changeset viewer.