summaryrefslogtreecommitdiff
path: root/TAO/tao/Sequence_T.i
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/tao/Sequence_T.i')
-rw-r--r--TAO/tao/Sequence_T.i155
1 files changed, 90 insertions, 65 deletions
diff --git a/TAO/tao/Sequence_T.i b/TAO/tao/Sequence_T.i
index 15015f25b21..5c06708a01e 100644
--- a/TAO/tao/Sequence_T.i
+++ b/TAO/tao/Sequence_T.i
@@ -5,43 +5,82 @@
// Operations on the generic unbounded sequence class.
// ***************************************************
+template <class T> ACE_INLINE T *
+TAO_Unbounded_Sequence<T>::allocbuf (CORBA::ULong size)
+{
+ return new T[size];
+}
+
+template <class T> ACE_INLINE void
+TAO_Unbounded_Sequence<T>::freebuf (T *buffer)
+{
+ delete [] buffer;
+}
+
template <class T> ACE_INLINE
TAO_Unbounded_Sequence<T>::TAO_Unbounded_Sequence (void)
{
}
+template <class T> ACE_INLINE
+TAO_Unbounded_Sequence<T>::TAO_Unbounded_Sequence (CORBA::ULong maximum)
+ : TAO_Unbounded_Base_Sequence (maximum,
+ TAO_Unbounded_Sequence<T>::allocbuf (maximum))
+{
+}
+
+template <class T> ACE_INLINE
+TAO_Unbounded_Sequence<T>::TAO_Unbounded_Sequence (CORBA::ULong maximum,
+ CORBA::ULong length,
+ T *data,
+ CORBA::Boolean release)
+ : TAO_Unbounded_Base_Sequence (maximum, length, data, release)
+{
+}
+
template <class T> ACE_INLINE T *
TAO_Unbounded_Sequence<T>::get_buffer (CORBA::Boolean orphan)
{
+ T *result = 0;
if (orphan == CORBA::B_FALSE)
{
// We retain ownership.
if (this->buffer_ == 0)
- this->buffer_ = (void *) new T[this->length_];
+ {
+ result = TAO_Unbounded_Sequence<T>::allocbuf (this->length_);
+ this->buffer_ = result;
+ }
+ else
+ {
+ result =
+ ACE_reinterpret_cast (T*, this->buffer_);
+ }
}
else // if (orphan == CORBA::B_TRUE)
{
- if (this->release_ == CORBA::B_FALSE)
- // Oops, it's not our buffer to relinquish...
- return 0;
- else
+ if (this->release_ != CORBA::B_FALSE)
{
// 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_ = CORBA::B_FALSE;
}
+ /* else
+ // Oops, it's not our buffer to relinquish...
+ return 0;
+ */
}
- return (T *) this->buffer_;
+ return result;
}
template <class T> ACE_INLINE const T *
TAO_Unbounded_Sequence<T>::get_buffer (void) const
{
- return (const T *) this->buffer_;
+ return ACE_reinterpret_cast(const T *, this->buffer_);
}
template <class T> ACE_INLINE void
@@ -53,27 +92,15 @@ TAO_Unbounded_Sequence<T>::replace (CORBA::ULong max,
this->maximum_ = max;
this->length_ = length;
if (this->buffer_ && this->release_ == CORBA::B_TRUE)
+ {
+ T *tmp = ACE_reinterpret_cast(T*,this->buffer_);
+ TAO_Unbounded_Sequence<CORBA::Octet>::freebuf (tmp);
+ }
TAO_Unbounded_Sequence<T>::freebuf ((T *) this->buffer_);
this->buffer_ = data;
this->release_ = release;
}
-template <class T> ACE_INLINE
-TAO_Unbounded_Sequence<T>::TAO_Unbounded_Sequence (CORBA::ULong maximum)
- : TAO_Unbounded_Base_Sequence (maximum,
- TAO_Unbounded_Sequence<T>::allocbuf (maximum))
-{
-}
-
-template <class T> ACE_INLINE
-TAO_Unbounded_Sequence<T>::TAO_Unbounded_Sequence (CORBA::ULong maximum,
- CORBA::ULong length,
- T *data,
- CORBA::Boolean release)
- : TAO_Unbounded_Base_Sequence (maximum, length, data, release)
-{
-}
-
template <class T> ACE_INLINE T &
TAO_Unbounded_Sequence<T>::operator[] (CORBA::ULong i)
{
@@ -90,54 +117,74 @@ TAO_Unbounded_Sequence<T>::operator[] (CORBA::ULong i) const
return tmp[i];
}
-template <class T> ACE_INLINE T *
-TAO_Unbounded_Sequence<T>::allocbuf (CORBA::ULong size)
+// ***************************************************
+// operations on the generic Bounded sequence class
+// ***************************************************
+
+template <class T, CORBA::ULong MAX> ACE_INLINE T *
+TAO_Bounded_Sequence<T, MAX>::allocbuf (CORBA::ULong)
{
- return new T[size];
+ return new T[MAX];
}
-template <class T> ACE_INLINE void
-TAO_Unbounded_Sequence<T>::freebuf (T *buffer)
+template <class T, CORBA::ULong MAX> ACE_INLINE void
+TAO_Bounded_Sequence<T, MAX>::freebuf (T *buffer)
{
delete [] buffer;
}
-// ***************************************************
-// operations on the generic Bounded sequence class
-// ***************************************************
+template <class T, CORBA::ULong MAX> ACE_INLINE
+TAO_Bounded_Sequence<T, MAX>::TAO_Bounded_Sequence (void)
+{
+}
+
+template <class T, CORBA::ULong MAX> ACE_INLINE
+TAO_Bounded_Sequence<T, MAX>::TAO_Bounded_Sequence (CORBA::ULong length,
+ T *data,
+ CORBA::Boolean release)
+ : TAO_Bounded_Base_Sequence (length, MAX, data, release)
+{
+}
template <class T, CORBA::ULong MAX> ACE_INLINE T *
TAO_Bounded_Sequence<T, MAX>::get_buffer (CORBA::Boolean orphan)
{
+ T *result = 0;
if (orphan == CORBA::B_FALSE)
{
// We retain ownership.
if (this->buffer_ == 0)
- this->buffer_ = (void *) new T[this->maximum_];
+ {
+ result = TAO_Bounded_Sequence<T,MAX>::allocbuf (this->maximum_);
+ this->buffer_ = result;
+ }
+ else
+ {
+ result =
+ ACE_reinterpret_cast (T*, this->buffer_);
+ }
}
else // if (orphan == CORBA::B_TRUE)
{
- if (this->release_ == CORBA::B_FALSE)
- // Oops, it's not our buffer to relinquish...
- return 0;
- else
+ if (this->release_ != CORBA::B_FALSE)
{
// 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_ = CORBA::B_FALSE;
}
}
- return (T *) this->buffer_;
+ return result;
}
template <class T, CORBA::ULong MAX> ACE_INLINE const T *
TAO_Bounded_Sequence<T, MAX>::get_buffer (void) const
{
- return (const T *) this->buffer_;
+ return ACE_reinterpret_cast(const T *, this->buffer_);
}
template <class T, CORBA::ULong MAX> ACE_INLINE void
@@ -149,24 +196,14 @@ TAO_Bounded_Sequence<T, MAX>::replace (CORBA::ULong max,
this->maximum_ = max;
this->length_ = length;
if (this->buffer_ && this->release_ == CORBA::B_TRUE)
- TAO_Bounded_Sequence<T, MAX>::freebuf ((T *) this->buffer_);
+ {
+ T* tmp = ACE_reinterpret_cast(T*, this->buffer_);
+ TAO_Bounded_Sequence<T, MAX>::freebuf (tmp);
+ }
this->buffer_ = data;
this->release_ = release;
}
-template <class T, CORBA::ULong MAX> ACE_INLINE
-TAO_Bounded_Sequence<T, MAX>::TAO_Bounded_Sequence (void)
-{
-}
-
-template <class T, CORBA::ULong MAX> ACE_INLINE
-TAO_Bounded_Sequence<T, MAX>::TAO_Bounded_Sequence (CORBA::ULong length,
- T *data,
- CORBA::Boolean release)
- : TAO_Bounded_Base_Sequence (length, MAX, data, release)
-{
-}
-
template <class T, CORBA::ULong MAX> ACE_INLINE T &
TAO_Bounded_Sequence<T, MAX>::operator[] (CORBA::ULong i)
{
@@ -179,22 +216,10 @@ template <class T, CORBA::ULong MAX> ACE_INLINE const T &
TAO_Bounded_Sequence<T, MAX>::operator[] (CORBA::ULong i) const
{
ACE_ASSERT (i < this->maximum_);
- const T* tmp = ACE_reinterpret_cast (const T*,this->buffer_);
+ const T* tmp = ACE_reinterpret_cast (const T* ACE_CAST_CONST,this->buffer_);
return tmp[i];
}
-template <class T, CORBA::ULong MAX> ACE_INLINE T *
-TAO_Bounded_Sequence<T, MAX>::allocbuf (CORBA::ULong)
-{
- return new T[MAX];
-}
-
-template <class T, CORBA::ULong MAX> ACE_INLINE void
-TAO_Bounded_Sequence<T, MAX>::freebuf (T *buffer)
-{
- delete [] buffer;
-}
-
// *************************************************************
// Inline operations for class TAO_Object_Manager<T>
// *************************************************************