#include <Generic_Sequence_T.h>
Public Types | |
typedef T | value_type |
typedef ALLOCATION_TRAITS | allocation_traits |
typedef ELEMENT_TRAITS | element_traits |
typedef range_checking< value_type, true > | range |
Public Member Functions | |
generic_sequence () | |
Default constructor. | |
generic_sequence (CORBA::ULong maximum) | |
Constructor with control of ownership. | |
generic_sequence (CORBA::ULong maximum, CORBA::ULong length, value_type *data, CORBA::Boolean release) | |
generic_sequence (generic_sequence const &rhs) | |
Copy constructor. | |
generic_sequence & | operator= (generic_sequence const &rhs) |
Assignment operator. | |
~generic_sequence () | |
Destructor. | |
CORBA::ULong | maximum () const |
Return the maximum length of the sequence. | |
CORBA::Boolean | release () const |
Returns the state of the sequence release flag. | |
CORBA::ULong | length () const |
Returns the length of the sequence. | |
void | length (CORBA::ULong length) |
Set a new length for the sequence. | |
value_type const & | operator[] (CORBA::ULong i) const |
Get a const element from the sequence. | |
value_type & | operator[] (CORBA::ULong i) |
Get an element from the sequence. | |
void | replace (CORBA::ULong maximum, CORBA::ULong length, value_type *data, CORBA::Boolean release) |
value_type const * | get_buffer () const |
value_type * | get_buffer (CORBA::Boolean orphan) |
Allows read-write access to the underlying buffer. | |
void | swap (generic_sequence &rhs) throw () |
Static Public Member Functions | |
value_type * | allocbuf (CORBA::ULong maximum) |
void | freebuf (value_type *buffer) |
Private Attributes | |
CORBA::ULong | maximum_ |
The maximum number of elements the buffer can contain. | |
CORBA::ULong | length_ |
The current number of elements in the buffer. | |
value_type * | buffer_ |
The buffer with all the elements. | |
CORBA::Boolean | release_ |
|
Definition at line 77 of file Generic_Sequence_T.h. |
|
Definition at line 78 of file Generic_Sequence_T.h. |
|
Definition at line 79 of file Generic_Sequence_T.h. |
|
Definition at line 76 of file Generic_Sequence_T.h. |
|
Default constructor.
Definition at line 82 of file Generic_Sequence_T.h.
|
|
Constructor with control of ownership.
Definition at line 91 of file Generic_Sequence_T.h.
|
|
Definition at line 99 of file Generic_Sequence_T.h.
|
|
Copy constructor.
Definition at line 112 of file Generic_Sequence_T.h.
|
|
Destructor.
Definition at line 134 of file Generic_Sequence_T.h.
|
|
Definition at line 293 of file Generic_Sequence_T.h. Referenced by TAO::details::generic_sequence< value_type, allocation_traits, element_traits >::get_buffer().
00294 {
00295 return allocation_traits::allocbuf(maximum);
00296 }
|
|
Definition at line 298 of file Generic_Sequence_T.h. Referenced by TAO::details::generic_sequence< value_type, allocation_traits, element_traits >::~generic_sequence().
00299 { 00300 allocation_traits::freebuf(buffer); 00301 } |
|
Allows read-write access to the underlying buffer. If orphan is FALSE the sequence returns a pointer to its buffer, allocating one if it has not yet done so. The number of elements in the buffer can be determined from the sequence length() accessor. If the orphan argument to get_buffer() is FALSE, the sequence maintains ownership of the underlying buffer. Elements in the returned buffer may be directly replaced by the caller. For sequences of strings, wide strings, and object references, the caller must use the sequence accessor to determine whether elements should be freed (using , , or <CORBA::release> for strings, wide strings, and object references, respective) before being directly assigned to. If the orphan argument to get_buffer is TRUE, the sequence yields ownership of the buffer to the caller. If orphan is TRUE and the sequence does not own its buffer (i.e., its release_ flag is FALSE), the return value is a null pointer. If the buffer is taken from the sequence using this form of get_buffer(), the sequence reverts to the same state it would have if constructed using its default constructor. The caller becomes responsible for eventually freeing each element of the returned buffer (for strings, wide string, and object references), and then freeing the returned buffer itself using freebuf(). Definition at line 263 of file Generic_Sequence_T.h.
00264 { 00265 if (orphan && !release_) 00266 { 00267 return 0; 00268 } 00269 if (buffer_ == 0) 00270 { 00271 buffer_ = allocbuf(maximum_); 00272 } 00273 if (!orphan) 00274 { 00275 return buffer_; 00276 } 00277 00278 generic_sequence tmp; 00279 swap(tmp); 00280 tmp.release_ = false; 00281 00282 return tmp.buffer_; 00283 } |
|
This function allows read-only access to the sequence buffer. The sequence returns its buffer, allocating one of one has not yet been allocated. No direct modification of the returned buffer by the caller is permitted. Definition at line 226 of file Generic_Sequence_T.h. Referenced by TAO::bounded_array_sequence< T_array, T_slice, T_tag, MAX >::get_buffer().
|
|
Set a new length for the sequence.
Definition at line 161 of file Generic_Sequence_T.h.
00162 { 00163 if (length <= maximum_ || length <= length_) 00164 { 00165 if (length_ < length) 00166 { 00167 // TODO This code does not provide the strong-exception 00168 // guarantee, but it does provide the weak-exception 00169 // guarantee. The problem would appear when 00170 // initialize_range() raises an exception after several 00171 // elements have been modified. One could argue that 00172 // this problem is irrelevant, as the elements already 00173 // modified are unreachable to conforming applications. 00174 element_traits::initialize_range( 00175 buffer_ + length_, buffer_ + length); 00176 } 00177 length_ = length; 00178 return; 00179 } 00180 00181 generic_sequence tmp(length); 00182 tmp.length_ = length; 00183 element_traits::copy_range( 00184 buffer_, buffer_ + length_, tmp.buffer_); 00185 element_traits::initialize_range( 00186 tmp.buffer_ + length_, tmp.buffer_ + length); 00187 00188 swap(tmp); 00189 } |
|
Returns the length of the sequence.
Definition at line 155 of file Generic_Sequence_T.h. Referenced by TAO::bounded_array_sequence< T_array, T_slice, T_tag, MAX >::length().
00156 { 00157 return length_; 00158 } |
|
Return the maximum length of the sequence.
Definition at line 143 of file Generic_Sequence_T.h. Referenced by TAO::bounded_array_sequence< T_array, T_slice, T_tag, MAX >::maximum().
00144 { 00145 return maximum_; 00146 } |
|
Assignment operator.
Definition at line 126 of file Generic_Sequence_T.h.
00127 { 00128 generic_sequence tmp(rhs); 00129 swap(tmp); 00130 return * this; 00131 } |
|
Get an element from the sequence.
Definition at line 199 of file Generic_Sequence_T.h.
00200 { 00201 range::check(i, length_, maximum_, "operator[]() non-const"); 00202 return buffer_[i]; 00203 } |
|
Get a const element from the sequence.
Definition at line 192 of file Generic_Sequence_T.h.
00193 { 00194 range::check(i, length_, maximum_, "operator[]() const"); 00195 return buffer_[i]; 00196 } |
|
Returns the state of the sequence release flag.
Definition at line 149 of file Generic_Sequence_T.h. Referenced by TAO::bounded_array_sequence< T_array, T_slice, T_tag, MAX >::release().
00150 { 00151 return release_; 00152 } |
|
Allows the buffer underlying a sequence to be replaced. The parameters to replace() are identical in type, order, and purpose to those for the <T *data> constructor for the sequence. Definition at line 210 of file Generic_Sequence_T.h. Referenced by TAO::bounded_array_sequence< T_array, T_slice, T_tag, MAX >::replace().
00215 { 00216 generic_sequence tmp(maximum, length, data, release); 00217 swap(tmp); 00218 } |
|
Definition at line 285 of file Generic_Sequence_T.h. Referenced by TAO::details::generic_sequence< value_type, allocation_traits, element_traits >::generic_sequence(), TAO::details::generic_sequence< value_type, allocation_traits, element_traits >::get_buffer(), TAO::details::generic_sequence< value_type, allocation_traits, element_traits >::length(), TAO::details::generic_sequence< value_type, allocation_traits, element_traits >::operator=(), TAO::details::generic_sequence< value_type, allocation_traits, element_traits >::replace(), and TAO::bounded_array_sequence< T_array, T_slice, T_tag, MAX >::swap().
00286 { 00287 std::swap(maximum_, rhs.maximum_); 00288 std::swap(length_, rhs.length_); 00289 std::swap(buffer_, rhs.buffer_); 00290 std::swap(release_, rhs.release_); 00291 } |
|
The buffer with all the elements.
Definition at line 309 of file Generic_Sequence_T.h. Referenced by TAO::details::generic_sequence< value_type, allocation_traits, element_traits >::generic_sequence(), TAO::details::generic_sequence< value_type, allocation_traits, element_traits >::get_buffer(), and TAO::details::generic_sequence< value_type, allocation_traits, element_traits >::length(). |
|
The current number of elements in the buffer.
Definition at line 307 of file Generic_Sequence_T.h. Referenced by TAO::details::generic_sequence< value_type, allocation_traits, element_traits >::generic_sequence(), and TAO::details::generic_sequence< value_type, allocation_traits, element_traits >::length(). |
|
The maximum number of elements the buffer can contain.
Definition at line 305 of file Generic_Sequence_T.h. Referenced by TAO::details::generic_sequence< value_type, allocation_traits, element_traits >::generic_sequence(). |
|
If true then the sequence should release the buffer when it is destroyed. Definition at line 312 of file Generic_Sequence_T.h. Referenced by TAO::details::generic_sequence< value_type, allocation_traits, element_traits >::get_buffer(). |