00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00023
00024 #ifndef BTK_UTILITY_BTK_SEQUENCE_HPP
00025 #define BTK_UTILITY_BTK_SEQUENCE_HPP
00026
00027 #include <btk/core/utility/btk_container.hpp>
00028
00029 namespace BTK {
00030 namespace UTILITY {
00031
00032 template <typename T, typename StorageStrategy>
00033 class BTKSequence : public BTKContainer<T,StorageStrategy>
00034 {
00035 BOOST_CLASS_REQUIRE(StorageStrategy,boost,SequenceConcept);
00036 typedef BTKSequence<T,StorageStrategy> self_type;
00037 typedef BTKContainer<T,StorageStrategy> base_type;
00038
00039 public:
00040 IMPORT_BTK_CONTAINER_TYPES(base_type);
00041
00043
00044
00045 BTKSequence(self_type const & source) : base_type(source) {}
00046 virtual ~BTKSequence() {}
00047
00049
00051
00052 BTKSequence(size_type n = 0, const_reference t = value_type()) :
00053 base_type(n,t) {}
00054
00055 template <typename InputIterator>
00056 BTKSequence(InputIterator i, InputIterator j) : base_type(i,j) {}
00057
00059
00061
00062
00063 reference front() { return base_type::_storage.front(); }
00064 const_reference front() const { return base_type::_storage.front(); }
00065
00066 virtual iterator insert(iterator p, const_reference t)
00067 {
00068 return base_type::_storage.insert(p,t);
00069 }
00070
00071 virtual void insert(iterator p, size_type n, const_reference t)
00072 {
00073 base_type::_storage.insert(p,n,t);
00074 }
00075
00076 template <typename InputIterator>
00077 void insert(iterator p, InputIterator i, InputIterator j)
00078 {
00079 boost::function_requires<boost::InputIteratorConcept<InputIterator> >();
00080 base_type::_storage.insert(p,i,j);
00081 }
00082
00083 virtual iterator erase(iterator p) { return base_type::_storage.erase(p); }
00084 virtual iterator erase(iterator p, iterator q)
00085 { return base_type::_storage.erase(p,q); }
00086
00087 virtual void clear() { base_type::_storage.clear(); }
00088
00089 virtual void resize(size_type n, const_reference t = value_type())
00090 { base_type::_storage.resize(n,t); }
00091
00093 };
00094
00095
00096
00097
00098 #define IMPORT_BTK_SEQUENCE_METHODS(Sequence) \
00099 using Sequence::front; \
00100 using Sequence::insert; \
00101 template <typename InputIterator> \
00102 void insert(iterator p, InputIterator i, InputIterator j) \
00103 { Sequence::insert(p,i,j); } \
00104 using Sequence::erase; \
00105 using Sequence::clear; \
00106 using Sequence::resize;
00107
00108 }
00109 }
00110
00111 #endif // BTK_UTILITY_BTK_SEQUENCE_HPP