TAO::details::generic_sequence< T, ALLOCATION_TRAITS, ELEMENT_TRAITS > Class Template Reference

#include <Generic_Sequence_T.h>

List of all members.

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_sequenceoperator= (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_typeoperator[] (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_typeget_buffer (CORBA::Boolean orphan)
 Allows read-write access to the underlying buffer.

void swap (generic_sequence &rhs) throw ()

Static Public Member Functions

value_typeallocbuf (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_typebuffer_
 The buffer with all the elements.

CORBA::Boolean release_

template<typename T, class ALLOCATION_TRAITS, class ELEMENT_TRAITS>
class TAO::details::generic_sequence< T, ALLOCATION_TRAITS, ELEMENT_TRAITS >


Member Typedef Documentation

template<typename T, class ALLOCATION_TRAITS, class ELEMENT_TRAITS>
typedef ALLOCATION_TRAITS TAO::details::generic_sequence< T, ALLOCATION_TRAITS, ELEMENT_TRAITS >::allocation_traits
 

Definition at line 77 of file Generic_Sequence_T.h.

template<typename T, class ALLOCATION_TRAITS, class ELEMENT_TRAITS>
typedef ELEMENT_TRAITS TAO::details::generic_sequence< T, ALLOCATION_TRAITS, ELEMENT_TRAITS >::element_traits
 

Definition at line 78 of file Generic_Sequence_T.h.

template<typename T, class ALLOCATION_TRAITS, class ELEMENT_TRAITS>
typedef range_checking<value_type,true> TAO::details::generic_sequence< T, ALLOCATION_TRAITS, ELEMENT_TRAITS >::range
 

Definition at line 79 of file Generic_Sequence_T.h.

template<typename T, class ALLOCATION_TRAITS, class ELEMENT_TRAITS>
typedef T TAO::details::generic_sequence< T, ALLOCATION_TRAITS, ELEMENT_TRAITS >::value_type
 

Definition at line 76 of file Generic_Sequence_T.h.


Constructor & Destructor Documentation

template<typename T, class ALLOCATION_TRAITS, class ELEMENT_TRAITS>
TAO::details::generic_sequence< T, ALLOCATION_TRAITS, ELEMENT_TRAITS >::generic_sequence  )  [inline]
 

Default constructor.

Definition at line 82 of file Generic_Sequence_T.h.

00083     : maximum_(allocation_traits::default_maximum())
00084     , length_(0)
00085     , buffer_(allocation_traits::default_buffer_allocation())
00086     , release_(true)
00087   {
00088   }

template<typename T, class ALLOCATION_TRAITS, class ELEMENT_TRAITS>
TAO::details::generic_sequence< T, ALLOCATION_TRAITS, ELEMENT_TRAITS >::generic_sequence CORBA::ULong  maximum  )  [inline, explicit]
 

Constructor with control of ownership.

Definition at line 91 of file Generic_Sequence_T.h.

00092     : maximum_(maximum)
00093     , length_(0)
00094     , buffer_(allocbuf(maximum_))
00095     , release_(true)
00096   {
00097   }

template<typename T, class ALLOCATION_TRAITS, class ELEMENT_TRAITS>
TAO::details::generic_sequence< T, ALLOCATION_TRAITS, ELEMENT_TRAITS >::generic_sequence CORBA::ULong  maximum,
CORBA::ULong  length,
value_type data,
CORBA::Boolean  release
[inline]
 

Definition at line 99 of file Generic_Sequence_T.h.

00104     : maximum_(maximum)
00105     , length_(length)
00106     , buffer_(data)
00107     , release_(release)
00108   {
00109   }

template<typename T, class ALLOCATION_TRAITS, class ELEMENT_TRAITS>
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 112 of file Generic_Sequence_T.h.

00113     : maximum_(0)
00114     , length_(0)
00115     , buffer_(0)
00116     , release_(false)
00117   {
00118     generic_sequence tmp(rhs.maximum_);
00119     tmp.length_ = rhs.length_;
00120     element_traits::copy_range(
00121         rhs.buffer_, rhs.buffer_ + rhs.length_, tmp.buffer_);
00122     swap(tmp);
00123   }

template<typename T, class ALLOCATION_TRAITS, class ELEMENT_TRAITS>
TAO::details::generic_sequence< T, ALLOCATION_TRAITS, ELEMENT_TRAITS >::~generic_sequence  )  [inline]
 

Destructor.

