stlab.adobe.com Adobe Systems Incorporated

poly_sequence_view.hpp

Go to the documentation of this file.
00001 /*
00002     Copyright 2006-2007 Adobe Systems Incorporated
00003     Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt
00004     or a copy at http://stlab.adobe.com/licenses.html)
00005 */
00006 
00007 /******************************************************************************/
00008 
00009 #ifndef ADOBE_POLY_SEQUENCE_VIEW_HPP
00010 #define ADOBE_POLY_SEQUENCE_VIEW_HPP
00011 
00012 /******************************************************************************/
00013 
00014 #include <adobe/config.hpp>
00015 
00016 #include <boost/function.hpp>
00017 
00018 #include <adobe/copy_on_write.hpp>
00019 #include <adobe/poly.hpp>
00020 #include <adobe/sequence_model_fwd.hpp>
00021 #include <adobe/sequence_view.hpp>
00022 #include <adobe/vector.hpp>
00023 
00024 /******************************************************************************/
00025 
00026 namespace adobe {
00027 
00028 /******************************************************************************/
00034 template <typename T>
00035 struct poly_sequence_view_interface : poly_copyable_interface
00036 {
00037     typedef copy_on_write<T> cow_value_type;
00038 
00039     virtual void refresh(sequence_key<T> index, cow_value_type value) = 0;
00040 
00041     virtual void extend(sequence_key<T> before, sequence_key<T> value_key, cow_value_type value) = 0;
00042 
00043     virtual void extend_set(sequence_key<T> before, const vector<sequence_key<T> >& extend_key_set) = 0;
00044 
00045     virtual void erase(const vector<sequence_key<T> >& key_set) = 0;
00046 
00047     virtual void clear() = 0;
00048 };
00049 
00050 /******************************************************************************/
00056 template <typename T>
00057 struct poly_sequence_view_instance
00058 {
00059     typedef typename poly_sequence_view_interface<T>::cow_value_type cow_value_type;
00060 
00061     template <typename V>
00062     struct type : optimized_storage_type<V, poly_sequence_view_interface<T> >::type
00063     {
00064         typedef typename optimized_storage_type<V, poly_sequence_view_interface<T> >::type base_t;
00065 
00066         BOOST_CLASS_REQUIRE(V, adobe, SequenceViewConcept);
00067 
00068         explicit type(const V& x) :
00069             base_t(x)
00070         { }
00071 
00072         type(move_from<type> x) :
00073             base_t(move_from<base_t>(x.source))
00074         { }
00075 
00076         void refresh(sequence_key<T> index, cow_value_type value)
00077         { SequenceViewConcept<V>::refresh(this->get(), index, value); }
00078     
00079         void extend(sequence_key<T> before, sequence_key<T> value_key, cow_value_type value)
00080         { SequenceViewConcept<V>::extend(this->get(), before, value_key, value); }
00081 
00082         void extend_set(sequence_key<T> before, const vector<sequence_key<T> >& extend_key_set)
00083         { SequenceViewConcept<V>::extend_set(this->get(), before, extend_key_set); }
00084 
00085         void erase(const vector<sequence_key<T> >& key_set)
00086         { SequenceViewConcept<V>::erase(this->get(), key_set); }
00087 
00088         void clear()
00089         { SequenceViewConcept<V>::clear(this->get()); }
00090     };
00091 };
00092 
00093 /******************************************************************************/
00099 template <typename T>
00100 struct sequence_view : poly_base<poly_sequence_view_interface<T>,
00101                                  poly_sequence_view_instance<T>::template type>
00102 {
00103     typedef poly_base<poly_sequence_view_interface<T>,
00104                       poly_sequence_view_instance<T>::template type> base_t;
00105 
00106     typedef typename poly_sequence_view_instance<T>::cow_value_type cow_value_type;
00107 
00108     template <typename V>
00109     explicit sequence_view(const V& s) :
00110         base_t(s)
00111     { }
00112 
00113     sequence_view(move_from<sequence_view> x) :
00114         base_t(move_from<base_t>(x.source))
00115     { }
00116 
00117     void refresh(sequence_key<T> index, cow_value_type value)
00118     { this->interface_ref().refresh(index, value); }
00119 
00120     void extend(sequence_key<T> before, sequence_key<T> value_key, cow_value_type value)
00121     { this->interface_ref().extend(before, value_key, value); }
00122 
00123     void extend_set(sequence_key<T> before, const vector<sequence_key<T> >& extend_key_set)
00124     { this->interface_ref().extend_set(before, extend_key_set); }
00125 
00126     void erase(const vector<sequence_key<T> >& key_set)
00127     { this->interface_ref().erase(key_set); }
00128 
00129     void clear()
00130     { this->interface_ref().clear(); }
00131 };
00132 
00133 /******************************************************************************/
00134 
00135 template <typename T>
00136 struct poly_sequence_view
00137 {
00138     typedef poly< sequence_view<T> > type;
00139 };
00140 
00141 /******************************************************************************/
00142 
00143 } // namespace adobe
00144 
00145 /******************************************************************************/
00146 
00147 // ADOBE_POLY_SEQUENCE_VIEW_HPP
00148 #endif
00149 
00150 /******************************************************************************/

Copyright © 2006-2007 Adobe Systems Incorporated.

Use of this website signifies your agreement to the Terms of Use and Online Privacy Policy.

Search powered by Google