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

Sequence.cpp File Reference

#include "tao_pch.h"
#include "tao/Sequence.h"
#include "tao/Sequence.i"

Include dependency graph for Sequence.cpp:

Include dependency graph

Go to the source code of this file.

Functions

const char * get_rcsid_tao_Sequence (const char *)
 TAO_Unbounded_Sequence< CORBA::Octet >::TAO_Unbounded_Sequence (const TAO_Unbounded_Sequence< CORBA::Octet > &rhs)
TAO_Unbounded_Sequence< CORBA::Octet > & TAO_Unbounded_Sequence< CORBA::Octet >::operator= (const TAO_Unbounded_Sequence< CORBA::Octet > &rhs)
 TAO_Unbounded_Sequence< CORBA::Octet >::TAO_Unbounded_Sequence (CORBA::ULong length, const ACE_Message_Block *mb)
 TAO_Unbounded_Sequence< CORBA::Octet >::~TAO_Unbounded_Sequence (void)
void TAO_Unbounded_Sequence< CORBA::Octet >::_tao_any_destructor (void *x)
void TAO_Unbounded_Sequence< CORBA::Octet >::_allocate_buffer (CORBA::ULong length)
void TAO_Unbounded_Sequence< CORBA::Octet >::_deallocate_buffer (void)
int operator== (const TAO_Unbounded_Sequence< CORBA::Octet > &lhs, const TAO_Unbounded_Sequence< CORBA::Octet > &rhs)
int operator!= (const TAO_Unbounded_Sequence< CORBA::Octet > &lhs, const TAO_Unbounded_Sequence< CORBA::Octet > &rhs)

Variables

const char * rcsid_tao_Sequence = get_rcsid_tao_Sequence ( rcsid_tao_Sequence )


Function Documentation

const char* get_rcsid_tao_Sequence const char *    [inline, static]
 

Definition at line 12 of file Sequence.cpp.

00012 : Sequence.cpp,v 1.1.1.4.2.1 2003/03/14 16:05:15 chad Exp $")

int operator!= const TAO_Unbounded_Sequence< CORBA::Octet > &    lhs,
const TAO_Unbounded_Sequence< CORBA::Octet > &    rhs
 

Definition at line 908 of file Sequence.cpp.

00910 {
00911   return !(lhs == rhs);
00912 }

int operator== const TAO_Unbounded_Sequence< CORBA::Octet > &    lhs,
const TAO_Unbounded_Sequence< CORBA::Octet > &    rhs
 

Definition at line 888 of file Sequence.cpp.

References TAO_Unbounded_Base_Sequence::length.

00890 {
00891   if (rhs.length () != lhs.length ())
00892     {
00893       return 0;
00894     }
00895 
00896   for (CORBA::ULong i = 0; i < rhs.length (); ++i)
00897     {
00898       if (rhs[i] != lhs[i])
00899         {
00900           return 0;
00901         }
00902     }
00903 
00904   return 1;
00905 }

void TAO_Unbounded_Sequence< CORBA::Octet >::_allocate_buffer CORBA::ULong    length
 

Definition at line 832 of file Sequence.cpp.

References TAO_Unbounded_Sequence::allocbuf, TAO_Unbounded_Sequence::freebuf, and ACE_Message_Block::release.

00833 {
00834   CORBA::Octet *tmp = TAO_Unbounded_Sequence<CORBA::Octet>::allocbuf (length);
00835 
00836   if (this->buffer_ != 0)
00837     {
00838       CORBA::Octet *old = ACE_reinterpret_cast (CORBA::Octet *, 
00839                                                 this->buffer_);
00840 
00841       for (CORBA::ULong i = 0; i < this->length_; ++i)
00842         {
00843           tmp[i] = old[i];
00844         }
00845 
00846 #if (TAO_NO_COPY_OCTET_SEQUENCES == 1)
00847       if (this->mb_ != 0)
00848         {
00849           ACE_Message_Block::release (this->mb_);
00850           this->mb_ = 0;
00851         }
00852       else
00853 #endif /* TAO_NO_COPY_OCTET_SEQUENCES == 1 */
00854         if (this->release_)
00855         {
00856           TAO_Unbounded_Sequence<CORBA::Octet>::freebuf (old);
00857         }
00858     }
00859 
00860   this->buffer_ = tmp;
00861 }

void TAO_Unbounded_Sequence< CORBA::Octet >::_deallocate_buffer void   
 

Definition at line 863 of file Sequence.cpp.

References TAO_Unbounded_Sequence::freebuf, and ACE_Message_Block::release.