Definition at line 134 of file Generic_Sequence_T.h.

00135   {
00136     if (release_)
00137     {
00138       freebuf(buffer_);
00139     }
00140   }


Member Function Documentation

template<typename T, class ALLOCATION_TRAITS, class ELEMENT_TRAITS>
value_type* TAO::details::generic_sequence< T, ALLOCATION_TRAITS, ELEMENT_TRAITS >::allocbuf CORBA::ULong  maximum  )  [inline, static]
 

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   }

template<typename T, class ALLOCATION_TRAITS, class ELEMENT_TRAITS>
void TAO::details::generic_sequence< T, ALLOCATION_TRAITS, ELEMENT_TRAITS >::freebuf value_type buffer  )  [inline, static]
 

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   }

template<typename T, class ALLOCATION_TRAITS, class ELEMENT_TRAITS>
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 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   }

template<typename T, class ALLOCATION_TRAITS, class ELEMENT_TRAITS>
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 226 of file Generic_Sequence_T.h.

Referenced by TAO::bounded_array_sequence< T_array, T_slice, T_tag, MAX >::get_buffer().

00227   {
00228     if (buffer_ == 0)
00229     {
00230       buffer_ = allocbuf(maximum_);
00231     }
00232     return buffer_;
00233   }

template<typename T, class ALLOCATION_TRAITS, class ELEMENT_TRAITS>
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 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   }

template<typename T, class ALLOCATION_TRAITS, class ELEMENT_TRAITS>
CORBA::ULong TAO::details::generic_sequence< T, ALLOCATION_TRAITS, ELEMENT_TRAITS >::length void   )  const [inline]
 

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   }

template<typename T, class ALLOCATION_TRAITS, class ELEMENT_TRAITS>
CORBA::ULong TAO::details::generic_sequence< T, ALLOCATION_TRAITS, ELEMENT_TRAITS >::maximum  )  const [inline]
 

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   }

template<typename T, class ALLOCATION_TRAITS, class ELEMENT_TRAITS>
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 126 of file Generic_Sequence_T.h.

00127   {
00128     generic_sequence tmp(rhs);
00129     swap(tmp);
00130     return * this;
00131   }

template<typename T, class ALLOCATION_TRAITS, class ELEMENT_TRAITS>
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 199 of file Generic_Sequence_T.h.

00200   {
00201     range::check(i, length_, maximum_, "operator[]() non-const");
00202     return buffer_[i];
00203   }

template<typename T, class ALLOCATION_TRAITS, class ELEMENT_TRAITS>
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 192 of file Generic_Sequence_T.h.

00193   {
00194     range::check(i, length_, maximum_, "operator[]() const");
00195     return buffer_[i];
00196   }

template<typename T, class ALLOCATION_TRAITS, class ELEMENT_TRAITS>
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 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   }

template<typename T, class ALLOCATION_TRAITS, class ELEMENT_TRAITS>
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 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   }

template<typename T, class ALLOCATION_TRAITS, class ELEMENT_TRAITS>
void TAO::details::generic_sequence< T, ALLOCATION_TRAITS, ELEMENT_TRAITS >::swap generic_sequence< T, ALLOCATION_TRAITS, ELEMENT_TRAITS > &  rhs  )  throw () [inline]
 

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   }


Member Data Documentation

template<typename T, class ALLOCATION_TRAITS, class ELEMENT_TRAITS>
value_type* TAO::details::generic_sequence< T, ALLOCATION_TRAITS, ELEMENT_TRAITS >::buffer_ [mutable, private]
 

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().

template<typename T, class ALLOCATION_TRAITS, class ELEMENT_TRAITS>
CORBA::ULong TAO::details::generic_sequence< T, ALLOCATION_TRAITS, ELEMENT_TRAITS >::length_ [private]
 

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().

template<typename T, class ALLOCATION_TRAITS, class ELEMENT_TRAITS>
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 305 of file Generic_Sequence_T.h.

Referenced by TAO::details::generic_sequence< value_type, allocation_traits, element_traits >::generic_sequence().

template<typename T, class ALLOCATION_TRAITS, class ELEMENT_TRAITS>
CORBA::Boolean TAO::details::generic_sequence< T, ALLOCATION_TRAITS, ELEMENT_TRAITS >::release_ [private]
 

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().


The documentation for this class was generated from the following file:
Generated on Thu Nov 9 12:27:38 2006 for TAO by doxygen 1.3.6