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

TAO_Bounded_Valuetype_Sequence Class Template Reference

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

#include <Sequence_T.h>

Inheritance diagram for TAO_Bounded_Valuetype_Sequence:

Inheritance graph
[legend]
Collaboration diagram for TAO_Bounded_Valuetype_Sequence:

Collaboration graph
[legend]
List of all members.

Public Methods

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

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

 ~TAO_Bounded_Valuetype_Sequence (void)
 destructor. More...

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

TAO_Valuetype_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)

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_Valuetype_Sequence< T, T_var, MAX >

Parametric sequence for types that require managers.

Please see the documentation for the unbounded case.

Definition at line 997 of file Sequence_T.h.


Constructor & Destructor Documentation

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

Definition at line 1590 of file Sequence_T.cpp.

01593   : TAO_Bounded_Base_Sequence (
01594         MAX,
01595         TAO_Bounded_Valuetype_Sequence<T, T_var, MAX>::allocbuf (MAX)
01596       )
01597 {
01598 }

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

Constructor from data.

Definition at line 673 of file Sequence_T.i.

00678   : TAO_Bounded_Base_Sequence (MAX, length, value, release)
00679 {
00680 }

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

Copy constructor.

Definition at line 1601 of file Sequence_T.cpp.

References allocbuf, and TAO_Base_Sequence::buffer_.

01604   : TAO_Bounded_Base_Sequence (rhs)
01605 {
01606   if (rhs.buffer_ != 0)
01607     {
01608       T **tmp1 =
01609         TAO_Bounded_Valuetype_Sequence<T, T_var, MAX>::allocbuf (MAX);
01610 
01611       T ** const tmp2 =
01612         ACE_reinterpret_cast (T** ACE_CAST_CONST, rhs.buffer_);
01613 
01614       for (CORBA::ULong i = 0; i < rhs.length_; i++)
01615         {
01616           T_var::tao_add_ref (tmp2[i]);
01617           tmp1[i] = tmp2[i];
01618         }
01619 
01620       this->buffer_ = tmp1;
01621     }
01622   else
01623     {
01624       this->buffer_ = 0;
01625     }
01626 }

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

destructor.

Definition at line 664 of file Sequence_T.i.

References _deallocate_buffer.

00667 {
00668   this->_deallocate_buffer ();
00669 }


Member Function Documentation

template<class T, class T_var, size_t MAX>
void TAO_Bounded_Valuetype_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 1721 of file Sequence_T.cpp.

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

01724 {
01725   // For this class memory is never reallocated so the implementation
01726   // is *really* simple.
01727   this->buffer_ =
01728     TAO_Bounded_Valuetype_Sequence<T, T_var, MAX>::allocbuf (length);
01729 }

template<class T, class T_var, size_t MAX>
void TAO_Bounded_Valuetype_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 1733 of file Sequence_T.cpp.

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

Referenced by ~TAO_Bounded_Valuetype_Sequence.

01734 {
01735   if (this->release_ == 0)
01736     {
01737       return;
01738     }
01739 
01740   T **tmp = ACE_reinterpret_cast (T **, 
01741                                   this->buffer_);
01742   TAO_Bounded_Valuetype_Sequence<T, T_var, MAX>::freebuf (tmp);
01743   this->buffer_ = 0;
01744 }

template<class T, class T_var, size_t MAX>
void TAO_Bounded_Valuetype_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 1748 of file Sequence_T.cpp.

01750 {
01751   T **tmp = ACE_reinterpret_cast (T **, 
01752                                   this->buffer_);
01753 
01754   for (CORBA::ULong i = nl; i < ol; ++i)
01755     {
01756       T_var::tao_remove_ref (tmp[i]);
01757       tmp[i] = 0;
01758     }
01759 }

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

Allocate storage for a sequence..

Definition at line 1685 of file Sequence_T.cpp.

References ACE_NEW_RETURN.

Referenced by _allocate_buffer, operator=, and TAO_Bounded_Valuetype_Sequence.

01686 {
01687   T **buf = 0;
01688   ACE_NEW_RETURN (buf, 
01689                   T*[MAX], 
01690                   0);
01691 
01692   for (CORBA::ULong i = 0; i < MAX; ++i)
01693     {
01694       buf[i] = 0;
01695     }
01696 
01697   return buf;
01698 }

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

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

Definition at line 1702 of file Sequence_T.cpp.

Referenced by _deallocate_buffer.

01703 {
01704   // How much do we deallocate? Easy! allocbuf() always creates MAX
01705   // elements and initialize them to T::_nil().  So we can be
01706   // complaint and call CORBA::release() on each one.
01707   for (CORBA::ULong i = 0; i < MAX; ++i)
01708     {
01709       if (buffer[i] != 0)
01710         {
01711           T_var::tao_remove_ref (buffer[i]);
01712           buffer[i] = 0;
01713         }
01714     }
01715 
01716   delete [] buffer;
01717 }

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

Assignment from another Bounded sequence.

Definition at line 1630 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_.

01633 {
01634   if (this == &rhs)
01635     {
01636       return *this;
01637     }
01638 
01639   if (this->release_)
01640     {
01641       T **tmp = ACE_reinterpret_cast (T **, 
01642                                       this->buffer_);
01643 
01644       for (CORBA::ULong i = 0; i < this->length_; ++i)
01645         {
01646           T_var::tao_remove_ref (tmp[i]);
01647           tmp[i] = 0;
01648         }
01649       // No need to reallocate the buffer since it is always of size
01650       // MAX
01651     }
01652   else
01653     {
01654       if (rhs.maximum_ == 0)
01655         {
01656           this->buffer_ = 0;
01657         }
01658       else
01659         {
01660           this->buffer_ =
01661             TAO_Bounded_Valuetype_Sequence<T, T_var, MAX>::allocbuf (
01662                 rhs.maximum_
01663               );
01664         }
01665     }
01666 
01667   TAO_Bounded_Base_Sequence::operator= (rhs);
01668 
01669   T **tmp1 = ACE_reinterpret_cast (T **, 
01670                                    this->buffer_);
01671   T ** const tmp2 = ACE_reinterpret_cast (T ** ACE_CAST_CONST, 
01672                                           rhs.buffer_);
01673 
01674   for (CORBA::ULong i=0; i < rhs.length_; ++i)
01675     {
01676       T_var::tao_add_ref (tmp2[i]);
01677       tmp1[i] = tmp2[i];
01678     }
01679 
01680   return *this;
01681 }

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

Read-write accessor.

Definition at line 685 of file Sequence_T.i.

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

00688 {
00689   ACE_ASSERT (slot < this->maximum_);
00690   T **const tmp = ACE_reinterpret_cast (T ** ACE_CAST_CONST, this->buffer_);
00691   return TAO_Valuetype_Manager<T,T_var> (tmp + slot, this->release_);
00692 }


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