summaryrefslogtreecommitdiff
path: root/TAO/tao/Sequence_T.h
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/tao/Sequence_T.h')
-rw-r--r--TAO/tao/Sequence_T.h222
1 files changed, 221 insertions, 1 deletions
diff --git a/TAO/tao/Sequence_T.h b/TAO/tao/Sequence_T.h
index 2fefbe2ec3a..8ce5fab6042 100644
--- a/TAO/tao/Sequence_T.h
+++ b/TAO/tao/Sequence_T.h
@@ -126,6 +126,8 @@ public:
CORBA::Boolean release = 0);
};
+// *************************************************************
+
/**
* @class TAO_Bounded_Sequence
*
@@ -234,7 +236,9 @@ public:
template<class T,class T_var> class TAO_Unbounded_Object_Sequence;
template<class T,class T_var> class TAO_Unbounded_Pseudo_Sequence;
+template<class T,class T_var> class TAO_Unbounded_Valuetype_Sequence;
template<class T, class T_var, size_t MAX> class TAO_Bounded_Object_Sequence;
+template<class T, class T_var, size_t MAX> class TAO_Bounded_Valuetype_Sequence;
template<size_t MAX> class TAO_Bounded_String_Sequence;
// *************************************************************
@@ -340,6 +344,8 @@ private:
CORBA::Boolean release_;
};
+// *************************************************************
+
/**
* @class TAO_Pseudo_Object_Manager
*
@@ -421,6 +427,95 @@ private:
// *************************************************************
+ /**
+ * @class TAO_Valuetype_Manager
+ *
+ * @brief Manager for valuetypes.
+ *
+ * According to the spec., valuetypes are handled similarly to object
+ * references, so a manager class is needed.
+ *
+ * @see TAO_Object_Manager
+ */
+template<class T, class T_var>
+class TAO_Valuetype_Manager
+{
+ friend class TAO_Unbounded_Valuetype_Sequence<T,T_var>;
+public:
+ // @@ Use partial template specialization here to give access only
+ // to the right kind of sequence.
+ // friend template<CORBA::ULong MAX>
+ // class TAO_Bounded_Valuetype_Sequence<T,MAX>;
+
+ // = Initialization and termination methods.
+ /**
+ * Copy constructor, the semantics are non-trivial:
+ * + The referenced element is duplicated or not according to the
+ * release value on the <rhs>.
+ * + In any case a new reference to the same object is created.
+ */
+ TAO_Valuetype_Manager (const TAO_Valuetype_Manager<T,T_var> &rhs);
+
+ /**
+ * Constructor from address of an element, it should be private and
+ * only TAO_*_Object_Sequence would use it, but we have some
+ * problems with friendship and templates.
+ */
+ TAO_Valuetype_Manager (T **, CORBA::Boolean release);
+
+ /// Destructor, only releases the object if <release_> is true.
+ ~TAO_Valuetype_Manager (void);
+
+ /**
+ * Assignment from another managed type, only release if
+ * <this->release_> is true.
+ * @@ TODO what happens if rhs.release_ is true an this->relase_ is
+ * false?
+ */
+ TAO_Valuetype_Manager<T,T_var> &operator= (const TAO_Valuetype_Manager<T,T_var> &rhs);
+
+ /// Assignment from T *.
+ TAO_Valuetype_Manager<T,T_var> &operator= (T *);
+
+ /// Assignment from T_var.
+ TAO_Valuetype_Manager<T,T_var> &operator= (const T_var &);
+
+ /// Return pointer.
+ T * operator-> (void) const;
+
+ /// Cast (read-only).
+ operator const T *() const;
+
+ /// Cast.
+ operator T *&();
+
+ /// Cast (read-only) so that assignment from a structured
+ /// type to a T_var will make a copy.
+ operator const T_var() const;
+
+ /// for in parameter.
+ T *in (void) const;
+
+ /// for inout parameter.
+ T *&inout (void);
+
+ /// for out parameter.
+ T *&out (void);
+
+ /// for return type
+ T *_retn (void);
+
+private:
+ /// data member, notice that it is a pointer, to implement the
+ /// reference behavior for assignment.
+ T **ptr_;
+
+ /// release flag based on parent's flag
+ CORBA::Boolean release_;
+};
+
+// *************************************************************
+
/**
* @class TAO_Unbounded_Object_Sequence
*
@@ -428,7 +523,7 @@ private:
*
* Some IDL types require that sequences on them have a "manager"
* class, in charge of handling the object lifetime, examples are
- * pseudo objects, object references and strings.
+ * pseudo objects, object references, valuetypes, and strings.
*/
template<class T,class T_var>
class TAO_Unbounded_Object_Sequence : public TAO_Unbounded_Base_Sequence
@@ -737,6 +832,131 @@ public:
// *************************************************************
/**
+ * @class TAO_Unbounded_Valuetype_Sequence
+ *
+ * @brief Parametric sequence for valuetypes
+ *
+ * @see TAO_Unbounded_Object_Sequence
+ */
+template<class T,class T_var>
+class TAO_Unbounded_Valuetype_Sequence : public TAO_Unbounded_Base_Sequence
+{
+public:
+ // = Initialization and termination methods.
+
+ // Default ctor.
+ TAO_Unbounded_Valuetype_Sequence (void);
+
+ /// Constructor with a "hint" for the maximum capacity.
+ TAO_Unbounded_Valuetype_Sequence (CORBA::ULong max);
+
+ /// Constructor with a given buffer.
+ TAO_Unbounded_Valuetype_Sequence (CORBA::ULong maximum,
+ CORBA::ULong length,
+ T* *data,
+ CORBA::Boolean release=0);
+
+ /// Copy ctor, deep copies.
+ TAO_Unbounded_Valuetype_Sequence(const TAO_Unbounded_Valuetype_Sequence<T,T_var> &);
+
+ /// The destructor releases all object reference memebrs and frees
+ /// all string members.
+ ~TAO_Unbounded_Valuetype_Sequence (void);
+
+ /**
+ * The assignment operator first releases all object reference
+ * members and frees all string members, and then performs a
+ * deepcopy to create a new structure.
+ */
+ TAO_Unbounded_Valuetype_Sequence<T,T_var> &operator= (const TAO_Unbounded_Valuetype_Sequence <T,T_var> &);
+
+ /// read-write accessor
+ TAO_Valuetype_Manager<T,T_var> operator[] (CORBA::ULong slot) const;
+
+ /// The allocbuf function allocates a vector of T elements that can
+ /// be passed to the T *data constructor.
+ static T **allocbuf (CORBA::ULong);
+
+ /// Release all the elements.
+ static void freebuf (T **);
+
+ // The Base_Sequence functions, please see "tao/Sequence.h"
+ /// No default to workaround egcs problem with templates and
+ /// namespaces
+ virtual void _allocate_buffer (CORBA::ULong length);
+ virtual void _deallocate_buffer (void);
+ virtual void _shrink_buffer (CORBA::ULong new_length,
+ CORBA::ULong old_length);
+ /*
+ virtual void _downcast (void* target,
+ CORBA_ValueBase* src,
+ CORBA_Environment &ACE_TRY_ENV =
+ TAO_default_environment ());
+ virtual CORBA_ValueBase* _upcast (void* src) const;
+ */
+};
+
+// *************************************************************
+
+/**
+ * @class TAO_Bounded_Valuetype_Sequence
+ *
+ * @brief Parametric sequence for types that require managers.
+ *
+ * Please see the documentation for the unbounded case.
+ */
+template<class T, class T_var, size_t MAX>
+class TAO_Bounded_Valuetype_Sequence : public TAO_Bounded_Base_Sequence
+{
+public:
+ // = Initialization and termination methods.
+
+ // Default ctor.
+ TAO_Bounded_Valuetype_Sequence (void);
+
+ /// Constructor from data.
+ TAO_Bounded_Valuetype_Sequence (CORBA::ULong length,
+ T* *value,
+ CORBA::Boolean release=0);
+
+ /// Copy constructor.
+ TAO_Bounded_Valuetype_Sequence (const TAO_Bounded_Valuetype_Sequence<T,T_var,MAX> &);
+
+ /// destructor
+ ~TAO_Bounded_Valuetype_Sequence (void);
+
+ /// Assignment from another Bounded sequence.
+ TAO_Bounded_Valuetype_Sequence &operator= (const TAO_Bounded_Valuetype_Sequence<T,T_var,MAX> &);
+
+ /// Read-write accessor.
+ TAO_Valuetype_Manager<T,T_var> operator[] (CORBA::ULong slot) const;
+
+ /// Allocate storage for a sequence..
+ static T **allocbuf (CORBA::ULong length);
+
+ /// Free a buffer allocated by allocbuf() and release each element on
+ /// it.
+ static void freebuf (T **buffer);
+
+ // The Base_Sequence functions, please see "tao/sequence.h"
+ /// No default to workaround egcs problem with templates and
+ /// namespaces
+ virtual void _allocate_buffer (CORBA::ULong length);
+ virtual void _deallocate_buffer (void);
+ virtual void _shrink_buffer (CORBA::ULong new_length,
+ CORBA::ULong old_length);
+ /*
+ virtual void _downcast (void* target,
+ CORBA_ValueBase* src,
+ CORBA_Environment &ACE_TRY_ENV =
+ TAO_default_environment ());
+ virtual CORBA_ValueBase* _upcast (void* src) const;
+ */
+};
+
+// *************************************************************
+
+/**
* @class TAO_Unbounded_Array_Sequence
*
* @brief Parametric sequence for arrays.