TAO_Unbounded_Sequence< T > Class Template Reference

An unbounded sequence of Octets. More...

#include <Sequence_T.h>

Inheritance diagram for TAO_Unbounded_Sequence< T >:

Inheritance graph
[legend]
Collaboration diagram for TAO_Unbounded_Sequence< T >:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TAO_Unbounded_Sequence (void)
 Default constructor.
 TAO_Unbounded_Sequence (CORBA::ULong max)
 Constructor using a maximum length value.
 TAO_Unbounded_Sequence (CORBA::ULong max, CORBA::ULong length, T *data, CORBA::Boolean release=0)
 TAO_Unbounded_Sequence (const TAO_Unbounded_Sequence< T > &)
 Copy constructor.
TAO_Unbounded_Sequence< T > & operator= (const TAO_Unbounded_Sequence< T > &)
 Assignment operator.
 ~TAO_Unbounded_Sequence (void)
 Dtor.
T & operator[] (CORBA::ULong)
 operator []
const T & operator[] (CORBA::ULong) const
 operator []
virtual void _allocate_buffer (CORBA::ULong length)
 Implement the TAO_Base_Sequence methods (see Sequence.h).
virtual void _deallocate_buffer (void)
 Must deallocate the buffer and then set it to zero.
virtual void _shrink_buffer (CORBA::ULong new_length, CORBA::ULong old_length)
T * get_buffer (CORBA::Boolean orphan=0)
const T * get_buffer (void) const
void replace (CORBA::ULong max, CORBA::ULong length, T *data, CORBA::Boolean release=0)

Static Public Member Functions

static T * allocbuf (CORBA::ULong)
 Allocate storage for the sequence.
static void freebuf (T *)
 Free the sequence.

Detailed Description

template<typename T>
class TAO_Unbounded_Sequence< T >

An unbounded sequence of Octets.

Marshalling and demarshalling octet sequences can be highly optimize, for instance at demarshalling we don't require a copy from the CDR buffer to the octet sequence buffer, we can simply hold a duplicate of the underlying ACE_Message_Block. Specializing the TAO_Unbounded_Sequence<T> parametric class, is an excellent way to achieve this optimizations.


Constructor & Destructor Documentation

template<typename T>
ACE_INLINE TAO_Unbounded_Sequence< T >::TAO_Unbounded_Sequence ( void   ) 

Default constructor.

template<typename T>
ACE_INLINE TAO_Unbounded_Sequence< T >::TAO_Unbounded_Sequence ( CORBA::ULong  max  ) 

Constructor using a maximum length value.

template<typename T>
ACE_INLINE TAO_Unbounded_Sequence< T >::TAO_Unbounded_Sequence ( CORBA::ULong  max,
CORBA::ULong  length,
T *  data,
CORBA::Boolean  release = 0 
)

Constructor using the data and memory management flag. Memory *must* be allocated using the allocbuf static method, since in the future this classes may use a global ACE_Allocator.

template<typename T>
TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_Unbounded_Sequence< T >::TAO_Unbounded_Sequence ( const TAO_Unbounded_Sequence< T > &   ) 

Copy constructor.

template<typename T>
TAO_Unbounded_Sequence< T >::~TAO_Unbounded_Sequence ( void   ) 

Dtor.


Member Function Documentation

template<typename T>
void TAO_Unbounded_Sequence< T >::_allocate_buffer ( CORBA::ULong  length  )  [virtual]

Implement the TAO_Base_Sequence methods (see Sequence.h).

Implements TAO_Base_Sequence.

template<typename T>
void TAO_Unbounded_Sequence< T >::_deallocate_buffer ( void   )  [virtual]

Must deallocate the buffer and then set it to zero.

Implements TAO_Base_Sequence.

template<typename T>
void TAO_Unbounded_Sequence< T >::_shrink_buffer ( CORBA::ULong  new_length,
CORBA::ULong  old_length 
) [virtual]

Some sequences (of objects and strings) require some cleanup if the sequence is shrunk. The spec requires the destructor to release the objects only from position <0> to <length-1>; so shrink and then delete could result in a memory leak.

Reimplemented from TAO_Base_Sequence.

template<typename T>
TAO_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE T * TAO_Unbounded_Sequence< T >::allocbuf ( CORBA::ULong   )  [static]

Allocate storage for the sequence.

template<typename T>
ACE_INLINE void TAO_Unbounded_Sequence< T >::freebuf ( T *   )  [static]

Free the sequence.

template<typename T>
ACE_INLINE const T * TAO_Unbounded_Sequence< T >::get_buffer ( void   )  const

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.

template<typename T>
T * TAO_Unbounded_Sequence< T >::get_buffer ( CORBA::Boolean  orphan = 0  ) 

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 straings, 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>.

template<typename T>
TAO_Unbounded_Sequence< T > & TAO_Unbounded_Sequence< T >::operator= ( const TAO_Unbounded_Sequence< T > &   ) 

Assignment operator.

template<typename T>
const T & TAO_Unbounded_Sequence< T >::operator[] ( CORBA::ULong   )  const

operator []

template<typename T>
T & TAO_Unbounded_Sequence< T >::operator[] ( CORBA::ULong   ) 

operator []

template<typename T>
void TAO_Unbounded_Sequence< T >::replace ( CORBA::ULong  max,
CORBA::ULong  length,
T *  data,
CORBA::Boolean  release = 0 
)

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.


The documentation for this class was generated from the following files:
Generated on Wed Apr 19 03:25:42 2006 for TAO by  doxygen 1.4.6-4