sequence_view.hppGo to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef ADOBE_SEQUENCE_VIEW_HPP
00010 #define ADOBE_SEQUENCE_VIEW_HPP
00011
00012
00013
00014 #include <boost/concept_check.hpp>
00015 #include <boost/function.hpp>
00016
00017 #include <adobe/copy_on_write.hpp>
00018 #include <adobe/selection.hpp>
00019 #include <adobe/vector.hpp>
00020
00021
00022
00023 namespace adobe {
00024
00025
00032
00038 template <class SequenceView>
00039 struct sequence_view_key_type
00040 {
00042 typedef typename SequenceView::key_type type;
00043 };
00044
00045 template <class SequenceView>
00046 struct sequence_view_value_type
00047 {
00049 typedef typename SequenceView::value_type type;
00050 };
00051
00052 template <class SequenceView>
00053 struct sequence_view_cow_value_type
00054 {
00056 typedef typename SequenceView::cow_value_type type;
00057 };
00058
00059
00060
00066 template <class SV>
00067 inline void refresh(SV& v,
00068 typename sequence_view_key_type<SV>::type index,
00069 typename sequence_view_cow_value_type<SV>::type value)
00070 { v.refresh(index, value); }
00071
00077 template <class SV>
00078 inline void extend(SV& v,
00079 typename sequence_view_key_type<SV>::type before,
00080 typename sequence_view_key_type<SV>::type value_key,
00081 typename sequence_view_cow_value_type<SV>::type value)
00082 { v.extend(before, value_key, value); }
00083
00089 template <class SV>
00090 inline void extend_set(SV& v,
00091 typename sequence_view_key_type<SV>::type before,
00092 const vector<typename sequence_view_key_type<SV>::type>& extend_key_set)
00093 { v.extend_set(before, extend_key_set); }
00094
00100 template <class SV>
00101 inline void erase(SV& v,
00102 const vector<typename sequence_view_key_type<SV>::type>& key_set)
00103 { v.erase(key_set); }
00104
00110 template <class SV>
00111 inline void clear(SV& v)
00112 { v.clear(); }
00113
00114
00120 template <class SequenceView>
00121 struct SequenceViewConcept
00122 {
00124 typedef typename sequence_view_key_type<SequenceView>::type key_type;
00125 typedef typename sequence_view_cow_value_type<SequenceView>::type cow_value_type;
00126
00128 void constraints()
00129 {
00130 refresh(*view, index, value);
00131 extend(*view, index, index, value);
00132 extend_set(*view, index, key_set);
00133 erase(*view, key_set);
00134 }
00135
00137 static void refresh(SequenceView& view,
00138 key_type index,
00139 cow_value_type value)
00140 {
00141 using adobe::refresh;
00142
00143 refresh(view, index, value);
00144 }
00145
00147 static void extend(SequenceView& view,
00148 key_type before,
00149 key_type value_key,
00150 cow_value_type value)
00151 {
00152 using adobe::extend;
00153
00154 (extend)(view, before, value_key, value);
00155 }
00156
00158 static void extend_set(SequenceView& view,
00159 key_type before,
00160 const vector<key_type>& key_set)
00161 {
00162 using adobe::extend_set;
00163
00164 extend_set(view, before, key_set);
00165 }
00166
00168 static void erase(SequenceView& view,
00169 const vector<key_type>& key_set)
00170 {
00171 using adobe::erase;
00172
00173 erase(view, key_set);
00174 }
00175
00177 static void clear(SequenceView& view)
00178 {
00179 using adobe::clear;
00180
00181 clear(view);
00182 }
00183
00184 #ifndef ADOBE_NO_DOCUMENTATION
00185 SequenceView* view;
00186 key_type index;
00187 cow_value_type value;
00188 vector<key_type> key_set;
00189 #endif
00190 };
00191
00192
00197 template <class T>
00198 struct SequenceViewConcept<boost::reference_wrapper<T> > : SequenceViewConcept<T>
00199 {
00200 void constraints() {
00201
00202 SequenceViewConcept<T>::constraints();
00203 }
00204 };
00205
00206
00207
00208 }
00209
00210
00211
00212
00213 #endif
00214
00215
|