#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 | |
static value_type * | allocbuf (CORBA::ULong maximum) |
static 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 91 of file Generic_Sequence_T.h.
typedef ALLOCATION_TRAITS TAO::details::generic_sequence< T, ALLOCATION_TRAITS, ELEMENT_TRAITS >::allocation_traits |
Definition at line 105 of file Generic_Sequence_T.h.
typedef ELEMENT_TRAITS TAO::details::generic_sequence< T, ALLOCATION_TRAITS, ELEMENT_TRAITS >::element_traits |
Definition at line 106 of file Generic_Sequence_T.h.
typedef range_checking<value_type,true> TAO::details::generic_sequence< T, ALLOCATION_TRAITS, ELEMENT_TRAITS >::range |
Definition at line 107 of file Generic_Sequence_T.h.
typedef T TAO::details::generic_sequence< T, ALLOCATION_TRAITS, ELEMENT_TRAITS >::value_type |
Definition at line 104 of file Generic_Sequence_T.h.
TAO::details::generic_sequence< T, ALLOCATION_TRAITS, ELEMENT_TRAITS >::generic_sequence | ( | ) | [inline] |
TAO::details::generic_sequence< T, ALLOCATION_TRAITS, ELEMENT_TRAITS >::generic_sequence | ( | CORBA::ULong | maximum | ) | [inline, explicit] |
TAO::details::generic_sequence< T, ALLOCATION_TRAITS, ELEMENT_TRAITS >::generic_sequence | ( | CORBA::ULong | maximum, | |
CORBA::ULong | length, | |||
value_type * | data, | |||
CORBA::Boolean | release | |||
) | [inline] |
TAO::details::generic_sequence< T, ALLOCATION_TRAITS, ELEMENT_TRAITS >::generic_sequence | ( | generic_sequence< T, ALLOCATION_TRAITS, ELEMENT_TRAITS > const & | rhs | ) | [inline] |
Copy constructor.
Definition at line 140 of file Generic_Sequence_T.h.
: maximum_(0) , length_(0) , buffer_(0) , release_(false) { if (rhs.maximum_ == 0 || rhs.buffer_ == 0) { maximum_ = rhs.maximum_; length_ = rhs.length_; return; } generic_sequence tmp(rhs.maximum_, rhs.length_, allocation_traits::allocbuf_noinit(rhs.maximum_), true); element_traits::initialize_range( tmp.buffer_ + tmp.length_, tmp.buffer_ + tmp.maximum_); element_traits::copy_range( rhs.buffer_, rhs.buffer_ + rhs.length_, ACE_make_checked_array_iterator (tmp.buffer_, tmp.length_)); swap(tmp); }
TAO::details::generic_sequence< T, ALLOCATION_TRAITS, ELEMENT_TRAITS >::~generic_sequence | ( | ) | [inline] |
Destructor.
Definition at line 173 of file Generic_Sequence_T.h.
{ if (release_) { freebuf(buffer_); } }
static value_type* TAO::details::generic_sequence< T, ALLOCATION_TRAITS, ELEMENT_TRAITS >::allocbuf | ( | CORBA::ULong | maximum | ) | [inline, static] |
Definition at line 356 of file Generic_Sequence_T.h.
{
return allocation_traits::allocbuf(maximum);
}
static void TAO::details::generic_sequence< T, ALLOCATION_TRAITS, ELEMENT_TRAITS >::freebuf | ( | value_type * | buffer | ) | [inline, static] |
Definition at line 361 of file Generic_Sequence_T.h.
{ allocation_traits::freebuf(buffer); }
value_type* TAO::details::generic_sequence< T, ALLOCATION_TRAITS, ELEMENT_TRAITS >::get_buffer | ( | CORBA::Boolean | orphan | ) | [inline] |
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 release
accessor to determine whether elements should be freed (using string_free
, wstring_free
, 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 322 of file Generic_Sequence_T.h.
value_type const* TAO::details::generic_sequence< T, ALLOCATION_TRAITS, ELEMENT_TRAITS >::get_buffer | ( | ) | const [inline] |
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 284 of file Generic_Sequence_T.h.
void TAO::details::generic_sequence< T, ALLOCATION_TRAITS, ELEMENT_TRAITS >::length | ( | CORBA::ULong | length | ) | [inline] |
Set a new length for the sequence.
Definition at line 200 of file Generic_Sequence_T.h.
{ if (length <= maximum_) { if (buffer_ == 0) { buffer_ = allocbuf(maximum_); release_ = true; length_ = length; // Since allocbuf returns completely initialized buffer // no further actions are required. return; } // When sequence doesn't own a buffer it's not allowed // to change it in any way. if (length < length_ && release_) { // TODO This code does not provide the strong-exception // guarantee, but it does provide the weak-exception // guarantee. The problem would appear when // initialize_range() raises an exception after several // elements have been modified. One could argue that // this problem is irrelevant, as the elements already // modified are unreachable to conforming applications. element_traits::release_range( buffer_ + length, buffer_ + length_); element_traits::initialize_range( buffer_ + length, buffer_ + length_); } length_ = length; return; } generic_sequence tmp(length, length, allocation_traits::allocbuf_noinit(length), true); // First do initialize_range. If it will throw then tmp will be // destructed but *this will remain unchanged. element_traits::initialize_range( tmp.buffer_ + length_, tmp.buffer_ + length); element_traits::copy_swap_range( buffer_, buffer_ + length_, ACE_make_checked_array_iterator (tmp.buffer_, tmp.length_)); swap(tmp); }
CORBA::ULong TAO::details::generic_sequence< T, ALLOCATION_TRAITS, ELEMENT_TRAITS >::length | ( | void | ) | const [inline] |
Returns the length of the sequence.
Definition at line 194 of file Generic_Sequence_T.h.
{ return length_; }
CORBA::ULong TAO::details::generic_sequence< T, ALLOCATION_TRAITS, ELEMENT_TRAITS >::maximum | ( | ) | const [inline] |
Return the maximum length of the sequence.
Definition at line 182 of file Generic_Sequence_T.h.
{ return maximum_; }
generic_sequence& TAO::details::generic_sequence< T, ALLOCATION_TRAITS, ELEMENT_TRAITS >::operator= | ( | generic_sequence< T, ALLOCATION_TRAITS, ELEMENT_TRAITS > const & | rhs | ) | [inline] |
Assignment operator.
Definition at line 165 of file Generic_Sequence_T.h.
{ generic_sequence tmp(rhs); swap(tmp); return * this; }
value_type& TAO::details::generic_sequence< T, ALLOCATION_TRAITS, ELEMENT_TRAITS >::operator[] | ( | CORBA::ULong | i | ) | [inline] |
Get an element from the sequence.
Definition at line 257 of file Generic_Sequence_T.h.
{ range::check(i, length_, maximum_, "operator[]() non-const"); return buffer_[i]; }
value_type const& TAO::details::generic_sequence< T, ALLOCATION_TRAITS, ELEMENT_TRAITS >::operator[] | ( | CORBA::ULong | i | ) | const [inline] |
Get a const element from the sequence.
Definition at line 250 of file Generic_Sequence_T.h.
{ range::check(i, length_, maximum_, "operator[]() const"); return buffer_[i]; }
CORBA::Boolean TAO::details::generic_sequence< T, ALLOCATION_TRAITS, ELEMENT_TRAITS >::release | ( | void | ) | const [inline] |
Returns the state of the sequence release flag.
Definition at line 188 of file Generic_Sequence_T.h.
{ return release_; }
void TAO::details::generic_sequence< T, ALLOCATION_TRAITS, ELEMENT_TRAITS >::replace | ( | CORBA::ULong | maximum, | |
CORBA::ULong | length, | |||
value_type * | data, | |||
CORBA::Boolean | release | |||
) | [inline] |
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 268 of file Generic_Sequence_T.h.
{ generic_sequence tmp(maximum, length, data, release); swap(tmp); }
void TAO::details::generic_sequence< T, ALLOCATION_TRAITS, ELEMENT_TRAITS >::swap | ( | generic_sequence< T, ALLOCATION_TRAITS, ELEMENT_TRAITS > & | rhs | ) | throw () [inline] |
Definition at line 348 of file Generic_Sequence_T.h.
{ std::swap(maximum_, rhs.maximum_); std::swap(length_, rhs.length_); std::swap(buffer_, rhs.buffer_); std::swap(release_, rhs.release_); }
value_type* TAO::details::generic_sequence< T, ALLOCATION_TRAITS, ELEMENT_TRAITS >::buffer_ [mutable, private] |
The buffer with all the elements.
Definition at line 446 of file Generic_Sequence_T.h.
CORBA::ULong TAO::details::generic_sequence< T, ALLOCATION_TRAITS, ELEMENT_TRAITS >::length_ [private] |
The current number of elements in the buffer.
Definition at line 444 of file Generic_Sequence_T.h.
CORBA::ULong TAO::details::generic_sequence< T, ALLOCATION_TRAITS, ELEMENT_TRAITS >::maximum_ [private] |
The maximum number of elements the buffer can contain.
Definition at line 442 of file Generic_Sequence_T.h.
CORBA::Boolean TAO::details::generic_sequence< T, ALLOCATION_TRAITS, ELEMENT_TRAITS >::release_ [mutable, private] |
If true then the sequence should release the buffer when it is destroyed.
Definition at line 449 of file Generic_Sequence_T.h.