TAO_Unbounded_Object_Sequence< T, T_var > Class Template Reference

Parametric sequence for types that require managers. More...

#include <Sequence_T.h>

Inheritance diagram for TAO_Unbounded_Object_Sequence< T, T_var >:

Inheritance graph
[legend]
Collaboration diagram for TAO_Unbounded_Object_Sequence< T, T_var >:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TAO_Unbounded_Object_Sequence (void)
 TAO_Unbounded_Object_Sequence (CORBA::ULong max)
 TAO_Unbounded_Object_Sequence (CORBA::ULong maximum, CORBA::ULong length, T **data, CORBA::Boolean release=0)
 TAO_Unbounded_Object_Sequence (const TAO_Unbounded_Object_Sequence< T, T_var > &)
 ~TAO_Unbounded_Object_Sequence (void)
TAO_Unbounded_Object_Sequence<
T, T_var > & 
operator= (const TAO_Unbounded_Object_Sequence< T, T_var > &)
TAO_Object_Manager< T, T_var > operator[] (CORBA::ULong slot) const
 read-write accessor
virtual void _allocate_buffer (CORBA::ULong length)
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)

Static Public Member Functions

static T ** allocbuf (CORBA::ULong)
static void freebuf (T **)

Detailed Description

template<typename T, typename T_var>
class TAO_Unbounded_Object_Sequence< T, T_var >

Parametric sequence for types that require managers.

Some IDL types require that sequences on them have a "manager" class, in charge of handling the object lifetime, examples are pseudo objects, object references, valuetypes, and strings.


Constructor & Destructor Documentation

template<typename T, typename T_var>
ACE_INLINE TAO_Unbounded_Object_Sequence< T, T_var >::TAO_Unbounded_Object_Sequence void   ) 
 

{orbos/97-05-15:16.8} The default constructor initializes object reference members to appropriately typed nil object references and string members to NULL; all other members are initialized via their default constructors.

{orbos/97-05-15:16.11} For both bounded and unbounded sequences, the default constructor (as shown in the example above) sets the sequence length equal to 0.

template<typename T, typename T_var>
TAO_Unbounded_Object_Sequence< T, T_var >::TAO_Unbounded_Object_Sequence CORBA::ULong  max  ) 
 

Unbounded sequences provide a constructor that allows only the initial value of the maximum length to be set (the ``maximum constructor'' shown in the example above). This allows applications to control how much buffer space is initially allocated by the sequence. This constructor also sets the length to 0 and the release flag to TRUE.

template<typename T, typename T_var>
ACE_INLINE TAO_Unbounded_Object_Sequence< T, T_var >::TAO_Unbounded_Object_Sequence CORBA::ULong  maximum,
CORBA::ULong  length,
T **  data,
CORBA::Boolean  release = 0
 

The ``T *data'' constructor (as shown in the example above) allows the length and contents of a bounded or unbounded sequence to be set. For unbounded sequences, it also allows the initial value of the maximum length to be set. For this constructor, ownership of the contents vector is determined by the release parameter---FALSE means the caller owns the storage, while TRUE means that the sequence assumes ownership of the storage. If release is TRUE, the contents vector must have been allocated using the sequence allocbuf function, and the sequence will pass it to freebuf when finished with it.

template<typename T, typename T_var>
TAO_Unbounded_Object_Sequence< T, T_var >::TAO_Unbounded_Object_Sequence const TAO_Unbounded_Object_Sequence< T, T_var > &   ) 
 

The copy constructor performs a deep copy from the existing structure to create a new structure, including calling _duplicate on all object reference members and performing the necessary heap allocations for all string members.

The copy constructor creates a new sequence with the same maximum and length as the given sequence, copies each of its current elements (items zero through length-1), and sets the release flag to TRUE.

template<typename T, typename T_var>
TAO_Unbounded_Object_Sequence< T, T_var >::~TAO_Unbounded_Object_Sequence void   ) 
 

The destructor releases all object reference memebrs and frees all string members.


Member Function Documentation

template<typename T, typename T_var>
void TAO_Unbounded_Object_Sequence< T, T_var >::_allocate_buffer CORBA::ULong  length  )  [virtual]
 

No default to workaround egcs problem with templates and namespaces

Implements TAO_Base_Sequence.

template<typename T, typename T_var>
void TAO_Unbounded_Object_Sequence< T, T_var >::_deallocate_buffer void   )  [virtual]
 

Must deallocate the buffer and then set it to zero.

Implements TAO_Base_Sequence.

template<typename T, typename T_var>
void TAO_Unbounded_Object_Sequence< T, T_var >::_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, typename T_var>
T ** TAO_Unbounded_Object_Sequence< T, T_var >::allocbuf CORBA::ULong   )  [static]
 

The allocbuf function allocates a vector of T elements that can be passed to the T *data constructor. The length of the vector is given by the nelems function argument. The allocbuf function initializes each element using its default constructor, except for strings, which are initialized to null pointers, and object references, which are initialized to suitably typed nil object references. A null pointer is returned if allocbuf for some reason cannot allocate the requested vector. Vectors allocated by allocbuf should be freed using the freebuf function.

template<typename T, typename T_var>
void TAO_Unbounded_Object_Sequence< T, T_var >::freebuf T **   )  [static]
 

The freebuf function ensures that the destructor for each element is called before the buffer is destroyed, except for string elements, which are freed using string_free(), and object reference elements, which are freed using release(). The freebuf function will ignore null pointers passed to it.

template<typename T, typename T_var>
TAO_Unbounded_Object_Sequence< T, T_var > & TAO_Unbounded_Object_Sequence< T, T_var >::operator= const TAO_Unbounded_Object_Sequence< T, T_var > &   ) 
 

The assignment operator first releases all object reference members and frees all string members, and then performs a deepcopy to create a new structure.

The assignment operator deepcopies its parameter, releasing old storage if necessary. It behaves as if the original sequence is destroyed via its destructor and then the source sequence copied using the copy constructor. If release=TRUE, the destructor destroys each of the current elements (items zero through length--1). For an unbounded sequence, if a reallocation is necessary due to a change in the length and the sequence was created using the release=TRUE parameter in its constructor, the sequence will deallocate the old storage. If release is FALSE under these circumstances, old storage will not be freed before the reallocation is performed. After reallocation, the release flag is always set to TRUE.

template<typename T, typename T_var>
ACE_INLINE TAO_Object_Manager< T, T_var > TAO_Unbounded_Object_Sequence< T, T_var >::operator[] CORBA::ULong  slot  )  const
 

read-write accessor


The documentation for this class was generated from the following files:
Generated on Wed Nov 23 16:04:19 2005 for TAO by  doxygen 1.4.5