00864 {
00865   if (this->buffer_ != 0
00866 #if (TAO_NO_COPY_OCTET_SEQUENCES == 1)
00867       && this->mb_ == 0
00868 #endif /* TAO_NO_COPY_OCTET_SEQUENCES == 1 */
00869       && this->release_ != 0)
00870     {
00871       CORBA::Octet *tmp = ACE_reinterpret_cast (CORBA::Octet *, this->buffer_);
00872       TAO_Unbounded_Sequence<CORBA::Octet>::freebuf (tmp);
00873     }
00874 #if (TAO_NO_COPY_OCTET_SEQUENCES == 1)
00875   else
00876     {
00877       ACE_Message_Block::release (this->mb_);
00878       this->mb_ = 0;
00879     }
00880 #endif /* TAO_NO_COPY_OCTET_SEQUENCES == 1 */
00881 
00882   this->buffer_ = 0;
00883 }

void TAO_Unbounded_Sequence< CORBA::Octet >::_tao_any_destructor void *    x
 

Definition at line 823 of file Sequence.cpp.

00824 {
00825   TAO_Unbounded_Sequence<CORBA::Octet> *tmp = 
00826     ACE_static_cast (TAO_Unbounded_Sequence<CORBA::Octet>*,
00827                      x);
00828   delete tmp;
00829 }

TAO_Unbounded_Sequence<CORBA::Octet>& TAO_Unbounded_Sequence< CORBA::Octet >::operator= const TAO_Unbounded_Sequence< CORBA::Octet > &    rhs
 

Definition at line 691 of file Sequence.cpp.

References TAO_Unbounded_Sequence::allocbuf, TAO_Base_Sequence::buffer_, ACE_Message_Block::cont, TAO_Unbounded_Sequence::freebuf, ACE_Message_Block::length, TAO_Base_Sequence::length_, TAO_Base_Sequence::maximum_, ACE_OS_String::memcpy, TAO_Base_Sequence::operator=, ACE_Message_Block::rd_ptr, and ACE_Message_Block::release.

00694 {
00695   if (this == &rhs)
00696     {
00697       return *this;
00698     }
00699 
00700 #if (TAO_NO_COPY_OCTET_SEQUENCES == 1)
00701   if (this->mb_ != 0)
00702     {
00703       ACE_Message_Block::release (this->mb_);
00704       this->mb_ = 0;
00705       this->buffer_ =
00706         TAO_Unbounded_Sequence<CORBA::Octet>::allocbuf (rhs.length_);
00707     }
00708   else
00709 #endif /* (TAO_NO_COPY_OCTET_SEQUENCES == 0) */
00710     if (this->release_)
00711     {
00712       if (this->maximum_ < rhs.length_)
00713         {
00714           // free the old buffer
00715           CORBA::Octet *tmp = ACE_reinterpret_cast (CORBA::Octet *,
00716                                                     this->buffer_);
00717           TAO_Unbounded_Sequence<CORBA::Octet>::freebuf (tmp);
00718           this->buffer_ =
00719             TAO_Unbounded_Sequence<CORBA::Octet>::allocbuf (rhs.length_);
00720         }
00721     }
00722   else
00723     {
00724       if (rhs.maximum_ == 0)
00725         {
00726           this->buffer_ = 0;
00727         }
00728       else
00729         {
00730           this->buffer_ =
00731             TAO_Unbounded_Sequence<CORBA::Octet>::allocbuf (rhs.maximum_);
00732         }
00733     }
00734 
00735   TAO_Unbounded_Base_Sequence::operator= (rhs);
00736 
00737   CORBA::Octet *tmp1 = ACE_reinterpret_cast (CORBA::Octet *, this->buffer_);
00738   CORBA::Octet * const tmp2 = 
00739     ACE_reinterpret_cast (CORBA::Octet * ACE_CAST_CONST, 
00740                           rhs.buffer_);
00741 
00742 #if (TAO_NO_COPY_OCTET_SEQUENCES == 1)
00743   // for (CORBA::ULong i = 0; i < this->length_; ++i)
00744   // tmp1[i] = tmp2[i];
00745   if (rhs.mb_ == 0)
00746     {
00747       ACE_OS::memcpy (tmp1, 
00748                       tmp2, 
00749                       this->length_);
00750     }
00751   else
00752     {
00753       size_t offset = 0;
00754 
00755       for (const ACE_Message_Block *i = rhs.mb_; i != 0; i = i->cont ())
00756         {
00757           ACE_OS::memcpy (tmp1 + offset, 
00758                           i->rd_ptr (), 
00759                           i->length ());
00760           offset += i->length ();
00761         }
00762     }
00763 #else /* (TAO_NO_COPY_OCTET_SEQUENCES == 0) */
00764   ACE_OS::memcpy (tmp1, tmp2, this->length_);
00765 #endif /* (TAO_NO_COPY_OCTET_SEQUENCES == 0) */
00766 
00767   return *this;
00768 }

TAO_Unbounded_Sequence< CORBA::Octet >::TAO_Unbounded_Sequence CORBA::ULong    length,
const ACE_Message_Block   mb
 

