Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

TAO_Bounded_Object_Sequence Class Template Reference

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

#include <Sequence_T.h>

Inheritance diagram for TAO_Bounded_Object_Sequence:

Inheritance graph
[legend]
Collaboration diagram for TAO_Bounded_Object_Sequence:

Collaboration graph
[legend]
List of all members.

Public Methods

 TAO_Bounded_Object_Sequence (void)
 TAO_Bounded_Object_Sequence (CORBA::ULong length, T **value, CORBA::Boolean release=0)
 Constructor from data. More...

 TAO_Bounded_Object_Sequence (const TAO_Bounded_Object_Sequence< T, T_var, MAX > &)
 Copy constructor. More...

 ~TAO_Bounded_Object_Sequence (void)
 destructor. More...

TAO_Bounded_Object_Sequence & operator= (const TAO_Bounded_Object_Sequence< T, T_var, MAX > &)
 Assignment from another Bounded sequence. More...

TAO_Object_Manager< T, T_var > operator[] (CORBA::ULong slot) const
 Read-write accessor. More...

virtual void _allocate_buffer (CORBA::ULong length)
 No default to workaround egcs problem with templates and namespaces. More...

virtual void _deallocate_buffer (void)
 Must deallocate the buffer and then set it to zero. More...

virtual void _shrink_buffer (CORBA::ULong new_length, CORBA::ULong old_length)
virtual void _downcast (void *target, CORBA_Object *src ACE_ENV_ARG_DECL_WITH_DEFAULTS)
 Used for sequences of objects to downcast a recently demarshalled object reference into the right type. More...

virtual CORBA_Object_upcast (void *src) const
 Used for sequences of object to convert from the derived type into the Object class. More...


Static Public Methods

T ** allocbuf (CORBA::ULong length)
 Allocate storage for a sequence.. More...

void freebuf (T **buffer)
 Free a buffer allocated by allocbuf() and release each element on it. More...


Detailed Description

template<class T, class T_var, size_t MAX>
class TAO_Bounded_Object_Sequence< T, T_var, MAX >

Parametric sequence for types that require managers.

Please see the documentation for the unbounded case.

Definition at line 760 of file Sequence_T.h.


Constructor & Destructor Documentation

template<class T, class T_var, size_t MAX>
TAO_Bounded_Object_Sequence< T, T_var, MAX >::TAO_Bounded_Object_Sequence void   
 

For bounded sequences, the maximum length is part of the type and cannot be set or modified, while for unbounded sequences, the default constructor also sets the maximum length to 0. The default constructor for a bounded sequence always allocates a contents vector, so it always sets the release flag to TRUE.

Definition at line 807 of file Sequence_T.cpp.

00808   : TAO_Bounded_Base_Sequence (
00809         MAX,
00810         TAO_Bounded_Object_Sequence<T, T_var,MAX>::allocbuf (MAX)
00811       )
00812 {
00813 }

template<class T, class T_var, size_t MAX>
ACE_INLINE TAO_Bounded_Object_Sequence< T, T_var, MAX >::TAO_Bounded_Object_Sequence CORBA::ULong    length,
T **    value,
CORBA::Boolean    release = 0
 

Constructor from data.

Definition at line 549 of file Sequence_T.i.

00552   : TAO_Bounded_Base_Sequence (MAX, length, value, release)
00553 {
00554 }

template<class T, class T_var, size_t MAX>
TAO_Bounded_Object_Sequence< T, T_var, MAX >::TAO_Bounded_Object_Sequence const TAO_Bounded_Object_Sequence< T, T_var, MAX > &   
 

Copy constructor.

Definition at line 816 of file Sequence_T.cpp.

References allocbuf, and TAO_Base_Sequence::buffer_.

00819   : TAO_Bounded_Base_Sequence (rhs)
00820 {
00821   if (rhs.buffer_ != 0)
00822     {
00823       T **tmp1 =
00824         TAO_Bounded_Object_Sequence<T, T_var,MAX>::allocbuf (MAX);
00825 
00826       T ** const tmp2 =
00827         ACE_reinterpret_cast (T** ACE_CAST_CONST, 
00828                               rhs.buffer_);
00829 
00830       for (CORBA::ULong i = 0; i < rhs.length_; i++)
00831         {
00832           tmp1[i] = T_var::tao_duplicate (tmp2[i]);
00833         }
00834 
00835       this->buffer_ = tmp1;
00836     }
00837   else
00838     {
00839       this->buffer_ = 0;
00840     }
00841 }

