// This may look like C, but it's really -*- C++ -*- // $Id$ // *************************************************** // Operations on the generic unbounded sequence class. // *************************************************** template ACE_INLINE T * TAO_Unbounded_Sequence::allocbuf (CORBA::ULong size) { return new T[size]; } template ACE_INLINE void TAO_Unbounded_Sequence::freebuf (T *buffer) { delete [] buffer; } template ACE_INLINE TAO_Unbounded_Sequence::TAO_Unbounded_Sequence (void) { } template ACE_INLINE TAO_Unbounded_Sequence::TAO_Unbounded_Sequence (CORBA::ULong maximum) : TAO_Unbounded_Base_Sequence (maximum, TAO_Unbounded_Sequence::allocbuf (maximum)) { } template ACE_INLINE TAO_Unbounded_Sequence::TAO_Unbounded_Sequence (CORBA::ULong maximum, CORBA::ULong length, T *data, CORBA::Boolean release) : TAO_Unbounded_Base_Sequence (maximum, length, data, release) { } template ACE_INLINE T * TAO_Unbounded_Sequence::get_buffer (CORBA::Boolean orphan) { T *result = 0; if (orphan == 0) { // We retain ownership. if (this->buffer_ == 0) { if (this->length_ > 0) { result = TAO_Unbounded_Sequence::allocbuf (this->length_); this->buffer_ = result; this->release_ = 1; } } else { result = ACE_reinterpret_cast (T*, this->buffer_); } } else // if (orphan == 1) { result = ACE_reinterpret_cast (T*, this->buffer_); if (this->release_ != 0) { // We set the state back to default and relinquish // ownership. this->maximum_ = 0; this->length_ = 0; this->buffer_ = 0; this->release_ = 0; } } return result; } template ACE_INLINE const T * TAO_Unbounded_Sequence::get_buffer (void) const { return ACE_reinterpret_cast (const T * ACE_CAST_CONST, this->buffer_); } template ACE_INLINE void TAO_Unbounded_Sequence::replace (CORBA::ULong max, CORBA::ULong length, T *data, CORBA::Boolean release) { this->maximum_ = max; this->length_ = length; if (this->buffer_ && this->release_ == 1) { T *tmp = ACE_reinterpret_cast(T*,this->buffer_); TAO_Unbounded_Sequence::freebuf (tmp); } this->buffer_ = data; this->release_ = release; } // *************************************************** // operations on the generic Bounded sequence class // *************************************************** template ACE_INLINE T * TAO_Bounded_Sequence::allocbuf (CORBA::ULong) { return new T[MAX]; } template ACE_INLINE void TAO_Bounded_Sequence::freebuf (T *buffer) { delete [] buffer; } template ACE_INLINE TAO_Bounded_Sequence::TAO_Bounded_Sequence (void) { this->maximum_ = MAX; } template ACE_INLINE TAO_Bounded_Sequence::TAO_Bounded_Sequence (CORBA::ULong length, T *data, CORBA::Boolean release) : TAO_Bounded_Base_Sequence (MAX, length, data, release) { } template ACE_INLINE T * TAO_Bounded_Sequence::get_buffer (CORBA::Boolean orphan) { T *result = 0; if (orphan == 0) { // We retain ownership. if (this->buffer_ == 0) { result = TAO_Bounded_Sequence::allocbuf (this->maximum_); this->buffer_ = result; this->release_ = 1; } else { result = ACE_reinterpret_cast (T*, this->buffer_); } } else // if (orphan == 1) { if (this->release_ != 0) { // We set the state back to default and relinquish // ownership. result = ACE_reinterpret_cast(T*,this->buffer_); this->maximum_ = 0; this->length_ = 0; this->buffer_ = 0; this->release_ = 0; } } return result; } template ACE_INLINE const T * TAO_Bounded_Sequence::get_buffer (void) const { return ACE_reinterpret_cast(const T * ACE_CAST_CONST, this->buffer_); } template ACE_INLINE void TAO_Bounded_Sequence::replace (CORBA::ULong max, CORBA::ULong length, T *data, CORBA::Boolean release) { this->maximum_ = max; this->length_ = length; if (this->buffer_ && this->release_ == 1) { T* tmp = ACE_reinterpret_cast(T*, this->buffer_); TAO_Bounded_Sequence::freebuf (tmp); } this->buffer_ = data; this->release_ = release; } template ACE_INLINE T & TAO_Bounded_Sequence::operator[] (CORBA::ULong i) { ACE_ASSERT (i < this->maximum_); T *tmp = ACE_reinterpret_cast (T*,this->buffer_); return tmp[i]; } template ACE_INLINE const T & TAO_Bounded_Sequence::operator[] (CORBA::ULong i) const { ACE_ASSERT (i < this->maximum_); const T* tmp = ACE_reinterpret_cast (const T* ACE_CAST_CONST,this->buffer_); return tmp[i]; } // ************************************************************* // Inline operations for class TAO_Object_Manager // ************************************************************* template ACE_INLINE TAO_Object_Manager::~TAO_Object_Manager (void) { } template ACE_INLINE TAO_Object_Manager::TAO_Object_Manager (const TAO_Object_Manager &rhs) : ptr_ (rhs.ptr_), release_ (rhs.release_) { } template ACE_INLINE TAO_Object_Manager::TAO_Object_Manager(T** buffer, CORBA::Boolean release) : ptr_ (buffer), release_ (release) { } template ACE_INLINE T * TAO_Object_Manager::operator-> (void) const { return *this->ptr_; } template ACE_INLINE TAO_Object_Manager::operator const T_var () const { return T_var::tao_duplicate (*this->ptr_); } template ACE_INLINE TAO_Object_Manager::operator const T* () const // cast { return *this->ptr_; } template ACE_INLINE TAO_Object_Manager::operator T* &() // cast { return *this->ptr_; } template ACE_INLINE T * TAO_Object_Manager::in (void) const { return *this->ptr_; } template ACE_INLINE T *& TAO_Object_Manager::inout (void) { return *this->ptr_; } // ************************************************************* // Inline operations for class TAO_Pseudo_Object_Manager // ************************************************************* template ACE_INLINE TAO_Pseudo_Object_Manager::~TAO_Pseudo_Object_Manager (void) { } template ACE_INLINE TAO_Pseudo_Object_Manager:: TAO_Pseudo_Object_Manager (const TAO_Pseudo_Object_Manager &rhs) : ptr_ (rhs.ptr_), release_ (rhs.release_) { } template ACE_INLINE TAO_Pseudo_Object_Manager:: TAO_Pseudo_Object_Manager(T** buffer, CORBA::Boolean release) : ptr_ (buffer), release_ (release) { } template ACE_INLINE T * TAO_Pseudo_Object_Manager::operator-> (void) const { return *this->ptr_; } template ACE_INLINE TAO_Pseudo_Object_Manager::operator const T* () const // cast { return *this->ptr_; } template ACE_INLINE TAO_Pseudo_Object_Manager::operator T* &() // cast { return *this->ptr_; } template ACE_INLINE T * TAO_Pseudo_Object_Manager::in (void) const { return *this->ptr_; } template ACE_INLINE T *& TAO_Pseudo_Object_Manager::inout (void) { return *this->ptr_; } template ACE_INLINE T *& TAO_Pseudo_Object_Manager::out (void) { CORBA::release (*this->ptr_); *this->ptr_ = T::_nil (); return *this->ptr_; } template ACE_INLINE T * TAO_Pseudo_Object_Manager::_retn (void) { T *temp = *this->ptr_; *this->ptr_ = T::_nil (); return temp; } // ************************************************************* // class TAO_Unbounded_Object_Sequence // ************************************************************* //default constructor template ACE_INLINE TAO_Unbounded_Object_Sequence::TAO_Unbounded_Object_Sequence (void) { } template ACE_INLINE TAO_Unbounded_Object_Sequence:: TAO_Unbounded_Object_Sequence (CORBA::ULong maximum, CORBA::ULong length, T* *value, CORBA::Boolean release) : TAO_Unbounded_Base_Sequence (maximum, length, value, release) { } template ACE_INLINE TAO_Object_Manager TAO_Unbounded_Object_Sequence::operator[] (CORBA::ULong slot) const { ACE_ASSERT (slot < this->maximum_); T ** const tmp = ACE_reinterpret_cast (T ** ACE_CAST_CONST, this->buffer_); return TAO_Object_Manager (tmp + slot, this->release_); } // ************************************************************* // class TAO_Bounded_Object_Sequence // ************************************************************* template ACE_INLINE TAO_Bounded_Object_Sequence::~TAO_Bounded_Object_Sequence (void) { this->_deallocate_buffer (); } template ACE_INLINE TAO_Bounded_Object_Sequence:: TAO_Bounded_Object_Sequence (CORBA::ULong length, T **value, CORBA::Boolean release) : TAO_Bounded_Base_Sequence (MAX, length, value, release) { } template ACE_INLINE TAO_Object_Manager TAO_Bounded_Object_Sequence::operator[] (CORBA::ULong slot) const { ACE_ASSERT (slot < this->maximum_); T **const tmp = ACE_reinterpret_cast (T ** ACE_CAST_CONST, this->buffer_); return TAO_Object_Manager (tmp + slot, this->release_); } // ************************************************************* // class TAO_Unbounded_Pseudo_Sequence // ************************************************************* //default constructor template ACE_INLINE TAO_Unbounded_Pseudo_Sequence::TAO_Unbounded_Pseudo_Sequence (void) { } template ACE_INLINE TAO_Unbounded_Pseudo_Sequence:: TAO_Unbounded_Pseudo_Sequence (CORBA::ULong maximum, CORBA::ULong length, T* *value, CORBA::Boolean release) : TAO_Unbounded_Base_Sequence (maximum, length, value, release) { } template ACE_INLINE TAO_Pseudo_Object_Manager TAO_Unbounded_Pseudo_Sequence::operator[] (CORBA::ULong slot) const { ACE_ASSERT (slot < this->maximum_); T ** const tmp = ACE_reinterpret_cast (T ** ACE_CAST_CONST, this->buffer_); return TAO_Pseudo_Object_Manager (tmp + slot, this->release_); } // ************************************************************* // class TAO_Bounded_Pseudo_Sequence // ************************************************************* template ACE_INLINE TAO_Bounded_Pseudo_Sequence::~TAO_Bounded_Pseudo_Sequence (void) { this->_deallocate_buffer (); } template ACE_INLINE TAO_Bounded_Pseudo_Sequence:: TAO_Bounded_Pseudo_Sequence (CORBA::ULong length, T **value, CORBA::Boolean release) : TAO_Bounded_Base_Sequence (MAX, length, value, release) { } template ACE_INLINE TAO_Pseudo_Object_Manager TAO_Bounded_Pseudo_Sequence::operator[] (CORBA::ULong slot) const { ACE_ASSERT (slot < this->maximum_); T **const tmp = ACE_reinterpret_cast (T ** ACE_CAST_CONST, this->buffer_); return TAO_Pseudo_Object_Manager (tmp + slot, this->release_); } // ************************************************************* // class TAO_Unbounded_Array_Sequence // ************************************************************* template ACE_INLINE void TAO_Unbounded_Array_Sequence::freebuf (T *buffer) { if (buffer == 0) return; delete [] buffer; } //default constructor template ACE_INLINE TAO_Unbounded_Array_Sequence::TAO_Unbounded_Array_Sequence (void) { } template ACE_INLINE TAO_Unbounded_Array_Sequence:: TAO_Unbounded_Array_Sequence (CORBA::ULong maximum) : TAO_Unbounded_Base_Sequence (maximum, TAO_Unbounded_Array_Sequence::allocbuf (maximum)) { } template ACE_INLINE TAO_Unbounded_Array_Sequence:: TAO_Unbounded_Array_Sequence (CORBA::ULong maximum, CORBA::ULong length, T *value, CORBA::Boolean release) : TAO_Unbounded_Base_Sequence (maximum, length, value, release) { } template ACE_INLINE T & TAO_Unbounded_Array_Sequence::operator[] (CORBA::ULong i) { ACE_ASSERT (i < this->maximum_); #if defined (__SUNPRO_CC) && (__SUNPRO_CC < 0x500) return ((T*) this->buffer_)[i]; #else /* (__SUNPRO_CC) && (__SUNPRO_CC < 0x500) */ return (ACE_reinterpret_cast (T*, this->buffer_))[i]; #endif /* (__SUNPRO_CC) && (__SUNPRO_CC < 0x500) */ } template ACE_INLINE const T & TAO_Unbounded_Array_Sequence::operator[] (CORBA::ULong i) const { ACE_ASSERT (i < this->maximum_); #if defined (__SUNPRO_CC) && (__SUNPRO_CC < 0x500) return ((const T* ACE_CAST_CONST) this->buffer_)[i]; #else /* (__SUNPRO_CC) && (__SUNPRO_CC < 0x500) */ return (ACE_reinterpret_cast (const T* ACE_CAST_CONST, this->buffer_))[i]; #endif /* (__SUNPRO_CC) && (__SUNPRO_CC < 0x500) */ } template ACE_INLINE T * TAO_Unbounded_Array_Sequence::get_buffer (CORBA::Boolean orphan) { T *result = 0; if (orphan == 0) { // We retain ownership. if (this->buffer_ == 0) { if (this->length_ > 0) { result = TAO_Unbounded_Array_Sequence::allocbuf ( this->length_ ); this->buffer_ = result; this->release_ = 1; } } else { result = ACE_reinterpret_cast (T*, this->buffer_); } } else // if (orphan == 1) { if (this->release_ != 0) { // We set the state back to default and relinquish // ownership. result = ACE_reinterpret_cast (T*, this->buffer_); this->maximum_ = 0; this->length_ = 0; this->buffer_ = 0; this->release_ = 0; } } return result; } template ACE_INLINE const T * TAO_Unbounded_Array_Sequence::get_buffer (void) const { return ACE_reinterpret_cast (const T * ACE_CAST_CONST, this->buffer_); } template ACE_INLINE void TAO_Unbounded_Array_Sequence::replace (CORBA::ULong max, CORBA::ULong length, T *data, CORBA::Boolean release) { this->maximum_ = max; this->length_ = length; if (this->buffer_ && this->release_ == 1) { T *tmp = ACE_reinterpret_cast (T*, this->buffer_); TAO_Unbounded_Array_Sequence::freebuf (tmp); } this->buffer_ = data; this->release_ = release; } // ************************************************************* // class TAO_Bounded_Array_Sequence // ************************************************************* template ACE_INLINE void TAO_Bounded_Array_Sequence::freebuf (T *buffer) { if (buffer == 0) return; delete [] buffer; } template ACE_INLINE TAO_Bounded_Array_Sequence:: TAO_Bounded_Array_Sequence (void) : TAO_Bounded_Base_Sequence (MAX, 0, allocbuf (MAX), 1) { } template ACE_INLINE TAO_Bounded_Array_Sequence:: TAO_Bounded_Array_Sequence (CORBA::ULong length, T *data, CORBA::Boolean release) : TAO_Bounded_Base_Sequence (MAX, length, data, release) { } template ACE_INLINE T & TAO_Bounded_Array_Sequence::operator[] (CORBA::ULong i) { ACE_ASSERT (i < this->maximum_); #if defined (__SUNPRO_CC) && (__SUNPRO_CC < 0x500) return ((T*) this->buffer_)[i]; #else /* (__SUNPRO_CC) && (__SUNPRO_CC < 0x500) */ return (ACE_reinterpret_cast (T*, this->buffer_))[i]; #endif /* (__SUNPRO_CC) && (__SUNPRO_CC < 0x500) */ } template ACE_INLINE const T & TAO_Bounded_Array_Sequence::operator[] (CORBA::ULong i) const { ACE_ASSERT (i < this->maximum_); #if defined (__SUNPRO_CC) && (__SUNPRO_CC < 0x500) return ((const T* ACE_CAST_CONST) this->buffer_)[i]; #else /* (__SUNPRO_CC) && (__SUNPRO_CC < 0x500) */ return (ACE_reinterpret_cast (const T* ACE_CAST_CONST, this->buffer_))[i]; #endif /* (__SUNPRO_CC) && (__SUNPRO_CC < 0x500) */ } template ACE_INLINE T * TAO_Bounded_Array_Sequence::get_buffer (CORBA::Boolean orphan) { T *result = 0; if (orphan == 0) { // We retain ownership. if (this->buffer_ == 0) { result = TAO_Bounded_Array_Sequence::allocbuf (this->maximum_); this->buffer_ = result; this->release_ = 1; } else { result = ACE_reinterpret_cast (T*, this->buffer_); } } else // if (orphan == 1) { if (this->release_ != 0) { // We set the state back to default and relinquish // ownership. result = ACE_reinterpret_cast(T*,this->buffer_); this->maximum_ = 0; this->length_ = 0; this->buffer_ = 0; this->release_ = 0; } } return result; } template ACE_INLINE const T * TAO_Bounded_Array_Sequence::get_buffer (void) const { return ACE_reinterpret_cast (const T * ACE_CAST_CONST, this->buffer_); } template ACE_INLINE void TAO_Bounded_Array_Sequence::replace (CORBA::ULong max, CORBA::ULong length, T *data, CORBA::Boolean release) { this->maximum_ = max; this->length_ = length; if (this->buffer_ && this->release_ == 1) { T* tmp = ACE_reinterpret_cast (T*, this->buffer_); TAO_Bounded_Array_Sequence::freebuf (tmp); } this->buffer_ = data; this->release_ = release; } // ************************************************************* // class TAO_Bounded_String_Sequence // ************************************************************* template ACE_INLINE TAO_Bounded_String_Sequence::~TAO_Bounded_String_Sequence (void) { this->_deallocate_buffer (); } template ACE_INLINE TAO_Bounded_String_Sequence:: TAO_Bounded_String_Sequence (CORBA::ULong length, char **value, CORBA::Boolean release) : TAO_Bounded_Base_Sequence (MAX, length, value, release) { } // ************************************************************* // class TAO_Bounded_WString_Sequence // ************************************************************* template ACE_INLINE TAO_Bounded_WString_Sequence::~TAO_Bounded_WString_Sequence (void) { this->_deallocate_buffer (); } template ACE_INLINE TAO_Bounded_WString_Sequence:: TAO_Bounded_WString_Sequence (CORBA::ULong length, CORBA::WChar **value, CORBA::Boolean release) : TAO_Bounded_Base_Sequence (MAX, length, value, release) { }