Definition at line 771 of file Sequence.cpp.

References ACE_BIT_DISABLED, ACE_ptr_align_binary, ACE_Message_Block::DONT_DELETE, ACE_Message_Block::duplicate, ACE_CDR::MAX_ALIGNMENT, and ACE_Message_Block::Message_Flags.

00775   :  TAO_Unbounded_Base_Sequence (length,
00776                                   length,
00777                                   mb->rd_ptr (),
00778                                   0),
00779      mb_ (0)
00780 {
00781   // Get the message block flags.
00782   ACE_Message_Block::Message_Flags flg = mb->self_flags ();
00783 
00784   // If the DONT_DELETE flag is disabled just a duplicate would
00785   // help. If the DONT_DELETE flag is enabled a deep copy is needed as
00786   // the contents would be on stack. Just incrementing the ref count
00787   // on the stack based data block would only crash the program when
00788   // the stack unwinds
00789   if (ACE_BIT_DISABLED (flg,
00790                         ACE_Message_Block::DONT_DELETE))
00791     {
00792       this->mb_ = ACE_Message_Block::duplicate (mb);
00793     }
00794   else
00795     {
00796       // As we are in CORBA mode, all the data blocks would be aligned
00797       // on an 8 byte boundary
00798       ACE_Message_Block msgb (*mb,
00799                               ACE_CDR::MAX_ALIGNMENT);
00800 
00801       // Get the base pointer of the incoming message block
00802       char *start = ACE_ptr_align_binary (mb->base (),
00803                                           ACE_CDR::MAX_ALIGNMENT);
00804 
00805       // Get the read and write displacements in the incoming stream
00806       size_t rd_pos = mb->rd_ptr () - start;
00807       size_t wr_pos = mb->wr_ptr () - start;
00808 
00809       this->mb_ = ACE_Message_Block::duplicate (&msgb);
00810 
00811       this->mb_->rd_ptr (rd_pos);
00812       this->mb_->wr_ptr (wr_pos);
00813     }
00814 }

TAO_Unbounded_Sequence< CORBA::Octet >::TAO_Unbounded_Sequence const TAO_Unbounded_Sequence< CORBA::Octet > &    rhs
 

Definition at line 640 of file Sequence.cpp.

References TAO_Unbounded_Sequence::allocbuf, ACE_Message_Block::cont, ACE_Message_Block::length, ACE_OS_String::memcpy, ACE_Message_Block::rd_ptr, and TAO_NO_COPY_OCTET_SEQUENCES.

00643   : TAO_Unbounded_Base_Sequence (rhs)
00644 #if (TAO_NO_COPY_OCTET_SEQUENCES == 1)
00645   , mb_ (0)
00646 #endif /* (TAO_NO_COPY_OCTET_SEQUENCES == 0) */
00647 {
00648   if (rhs.buffer_ != 0)
00649     {
00650       CORBA::Octet *tmp1 =
00651        TAO_Unbounded_Sequence<CORBA::Octet>::allocbuf (this->maximum_);
00652 
00653 
00654       CORBA::Octet * const tmp2 =
00655         ACE_reinterpret_cast (CORBA::Octet * ACE_CAST_CONST,
00656                               rhs.buffer_);
00657 
00658 #if (TAO_NO_COPY_OCTET_SEQUENCES == 1)
00659       if (rhs.mb_ == 0)
00660         {
00661           ACE_OS::memcpy (tmp1,
00662                           tmp2,
00663                           this->length_);
00664         }
00665       else
00666         {
00667           size_t offset = 0;
00668 
00669           for (const ACE_Message_Block *i = rhs.mb_; i != 0; i = i->cont ())
00670             {
00671               ACE_OS::memcpy (tmp1 + offset,
00672                               i->rd_ptr (),
00673                               i->length ());
00674 
00675               offset += i->length ();
00676             }
00677         }
00678 #else /* (TAO_NO_COPY_OCTET_SEQUENCES == 0) */
00679       ACE_OS::memcpy (tmp1, tmp2, this->length_);
00680 #endif /* (TAO_NO_COPY_OCTET_SEQUENCES == 0) */
00681 
00682       this->buffer_ = tmp1;
00683     }
00684   else
00685     {
00686       this->buffer_ = 0;
00687     }
00688 }

TAO_Unbounded_Sequence< CORBA::Octet >::~TAO_Unbounded_Sequence void   
 

Definition at line 817 of file Sequence.cpp.

00818 {
00819   this->_deallocate_buffer ();
00820 }


Variable Documentation

const char* rcsid_tao_Sequence = get_rcsid_tao_Sequence ( rcsid_tao_Sequence ) [static]
 

Definition at line 12 of file Sequence.cpp.


Generated on Mon Jun 16 14:39:41 2003 for TAO by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002