Go to the documentation of this file.00001 #ifndef guard_bounded_object_reference_sequence_hpp
00002 #define guard_bounded_object_reference_sequence_hpp
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "Bounded_Reference_Allocation_Traits_T.h"
00013 #include "Object_Reference_Traits_T.h"
00014 #include "Generic_Sequence_T.h"
00015 #include "Object_Reference_Sequence_Element_T.h"
00016 #include "Object_Reference_Const_Sequence_Element_T.h"
00017 #include "tao/MM_Sequence_Iterator_T.h"
00018
00019 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00020
00021 namespace TAO
00022 {
00023
00024 template<typename object_t, typename object_t_var, CORBA::ULong MAX>
00025 class bounded_object_reference_sequence
00026 {
00027 public:
00028 typedef object_t object_type;
00029 typedef object_type * value_type;
00030 typedef value_type const const_value_type;
00031 typedef object_t_var object_type_var;
00032 typedef ::CORBA::ULong size_type;
00033
00034 typedef details::object_reference_traits<object_type,object_type_var,true> element_traits;
00035 typedef details::bounded_reference_allocation_traits<value_type,element_traits,MAX,true> allocation_traits;
00036
00037 typedef details::object_reference_sequence_element<element_traits> element_type;
00038 typedef details::object_reference_const_sequence_element<element_traits> const_element_type;
00039 typedef element_type subscript_type;
00040 typedef value_type const & const_subscript_type;
00041
00042 typedef details::generic_sequence<value_type, allocation_traits, element_traits> implementation_type;
00043
00044 inline bounded_object_reference_sequence()
00045 : impl_()
00046 {}
00047 inline bounded_object_reference_sequence(
00048 CORBA::ULong length,
00049 value_type * data,
00050 CORBA::Boolean release)
00051 : impl_(MAX, length, data, release)
00052 {}
00053
00054
00055
00056 inline CORBA::ULong maximum() const {
00057 return impl_.maximum();
00058 }
00059
00060 inline CORBA::Boolean release() const {
00061 return impl_.release();
00062 }
00063
00064 inline CORBA::ULong length() const {
00065 return impl_.length();
00066 }
00067
00068
00069 inline void length(CORBA::ULong length) {
00070 implementation_type::range::check_length(length, MAX);
00071 impl_.length(length);
00072 }
00073
00074 inline const_element_type operator[](CORBA::ULong i) const {
00075 return const_element_type (impl_[i], release());
00076 }
00077
00078 inline element_type operator[](CORBA::ULong i) {
00079 return element_type(impl_[i], release());
00080 }
00081
00082 inline value_type const * get_buffer() const {
00083 return impl_.get_buffer();
00084 }
00085
00086 inline void replace(
00087 CORBA::ULong length,
00088 value_type * data,
00089 CORBA::Boolean release = false) {
00090 impl_.replace(MAX, length, data, release);
00091 }
00092
00093 inline value_type * get_buffer(CORBA::Boolean orphan = false) {
00094 return impl_.get_buffer(orphan);
00095 }
00096
00097 inline void swap(bounded_object_reference_sequence & rhs) throw() {
00098 impl_.swap(rhs.impl_);
00099 }
00100
00101 static value_type * allocbuf(CORBA::ULong maximum)
00102 {
00103 return implementation_type::allocbuf(maximum);
00104 }
00105 static value_type * allocbuf()
00106 {
00107 return implementation_type::allocbuf(MAX);
00108 }
00109 static void freebuf(value_type * buffer)
00110 {
00111 implementation_type::freebuf(buffer);
00112 }
00113
00114
00115 #if defined TAO_HAS_SEQUENCE_ITERATORS && TAO_HAS_SEQUENCE_ITERATORS == 1
00116
00117
00118
00119
00120
00121
00122
00123 typedef MM_Sequence_Iterator<bounded_object_reference_sequence<object_t, object_t_var, MAX> > iterator;
00124 typedef Const_MM_Sequence_Iterator<bounded_object_reference_sequence<object_t, object_t_var, MAX> > const_iterator;
00125 typedef MM_Sequence_Reverse_Iterator<bounded_object_reference_sequence<object_t, object_t_var, MAX> > reverse_iterator;
00126 typedef Const_MM_Sequence_Reverse_Iterator<bounded_object_reference_sequence<object_t, object_t_var, MAX> > const_reverse_iterator;
00127
00128
00129 iterator begin (void)
00130 {
00131 return iterator (&this->impl_);
00132 }
00133
00134
00135 const_iterator begin (void) const
00136 {
00137 return const_iterator (&this->impl_);
00138 }
00139
00140
00141 iterator end (void)
00142 {
00143 return iterator (&this->impl_,
00144 this->impl_.length ());
00145 }
00146
00147
00148 const_iterator end (void) const
00149 {
00150 return const_iterator (&this->impl_,
00151 this->impl_.length ());
00152 }
00153
00154
00155 reverse_iterator rbegin (void)
00156 {
00157 return reverse_iterator (&this->impl_,
00158 this->impl_.length () - 1);
00159 }
00160
00161
00162 const_reverse_iterator rbegin (void) const
00163 {
00164 return const_reverse_iterator (&this->impl_,
00165 this->impl_.length () - 1);
00166 }
00167
00168
00169
00170 reverse_iterator rend (void)
00171 {
00172 return reverse_iterator (&this->impl_,
00173 -1);
00174 }
00175
00176
00177
00178 const_reverse_iterator rend (void) const
00179 {
00180 return const_reverse_iterator (&this->impl_,
00181 -1);
00182 }
00183
00184 #endif
00185
00186 private:
00187 implementation_type impl_;
00188 };
00189
00190 }
00191
00192 TAO_END_VERSIONED_NAMESPACE_DECL
00193
00194 #endif // guard_bounded_object_reference_sequence_hpp