template<class T, class T_var, size_t MAX>
ACE_INLINE TAO_Bounded_Object_Sequence< T, T_var, MAX >::~TAO_Bounded_Object_Sequence void   
 

destructor.

Definition at line 542 of file Sequence_T.i.

References _deallocate_buffer.

00543 {
00544   this->_deallocate_buffer ();
00545 }


Member Function Documentation

template<class T, class T_var, size_t MAX>
void TAO_Bounded_Object_Sequence< T, T_var, MAX >::_allocate_buffer CORBA::ULong    length [virtual]
 

No default to workaround egcs problem with templates and namespaces.

Implements TAO_Base_Sequence.

Definition at line 929 of file Sequence_T.cpp.

References allocbuf, TAO_Base_Sequence::buffer_, and TAO_Bounded_Base_Sequence::length.

00930 {
00931   // For this class memory is never reallocated so the implementation
00932   // is *really* simple.
00933   this->buffer_ =
00934     TAO_Bounded_Object_Sequence<T, T_var,MAX>::allocbuf (length);
00935 }

template<class T, class T_var, size_t MAX>
void TAO_Bounded_Object_Sequence< T, T_var, MAX >::_deallocate_buffer void    [virtual]
 

Must deallocate the buffer and then set it to zero.

Implements TAO_Base_Sequence.

Definition at line 938 of file Sequence_T.cpp.

References TAO_Base_Sequence::buffer_, freebuf, and TAO_Base_Sequence::release_.

Referenced by ~TAO_Bounded_Object_Sequence.

00939 {
00940   if (this->release_ == 0)
00941     {
00942       return;
00943     }
00944 
00945   T **tmp = ACE_reinterpret_cast (T **, 
00946                                   this->buffer_);
00947   TAO_Bounded_Object_Sequence<T,T_var,MAX>::freebuf (tmp);
00948   this->buffer_ = 0;
00949 }

template<class T, class T_var, size_t MAX>
void TAO_Bounded_Object_Sequence< T, T_var, MAX >::_downcast void *    target,
CORBA_Object *src    ACE_ENV_ARG_DECL_WITH_DEFAULTS
[virtual]
 

Used for sequences of objects to downcast a recently demarshalled object reference into the right type.

Reimplemented from TAO_Base_Sequence.

Definition at line 965 of file Sequence_T.cpp.

References ACE_CHECK, ACE_ENV_ARG_DECL, and ACE_ENV_ARG_PARAMETER.

00968 {
00969   T **tmp = ACE_static_cast (T**, 
00970                              target);
00971 
00972   *tmp = T_var::tao_narrow (src 
00973                             ACE_ENV_ARG_PARAMETER);
00974 
00975   ACE_CHECK;
00976 }

template<class T, class T_var, size_t MAX>
void TAO_Bounded_Object_Sequence< T, T_var, MAX >::_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.

Definition at line 952 of file Sequence_T.cpp.

00954 {
00955   T **tmp = ACE_reinterpret_cast (T **, this->buffer_);
00956 
00957   for (CORBA::ULong i = nl; i < ol; ++i)
00958     {
00959       T_var::tao_release (tmp[i]);
00960       tmp[i] = T_var::tao_nil ();
00961     }
00962 }

template<class T, class T_var, size_t MAX>
CORBA_Object * TAO_Bounded_Object_Sequence< T, T_var, MAX >::_upcast void *    src const [virtual]
 

Used for sequences of object to convert from the derived type into the Object class.

Reimplemented from TAO_Base_Sequence.

Definition at line 979 of file Sequence_T.cpp.

00980 {
00981   return T_var::tao_upcast (src);
00982 }

template<class T, class T_var, size_t MAX>
T ** TAO_Bounded_Object_Sequence< T, T_var, MAX >::allocbuf CORBA::ULong    length [static]
 

Allocate storage for a sequence..

