// This may look like C, but it's really -*- C++ -*- // $Id$ // *************************************************** // Operations on the generic unbounded sequence class. // *************************************************** template ACE_INLINE TAO_Unbounded_Sequence::TAO_Unbounded_Sequence (void) { } template ACE_INLINE T * TAO_Unbounded_Sequence::get_buffer (CORBA::Boolean orphan) { if (orphan == CORBA::B_FALSE) { // We retain ownership. if (this->buffer_ == 0) this->buffer_ = (void *) new T[this->length_]; } else // if (orphan == CORBA::B_TRUE) { if (this->release_ == CORBA::B_FALSE) // Oops, it's not our buffer to relinquish... return 0; else { // We set the state back to default and relinquish // ownership. this->maximum_ = 0; this->length_ = 0; this->buffer_ = 0; this->release_ = CORBA::B_FALSE; } } return (T *) this->buffer_; } template ACE_INLINE const T * TAO_Unbounded_Sequence::get_buffer (void) const { return (const T *) 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_ == CORBA::B_TRUE) TAO_Unbounded_Sequence::freebuf ((T *) this->buffer_); this->buffer_ = data; this->release_ = release; } 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::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_Unbounded_Sequence::operator[] (CORBA::ULong i) const { ACE_ASSERT (i < this->maximum_); T * const tmp = ACE_reinterpret_cast (T* ACE_CAST_CONST, this->buffer_); return tmp[i]; } 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; } // *************************************************** // operations on the generic Bounded sequence class // *************************************************** template ACE_INLINE T * TAO_Bounded_Sequence::get_buffer (CORBA::Boolean orphan) { if (orphan == CORBA::B_FALSE) { // We retain ownership. if (this->buffer_ == 0) this->buffer_ = (void *) new T[this->maximum_]; } else // if (orphan == CORBA::B_TRUE) { if (this->release_ == CORBA::B_FALSE) // Oops, it's not our buffer to relinquish... return 0; else { // We set the state back to default and relinquish // ownership. this->maximum_ = 0; this->length_ = 0; this->buffer_ = 0; this->release_ = CORBA::B_FALSE; } } return (T *) this->buffer_; } template ACE_INLINE const T * TAO_Bounded_Sequence::get_buffer (void) const { return (const T *) 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_ == CORBA::B_TRUE) TAO_Bounded_Sequence::freebuf ((T *) this->buffer_); this->buffer_ = data; this->release_ = release; } template ACE_INLINE TAO_Bounded_Sequence::TAO_Bounded_Sequence (void) { } template ACE_INLINE TAO_Bounded_Sequence::TAO_Bounded_Sequence (CORBA::ULong length, T *data, CORBA::Boolean release) : TAO_Bounded_Base_Sequence (length, MAX, data, 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*,this->buffer_); return tmp[i]; } 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; } // ************************************************************* // 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_; } // ************************************************************* // 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_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) { } template ACE_INLINE TAO_String_Manager TAO_Bounded_String_Sequence::operator[] (CORBA::ULong index) const { ACE_ASSERT (index < this->maximum_); char **const tmp = ACE_reinterpret_cast (char ** ACE_CAST_CONST, this->buffer_); return TAO_String_Manager (tmp + index, this->release_); }