// 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) { result = TAO_Unbounded_Sequence::allocbuf (this->length_); this->buffer_ = result; } 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; } /* else // Oops, it's not our buffer to relinquish... return 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); } TAO_Unbounded_Sequence::freebuf ((T *) this->buffer_); 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) : TAO_Bounded_Base_Sequence (MAX, 0, allocbuf (MAX), 0) { } 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) { this->_allocate_buffer (MAX); } 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; } 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 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 const T * TAO_Object_Manager::in (void) const { return *this->ptr_; } template ACE_INLINE T *& TAO_Object_Manager::inout (void) { return *this->ptr_; } template ACE_INLINE T *& TAO_Object_Manager::out (void) { CORBA::release (*this->ptr_); *this->ptr_ = T::_nil (); return *this->ptr_; } template ACE_INLINE T * TAO_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 index) const { ACE_ASSERT (index < this->maximum_); T ** const tmp = ACE_reinterpret_cast (T ** ACE_CAST_CONST, this->buffer_); return TAO_Object_Manager (tmp + index, 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 index) const { ACE_ASSERT (index < this->maximum_); T **const tmp = ACE_reinterpret_cast (T ** ACE_CAST_CONST, this->buffer_); return TAO_Object_Manager (tmp + index, 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_Object_Manager TAO_Unbounded_Pseudo_Sequence::operator[] (CORBA::ULong index) const { ACE_ASSERT (index < this->maximum_); T ** const tmp = ACE_reinterpret_cast (T ** ACE_CAST_CONST, this->buffer_); return TAO_Object_Manager (tmp + index, 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_Object_Manager TAO_Bounded_Pseudo_Sequence::operator[] (CORBA::ULong index) const { ACE_ASSERT (index < this->maximum_); T **const tmp = ACE_reinterpret_cast (T ** ACE_CAST_CONST, this->buffer_); return TAO_Object_Manager (tmp + index, this->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) { }