Definition at line 895 of file Sequence_T.cpp.

References ACE_NEW_RETURN.

Referenced by _allocate_buffer, operator=, and TAO_Bounded_Object_Sequence.

00896 {
00897   T **buf = 0;
00898   ACE_NEW_RETURN (buf, 
00899                   T*[MAX], 
00900                   0);
00901 
00902   for (CORBA::ULong i = 0; i < MAX; i++)
00903     {
00904       buf[i] = T_var::tao_nil ();
00905     }
00906 
00907   return buf;
00908 }

template<class T, class T_var, size_t MAX>
void TAO_Bounded_Object_Sequence< T, T_var, MAX >::freebuf T **    buffer [static]
 

Free a buffer allocated by allocbuf() and release each element on it.

Definition at line 911 of file Sequence_T.cpp.

Referenced by _deallocate_buffer.

00912 {
00913   // How much do we deallocate? Easy! allocbuf() always creates MAX
00914   // elements and initialize them to T::_nil().  So we can be
00915   // complaint and call CORBA::release() on each one.
00916   for (CORBA::ULong i = 0; i < MAX; ++i)
00917     {
00918       if (buffer[i] != T_var::tao_nil ())
00919         {
00920           T_var::tao_release (buffer[i]);
00921           buffer[i] = T_var::tao_nil ();
00922         }
00923     }
00924 
00925   delete [] buffer;
00926 }

template<class T, class T_var, size_t MAX>
TAO_Bounded_Object_Sequence< T, T_var, MAX > & TAO_Bounded_Object_Sequence< T, T_var, MAX >::operator= const TAO_Bounded_Object_Sequence< T, T_var, MAX > &   
 

Assignment from another Bounded sequence.

Definition at line 844 of file Sequence_T.cpp.

References allocbuf, TAO_Base_Sequence::buffer_, TAO_Base_Sequence::length_, TAO_Base_Sequence::maximum_, TAO_Base_Sequence::operator=, and TAO_Base_Sequence::release_.

00847 {
00848   if (this == &rhs)
00849     {
00850       return *this;
00851     }
00852 
00853   if (this->release_)
00854     {
00855       T **tmp = ACE_reinterpret_cast (T **, 
00856                                       this->buffer_);
00857 
00858       for (CORBA::ULong i = 0; i < this->length_; ++i)
00859         {
00860           T_var::tao_release (tmp[i]);
00861           tmp[i] = T_var::tao_nil ();
00862         }
00863       // No need to reallocate the buffer since it is always of size
00864       // MAX
00865     }
00866   else
00867     {
00868       if (rhs.maximum_ == 0)
00869         {
00870           this->buffer_ = 0;
00871         }
00872       else
00873         {
00874           this->buffer_ =
00875             TAO_Bounded_Object_Sequence<T,T_var,MAX>::allocbuf (rhs.maximum_);
00876         }
00877     }
00878 
00879   TAO_Bounded_Base_Sequence::operator= (rhs);
00880 
00881   T **tmp1 = ACE_reinterpret_cast (T **, 
00882                                    this->buffer_);
00883   T ** const tmp2 = ACE_reinterpret_cast (T ** ACE_CAST_CONST, 
00884                                           rhs.buffer_);
00885 
00886   for (CORBA::ULong i=0; i < rhs.length_; ++i)
00887     {
00888       tmp1[i] = T_var::tao_duplicate (tmp2[i]);
00889     }
00890 
00891   return *this;
00892 }

template<class T, class T_var, size_t MAX>
ACE_INLINE TAO_Object_Manager< T, T_var > TAO_Bounded_Object_Sequence< T, T_var, MAX >::operator[] CORBA::ULong    slot const
 

Read-write accessor.

Definition at line 557 of file Sequence_T.i.

References ACE_ASSERT, TAO_Base_Sequence::maximum_, and TAO_Base_Sequence::release_.

00558 {
00559   ACE_ASSERT (slot < this->maximum_);
00560   T **const tmp = ACE_reinterpret_cast (T ** ACE_CAST_CONST, this->buffer_);
00561   return TAO_Object_Manager<T,T_var> (tmp + slot, this->release_);
00562 }


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 15:04:56 2003 for TAO by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002