diff options
author | Ossama Othman <ossama-othman@users.noreply.github.com> | 2005-01-18 20:17:47 +0000 |
---|---|---|
committer | Ossama Othman <ossama-othman@users.noreply.github.com> | 2005-01-18 20:17:47 +0000 |
commit | 3e671a7461041e693be0c3091d2550543009ffc4 (patch) | |
tree | 884800ec514d96f09d75bc7a7358ae0adce4ab71 | |
parent | d32088cdaeb926c5ad8766cc9b8961749cd6c1fd (diff) | |
download | ATCD-3e671a7461041e693be0c3091d2550543009ffc4.tar.gz |
*** empty log message ***
-rw-r--r-- | TAO/tao/TypeCode/Alias_TypeCode.h | 4 | ||||
-rw-r--r-- | TAO/tao/TypeCode/Except_TypeCode.h | 4 | ||||
-rw-r--r-- | TAO/tao/TypeCode/Struct_TypeCode.cpp | 88 | ||||
-rw-r--r-- | TAO/tao/TypeCode/Struct_TypeCode.h | 21 | ||||
-rw-r--r-- | TAO/tao/TypeCode/Struct_TypeCode.inl | 2 | ||||
-rw-r--r-- | TAO/tao/TypeCode/TypeCode.cpp | 2 | ||||
-rw-r--r-- | TAO/tao/TypeCode/TypeCode_Constants.cpp | 2 | ||||
-rw-r--r-- | TAO/tao/TypeCode/TypeCode_Field.h | 12 | ||||
-rw-r--r-- | TAO/tao/TypeCode/Value_Box_TypeCode.cpp | 147 | ||||
-rw-r--r-- | TAO/tao/TypeCode/Value_Box_TypeCode.h | 130 |
10 files changed, 381 insertions, 31 deletions
diff --git a/TAO/tao/TypeCode/Alias_TypeCode.h b/TAO/tao/TypeCode/Alias_TypeCode.h index 880e5e1d10e..c87afb00f09 100644 --- a/TAO/tao/TypeCode/Alias_TypeCode.h +++ b/TAO/tao/TypeCode/Alias_TypeCode.h @@ -2,7 +2,7 @@ //============================================================================= /** - * @file Object_TypeCode.h + * @file Alias_TypeCode.h * * $Id$ * @@ -47,7 +47,7 @@ namespace TAO /// Constructor. Alias (char const * id, char const * name, - CORBA::TypeCode_ptr tc); + CORBA::TypeCode_ptr * tc); /// Destructor. ~Alias (void); diff --git a/TAO/tao/TypeCode/Except_TypeCode.h b/TAO/tao/TypeCode/Except_TypeCode.h index 545142d8ed9..021fa98276c 100644 --- a/TAO/tao/TypeCode/Except_TypeCode.h +++ b/TAO/tao/TypeCode/Except_TypeCode.h @@ -37,7 +37,7 @@ namespace TAO * This class implements a @c CORBA::TypeCode for an OMG IDL @c * except. */ - template <class AttrType, class RefCountPolicy> + template <typename StringType, class FieldArrayType, class RefCountPolicy> class Except : public Struct<AttrType, RefCountPolicy> { @@ -46,7 +46,7 @@ namespace TAO /// Constructor. Except (char const * id, char const * name, - Field const * fields, + Field<StringType> const * fields, CORBA::ULong nfields); protected: diff --git a/TAO/tao/TypeCode/Struct_TypeCode.cpp b/TAO/tao/TypeCode/Struct_TypeCode.cpp index ddd563696d0..2a5e1d328c3 100644 --- a/TAO/tao/TypeCode/Struct_TypeCode.cpp +++ b/TAO/tao/TypeCode/Struct_TypeCode.cpp @@ -11,10 +11,14 @@ #endif /* !__ACE_INLINE__ */ -template <typename StringType, class FieldArrayType, class RefCountPolicy> +template <typename StringType, + class FieldArrayType, + CORBA::TCKind Kind, + class RefCountPolicy> bool TAO::TypeCode::Struct<StringType, FieldArrayType, + Kind, RefCountPolicy>::tao_marshal ( TAO_OutputCDR & cdr) const { @@ -48,28 +52,40 @@ TAO::TypeCode::Struct<StringType, return true; } -template <typename StringType, class FieldArrayType, class RefCountPolicy> +template <typename StringType, + class FieldArrayType, + CORBA::TCKind Kind, + class RefCountPolicy> void TAO::TypeCode::Struct<StringType, FieldArrayType, + Kind, RefCountPolicy>::tao_duplicate (void) { this->RefCountPolicy::add_ref (void); } -template <typename StringType, class FieldArrayType, class RefCountPolicy> +template <typename StringType, + class FieldArrayType, + CORBA::TCKind Kind, + class RefCountPolicy> void TAO::TypeCode::Struct<StringType, FieldArrayType, + Kind, RefCountPolicy>::tao_release (void) { this->RefCountPolicy::remove_ref (void); } -template <typename StringType, class FieldArrayType, class RefCountPolicy> +template <typename StringType, + class FieldArrayType, + CORBA::TCKind Kind, + class RefCountPolicy> CORBA::Boolean TAO::TypeCode::Struct<StringType, FieldArrayType, + Kind, RefCountPolicy>::equal_i ( CORBA::TypeCode_ptr tc ACE_ENV_ARG_DECL) const @@ -115,10 +131,14 @@ TAO::TypeCode::Struct<StringType, return 1; } -template <typename StringType, class FieldArrayType, class RefCountPolicy> +template <typename StringType, + class FieldArrayType, + CORBA::TCKind Kind, + class RefCountPolicy> CORBA::Boolean TAO::TypeCode::Struct<StringType, FieldArrayType, + Kind, RefCountPolicy>::equivalent_i ( CORBA::TypeCode_ptr tc ACE_ENV_ARG_DECL) const @@ -186,18 +206,28 @@ TAO::TypeCode::Struct<StringType, return 1; } -template <typename StringType, class FieldArrayType, class RefCountPolicy> +template <typename StringType, + class FieldArrayType, + CORBA::TCKind Kind, + class RefCountPolicy> CORBA::TCKind -TAO::TypeCode::Struct<StringType, FieldArrayType, RefCountPolicy>::kind_i ( +TAO::TypeCode::Struct<StringType, + FieldArrayType, + Kind, + RefCountPolicy>::kind_i ( ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const { - return CORBA::tk_struct; + return Struct_Traits<Kind>::kind; } -template <typename StringType, class FieldArrayType, class RefCountPolicy> +template <typename StringType, + class FieldArrayType, + CORBA::TCKind Kind, + class RefCountPolicy> CORBA::TypeCode_ptr TAO::TypeCode::Struct<StringType, FieldArrayType, + Kind, RefCountPolicy>::get_compact_typecode_i ( ACE_ENV_SINGLE_ARG_DECL) const { @@ -217,7 +247,7 @@ TAO::TypeCode::Struct<StringType, safe_fields.reset (fields); - static char const * empty_name = ""; + static char const * const empty_name = ""; for (CORBA::ULong i = 0; i < this->nfields_; ++i) { @@ -259,9 +289,15 @@ TAO::TypeCode::Struct<StringType, return tc; } -template <typename StringType, class FieldArrayType, class RefCountPolicy> +template <typename StringType, + class FieldArrayType, + CORBA::TCKind Kind, + class RefCountPolicy> char const * -TAO::TypeCode::Struct<StringType, FieldArrayType, RefCountPolicy>::id_i ( +TAO::TypeCode::Struct<StringType, + FieldArrayType, + Kind, + RefCountPolicy>::id_i ( ACE_ENV_SINGLE_ARG_DECL) const { // Ownership is retained by the TypeCode, as required by the C++ @@ -269,9 +305,15 @@ TAO::TypeCode::Struct<StringType, FieldArrayType, RefCountPolicy>::id_i ( return this->base_attributes_.id (); } -template <typename StringType, class FieldArrayType, class RefCountPolicy> +template <typename StringType, + class FieldArrayType, + CORBA::TCKind Kind, + class RefCountPolicy> char const * -TAO::TypeCode::Struct<StringType, FieldArrayType, RefCountPolicy>::name_i ( +TAO::TypeCode::Struct<StringType, + FieldArrayType, + Kind, + RefCountPolicy>::name_i ( ACE_ENV_SINGLE_ARG_DECL) const { // Ownership is retained by the TypeCode, as required by the C++ @@ -279,20 +321,28 @@ TAO::TypeCode::Struct<StringType, FieldArrayType, RefCountPolicy>::name_i ( return this->base_attributes_.name (); } -template <typename StringType, class FieldArrayType, class RefCountPolicy> +template <typename StringType, + class FieldArrayType, + CORBA::TCKind Kind, + class RefCountPolicy> CORBA::ULong TAO::TypeCode::Struct<StringType, FieldArrayType, + Kind, RefCountPolicy>::member_count_i ( ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const { return this->nfields_; } -template <typename StringType, class FieldArrayType, class RefCountPolicy> +template <typename StringType, + class FieldArrayType, + CORBA::TCKind Kind, + class RefCountPolicy> char const * TAO::TypeCode::Struct<StringType, FieldArrayType, + Kind, RefCountPolicy>::member_name_i ( CORBA::ULong index ACE_ENV_ARG_DECL) const @@ -305,10 +355,14 @@ TAO::TypeCode::Struct<StringType, return this->fields_[index].get_name (); } -template <typename StringType, class FieldArrayType, class RefCountPolicy> +template <typename StringType, + class FieldArrayType, + CORBA::TCKind Kind, + class RefCountPolicy> CORBA::TypeCode_ptr TAO::TypeCode::Struct<StringType, FieldArrayType, + Kind, RefCountPolicy>::member_type_i ( CORBA::ULong index ACE_ENV_ARG_DECL) const diff --git a/TAO/tao/TypeCode/Struct_TypeCode.h b/TAO/tao/TypeCode/Struct_TypeCode.h index 52bdcebdbba..545bdc7d46d 100644 --- a/TAO/tao/TypeCode/Struct_TypeCode.h +++ b/TAO/tao/TypeCode/Struct_TypeCode.h @@ -31,6 +31,20 @@ namespace TAO { namespace TypeCode { + template <CORBA::TCKind KIND> Struct_Traits; + + template <> + struct Struct_Traits<CORBA::tk_struct> + { + enum { kind = CORBA::tk_struct }; + }; + + template <> + struct Struct_Traits<CORBA::tk_except> + { + enum { kind = CORBA::tk_except }; + }; + /** * @class Struct @@ -41,7 +55,10 @@ namespace TAO * This class implements a @c CORBA::TypeCode for an OMG IDL * @c struct. */ - template <typename StringType, class FieldArrayType, class RefCountPolicy> + template <typename StringType, + class FieldArrayType, + class StructTraits, + class RefCountPolicy> class Struct : public CORBA::TypeCode, private RefCountPolicy @@ -124,6 +141,8 @@ namespace TAO /// OMG IDL defined @c struct. FieldArrayType const fields_; + //@} + }; } // End namespace TypeCode diff --git a/TAO/tao/TypeCode/Struct_TypeCode.inl b/TAO/tao/TypeCode/Struct_TypeCode.inl index 34a8eec85e4..114d5e49b83 100644 --- a/TAO/tao/TypeCode/Struct_TypeCode.inl +++ b/TAO/tao/TypeCode/Struct_TypeCode.inl @@ -29,7 +29,7 @@ TAO::TypeCode::Struct<StringType, ACE_INLINE TAO::TypeCode::Field<CORBA::String_var> const * TAO::TypeCode::Struct<CORBA::String_var, - ACE_Auto_Ptr_Array<Field const> >::fields (void) const + ACE_Auto_Ptr_Array<Field<CORBA::String_var> const> >::fields (void) const { return this->fields_.get (); } diff --git a/TAO/tao/TypeCode/TypeCode.cpp b/TAO/tao/TypeCode/TypeCode.cpp index d8816e63cba..f6d77e94b87 100644 --- a/TAO/tao/TypeCode/TypeCode.cpp +++ b/TAO/tao/TypeCode/TypeCode.cpp @@ -204,7 +204,7 @@ TAO::unaliased_kind (CORBA::TypeCode_ptr tc if (tc_kind == CORBA::tk_alias) { CORBA::TypeCode_var tc_content = - tc_content = tc->content_type (ACE_ENV_SINGLE_ARG_PARAMETER); + tc->content_type (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK_RETURN (tc_kind); // Iterate until we get to the actual unaliased type. diff --git a/TAO/tao/TypeCode/TypeCode_Constants.cpp b/TAO/tao/TypeCode/TypeCode_Constants.cpp index 6bfd2a49b4a..9ebf280dae4 100644 --- a/TAO/tao/TypeCode/TypeCode_Constants.cpp +++ b/TAO/tao/TypeCode/TypeCode_Constants.cpp @@ -17,7 +17,7 @@ namespace TAO { namespace TypeCode { - // Notice that these are all statically instantiated, nor are they + // Notice that these are all statically instantiated and not // exported. Empty_Param tc_null (CORBA::tk_null); diff --git a/TAO/tao/TypeCode/TypeCode_Field.h b/TAO/tao/TypeCode/TypeCode_Field.h index 553d02b8c16..f718026e80a 100644 --- a/TAO/tao/TypeCode/TypeCode_Field.h +++ b/TAO/tao/TypeCode/TypeCode_Field.h @@ -53,8 +53,8 @@ namespace TAO * }; * \endcode * - * would be represented using the following statically instantiated @c - * TAO::TypeCode::Field array: + * would be represented using the following statically instantiated + * @c TAO::TypeCode::Field array: * * \code * TAO::TypeCode::Field<char const *> _tao_fields_Foo[] = @@ -64,10 +64,10 @@ namespace TAO * }; * \endcode * - * The template parameter @a STRING_TYPE is either @c char @c - * const @c * or @c CORBA::String_var. The latter is only used - * when creating @c CORBA::tk_struct or @c CORBA::tk_except @c - * TypeCodes dynamically, such as through the TypeCodeFactory. + * The template parameter @a STRING_TYPE is either @c char + * @c const @c * or @c CORBA::String_var. The latter is only used + * when creating @c CORBA::tk_struct or @c CORBA::tk_except + * @c TypeCodes dynamically, such as through the TypeCodeFactory. */ template <typename STRING_TYPE> struct Field diff --git a/TAO/tao/TypeCode/Value_Box_TypeCode.cpp b/TAO/tao/TypeCode/Value_Box_TypeCode.cpp new file mode 100644 index 00000000000..368d0141d81 --- /dev/null +++ b/TAO/tao/TypeCode/Value_Box_TypeCode.cpp @@ -0,0 +1,147 @@ +// $Id$ + +#ifndef TAO_VALUE_BOX_TYPECODE_CPP +#define TAO_VALUE_BOX_TYPECODE_CPP + +#include "tao/Value_Box_TypeCode.h" + +#ifndef __ACE_INLINE__ +# include "tao/Value_Box_TypeCode.inl" +#endif /* !__ACE_INLINE__ */ + + +template <typename StringType, class RefCountPolicy> +TAO::TypeCode::Value_Box<StringType, RefCountPolicy>::~Value_Box (void) +{ + if (this->content_type_) + CORBA::release (*this->content_type_); +} + +template <typename StringType, class RefCountPolicy> +bool +TAO::TypeCode::Value_Box<StringType, RefCountPolicy>::tao_marshal ( + TAO_OutputCDR &) const +{ + // A tk_value_box TypeCode has a "complex" parameter list type (see + // Table 15-2 in Section 15.3.5.1 "TypeCode" in the CDR section of + // the CORBA specification), meaning that it must be marshaled into + // a CDR encapsulation. + + // Create a CDR encapsulation. + return + (cdr << TAO_ENCAP_BYTE_ORDER) + && (cdr << this->attributes_.id ()) + && (cdr << this->attributes_.name ()) + && (cdr << *(this->content_type_.in ())); +} + +template <typename StringType, class RefCountPolicy> +void +TAO::TypeCode::Value_Box<StringType, RefCountPolicy>::tao_duplicate (void) +{ + this->RefCountPolicy::add_ref (void); +} + +template <typename StringType, class RefCountPolicy> +void +TAO::TypeCode::Value_Box<StringType, RefCountPolicy>::tao_release (void) +{ + this->RefCountPolicy::remove_ref (void); +} + +template <typename StringType, class RefCountPolicy> +CORBA::Boolean +TAO::TypeCode::Value_Box<StringType, RefCountPolicy>::equal_i ( + CORBA::TypeCode_ptr tc + ACE_ENV_ARG_DECL_NOT_USED) const +{ + // The CORBA::TypeCode base class already verified equality of the + // base attributes (id and name). Perform an equality comparison of + // the members. + + CORBA::TypeCode_var rhs_content_type = + tc->content_type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + return this->content_type_->equal (rhs_content_type.in () + ACE_ENV_ARG_PARAMETER); +} + +template <typename StringType, class RefCountPolicy> +CORBA::Boolean +TAO::TypeCode::Value_Box<StringType, RefCountPolicy>::equivalent_i ( + CORBA::TypeCode_ptr tc + ACE_ENV_ARG_DECL) const +{ + // We could refactor this code to the CORBA::TypeCode::equivalent() + // method but doing so would force us to determine the unaliased + // kind of this TypeCode. Since we already know the unaliased kind + // of this TypeCode, choose to optimize away the additional kind + // unaliasing operation rather than save space. + + CORBA::TCKind const tc_kind = + TAO::unaliased_kind (tc + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + if (tc_kind != CORBA::tk_value_box) + return (0); + + char const * const this_id = this->attributes_.id (); + char const * const tc_id = tc->id (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + if (ACE_OS::strlen (this_id) == 0 + || ACE_OS::strlen (tc_id) == 0) + { + CORBA::TypeCode_var rhs_content_type = + tc->content_type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + return *(this->content_type_)->equivalent (rhs_content_type.in () + ACE_ENV_ARG_PARAMETER); + } + else if (ACE_OS::strcmp (this_id, tc_id) != 0) + { + return 0; + } + + return 1; +} + +template <typename StringType, class RefCountPolicy> +CORBA::TCKind +TAO::TypeCode::Value_Box<StringType, RefCountPolicy>::kind_i ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const +{ + return CORBA::tk_value_box; +} + +template <typename StringType, class RefCountPolicy> +CORBA::TypeCode_ptr +TAO::TypeCode::Value_Box<StringType, RefCountPolicy>::get_compact_typecode_i ( + ACE_ENV_SINGLE_ARG_DECL) const +{ + TAO_TypeCodeFactory_Adapter * adapter = + ACE_Dynamic_Service<TAO_TypeCodeFactory_Adapter>::instance ( + TAO_ORB_Core::typecodefactory_adapter_name () + ); + + if (adapter == 0) + { + ACE_THROW_RETURN (CORBA::INTERNAL (), + CORBA::TypeCode::_nil ()); + } + + CORBA::TypeCode_var compact_content_type = + *(this->content_type_)->get_compact_typecode ( + ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (CORBA::TypeCode::_nil ()); + + return adapter->create_value_box_tc (this->attributes_.id (), + "" /* empty name */ + compact_content_type.in () + ACE_ENV_ARG_PARAMETER); +} + +#endif /* TAO_VALUE_BOX_TYPECODE_CPP */ diff --git a/TAO/tao/TypeCode/Value_Box_TypeCode.h b/TAO/tao/TypeCode/Value_Box_TypeCode.h new file mode 100644 index 00000000000..fb359bf63e0 --- /dev/null +++ b/TAO/tao/TypeCode/Value_Box_TypeCode.h @@ -0,0 +1,130 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Value_Box_TypeCode.h + * + * $Id$ + * + * Header file for a @c tk_value_box CORBA::TypeCode. + * + * @author Ossama Othman <ossama@dre.vanderbilt.edu> + */ +//============================================================================= + +#ifndef TAO_VALUE_BOX_TYPECODE_H +#define TAO_VALUE_BOX_TYPECODE_H + +#include /**/ "ace/pre.h" + +#include "tao/TypeCode.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +namespace TAO +{ + namespace TypeCode + { + + /** + * @class Value_Box + * + * @brief @c CORBA::TypeCode implementation for an OMG IDL + * boxed @c valuetype. + * + * This class implements a @c CORBA::TypeCode for an OMG IDL + * boxed @c valuetype. + */ + template <typename StringType, class RefCountPolicy> + class Value_Box + : public CORBA::TypeCode, + private RefCountPolicy + { + public: + + /// Constructor. + Value_Box (char const * id, + char const * name, + CORBA::TypeCode_ptr * tc); + + /// Destructor. + ~Value_Box (void); + + /** + * @name TAO-specific @c CORBA::TypeCode Methods + * + * Methods required by TAO's implementation of the + * @c CORBA::TypeCode class. + * + * @see @c CORBA::TypeCode + */ + //@{ + virtual bool tao_marshal (TAO_OutputCDR & cdr) const; + virtual void tao_duplicate (void); + virtual void tao_release (void); + //@} + + protected: + + /** + * @name @c TAO CORBA::TypeCode Template Methods + * + * @c tk_value_box @c CORBA::TypeCode -specific template methods. + * + * @see @c CORBA::TypeCode + */ + //@{ + virtual CORBA::Boolean equal_i (CORBA::TypeCode_ptr tc + ACE_ENV_ARG_DECL) const; + virtual CORBA::Boolean equivalent_i (CORBA::TypeCode_ptr tc + ACE_ENV_ARG_DECL) const; + virtual CORBA::TCKind kind_i (ACE_ENV_SINGLE_ARG_DECL) const; + virtual CORBA::TypeCode_ptr get_compact_typecode_i ( + ACE_ENV_SINGLE_ARG_DECL) const; + virtual char const * id_i (ACE_ENV_SINGLE_ARG_DECL) const; + virtual char const * name_i (ACE_ENV_SINGLE_ARG_DECL) const; + virtual TypeCode_ptr content_type_i (ACE_ENV_SINGLE_ARG_DECL) const; + + private: + + /// Base attributes for this @c TypeCode containing the + /// repository ID and name of the boxed @c valuetype. + Base_Attributes<StringType> attributes_; + + /// The @c TypeCode corresponding to the original type upon + /// which the IDL boxed @c valuetype was made. + /** + * A pointer to the @c CORBA::TypeCode_ptr rather than the + * @c CORBA::TypeCode_ptr itself is stored since that address is + * well-defined. We may not know the value of the @c + * CORBA::TypeCode_ptr when creating this @c Field statically at + * compile-time, hence the indirection. + * + * @note This @c TypeCode is released upon destruction of this + * @c TypeCode::Value_Box. + */ + CORBA::TypeCode_ptr * content_type_; + + }; + + } // End namespace TypeCode +} // End namespace TAO + + +#ifdef __ACE_INLINE__ +# include "tao/Value_Box_TypeCode.inl" +#endif /* __ACE_INLINE__ */ + +#ifdef ACE_TEMPLATES_REQUIRE_SOURCE +# include "tao/Value_Box_TypeCode.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#ifdef ACE_TEMPLATES_REQUIRE_PRAGMA +# pragma implementation ("Value_Box_TypeCode.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" + +#endif /* TAO_VALUE_BOX_TYPECODE_H */ |