diff options
author | Ossama Othman <ossama-othman@users.noreply.github.com> | 2005-03-07 11:43:40 +0000 |
---|---|---|
committer | Ossama Othman <ossama-othman@users.noreply.github.com> | 2005-03-07 11:43:40 +0000 |
commit | ad0c56987e7239c0212ffb2cff9a40c0b52bf5d3 (patch) | |
tree | 9abc2e7d0c99b7d679e4f5c0e7c6de8ef1274ffa | |
parent | 0b41eaeb64369a6a5da6983cdef1dcf777df97d9 (diff) | |
download | ATCD-ad0c56987e7239c0212ffb2cff9a40c0b52bf5d3.tar.gz |
*** empty log message ***
-rw-r--r-- | TAO/tao/TypeCode/Alias_TypeCode.cpp | 28 | ||||
-rw-r--r-- | TAO/tao/TypeCode/Enum_TypeCode.cpp | 4 | ||||
-rw-r--r-- | TAO/tao/TypeCode/Objref_TypeCode.cpp | 36 | ||||
-rw-r--r-- | TAO/tao/TypeCode/Struct_TypeCode.cpp | 4 | ||||
-rw-r--r-- | TAO/tao/TypeCode/Union_TypeCode.cpp | 6 | ||||
-rw-r--r-- | TAO/tao/TypeCode/Value_Box_TypeCode.cpp | 28 | ||||
-rw-r--r-- | TAO/tao/TypeCode/Value_TypeCode.cpp | 439 | ||||
-rw-r--r-- | TAO/tao/TypeCode/Value_TypeCode.h | 185 | ||||
-rw-r--r-- | TAO/tao/TypeCode/Value_TypeCode.inl | 41 |
9 files changed, 757 insertions, 14 deletions
diff --git a/TAO/tao/TypeCode/Alias_TypeCode.cpp b/TAO/tao/TypeCode/Alias_TypeCode.cpp index d153733b6eb..0f7c76d4851 100644 --- a/TAO/tao/TypeCode/Alias_TypeCode.cpp +++ b/TAO/tao/TypeCode/Alias_TypeCode.cpp @@ -144,4 +144,32 @@ TAO::TypeCode::Alias<StringType, RefCountPolicy>::get_compact_typecode_i ( ACE_ENV_ARG_PARAMETER); } +template <typename StringType, class RefCountPolicy> +char const * +TAO::TypeCode::Alias<StringType, RefCountPolicy>::id_i ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const +{ + // Ownership is retained by the TypeCode, as required by the C++ + // mapping. + return this->attributes_.id (); +} + +template <typename StringType, class RefCountPolicy> +char const * +TAO::TypeCode::Alias<StringType, RefCountPolicy>::name_i ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const +{ + // Ownership is retained by the TypeCode, as required by the C++ + // mapping. + return this->attributes_.name (); +} + +template <typename StringType, class RefCountPolicy> +CORBA::TypeCode_ptr +TAO::TypeCode::Alias<StringType, RefCountPolicy>::content_type_i ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const +{ + return CORBA::TypeCode::_duplicate (*this->content_type_); +} + #endif /* TAO_ALIAS_TYPECODE_CPP */ diff --git a/TAO/tao/TypeCode/Enum_TypeCode.cpp b/TAO/tao/TypeCode/Enum_TypeCode.cpp index c67b0c71b9e..f2a136a9ffe 100644 --- a/TAO/tao/TypeCode/Enum_TypeCode.cpp +++ b/TAO/tao/TypeCode/Enum_TypeCode.cpp @@ -226,7 +226,7 @@ TAO::TypeCode::Enum<StringType, template <typename StringType, class EnumeratorArrayType, class RefCountPolicy> char const * TAO::TypeCode::Enum<StringType, EnumeratorArrayType, RefCountPolicy>::id_i ( - ACE_ENV_SINGLE_ARG_DECL) const + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const { // Ownership is retained by the TypeCode, as required by the C++ // mapping. @@ -236,7 +236,7 @@ TAO::TypeCode::Enum<StringType, EnumeratorArrayType, RefCountPolicy>::id_i ( template <typename StringType, class EnumeratorArrayType, class RefCountPolicy> char const * TAO::TypeCode::Enum<StringType, EnumeratorArrayType, RefCountPolicy>::name_i ( - ACE_ENV_SINGLE_ARG_DECL) const + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const { // Ownership is retained by the TypeCode, as required by the C++ // mapping. diff --git a/TAO/tao/TypeCode/Objref_TypeCode.cpp b/TAO/tao/TypeCode/Objref_TypeCode.cpp index 993dae36cd8..ee372f4d8fa 100644 --- a/TAO/tao/TypeCode/Objref_TypeCode.cpp +++ b/TAO/tao/TypeCode/Objref_TypeCode.cpp @@ -12,7 +12,7 @@ template <typename StringType, CORBA::TCKind Kind, class RefCountPolicy> bool -TAO::TypeCode::Objref<StringType, RefCountPolicy>::tao_marshal ( +TAO::TypeCode::Objref<StringType, CORBA::TCKind, RefCountPolicy>::tao_marshal ( TAO_OutputCDR &) const { // A tk_objref TypeCode has a "complex" parameter list type (see @@ -29,21 +29,21 @@ TAO::TypeCode::Objref<StringType, RefCountPolicy>::tao_marshal ( template <typename StringType, CORBA::TCKind Kind, class RefCountPolicy> void -TAO::TypeCode::Objref<StringType, RefCountPolicy>::tao_duplicate (void) +TAO::TypeCode::Objref<StringType, Kind, RefCountPolicy>::tao_duplicate (void) { this->RefCountPolicy::add_ref (void); } template <typename StringType, CORBA::TCKind Kind, class RefCountPolicy> void -TAO::TypeCode::Objref<StringType, RefCountPolicy>::tao_release (void) +TAO::TypeCode::Objref<StringType, Kind, RefCountPolicy>::tao_release (void) { this->RefCountPolicy::remove_ref (void); } template <typename StringType, CORBA::TCKind Kind, class RefCountPolicy> CORBA::Boolean -TAO::TypeCode::Objref<StringType, RefCountPolicy>::equal_i ( +TAO::TypeCode::Objref<StringType, Kind, RefCountPolicy>::equal_i ( CORBA::TypeCode_ptr /* tc */ ACE_ENV_ARG_DECL_NOT_USED) const { @@ -55,7 +55,7 @@ TAO::TypeCode::Objref<StringType, RefCountPolicy>::equal_i ( template <typename StringType, CORBA::TCKind Kind, class RefCountPolicy> CORBA::Boolean -TAO::TypeCode::Objref<StringType, RefCountPolicy>::equivalent_i ( +TAO::TypeCode::Objref<StringType, Kind, RefCountPolicy>::equivalent_i ( CORBA::TypeCode_ptr tc ACE_ENV_ARG_DECL) const { @@ -85,7 +85,7 @@ TAO::TypeCode::Objref<StringType, RefCountPolicy>::equivalent_i ( template <typename StringType, CORBA::TCKind Kind, class RefCountPolicy> CORBA::TCKind -TAO::TypeCode::Objref<StringType, RefCountPolicy>::kind_i ( +TAO::TypeCode::Objref<StringType, Kind, RefCountPolicy>::kind_i ( ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const { return Objref_Traits<Kind>::kind; @@ -93,7 +93,7 @@ TAO::TypeCode::Objref<StringType, RefCountPolicy>::kind_i ( template <typename StringType, CORBA::TCKind Kind, class RefCountPolicy> CORBA::TypeCode_ptr -TAO::TypeCode::Objref<StringType, RefCountPolicy>::get_compact_typecode_i ( +TAO::TypeCode::Objref<StringType, Kind, RefCountPolicy>::get_compact_typecode_i ( ACE_ENV_SINGLE_ARG_DECL) const { TAO_TypeCodeFactory_Adapter * adapter = @@ -113,4 +113,26 @@ TAO::TypeCode::Objref<StringType, RefCountPolicy>::get_compact_typecode_i ( ACE_ENV_ARG_PARAMETER); } + +template <typename StringType, CORBA::TCKind Kind, class RefCountPolicy> +char const * +TAO::TypeCode::Objref<StringType, Kind, RefCountPolicy>::id_i ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const +{ + // Ownership is retained by the TypeCode, as required by the C++ + // mapping. + return this->attributes_.id (); +} + +template <typename StringType, CORBA::TCKind Kind, class RefCountPolicy> +char const * +TAO::TypeCode::Objref<StringType, Kind, RefCountPolicy>::name_i ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const +{ + // Ownership is retained by the TypeCode, as required by the C++ + // mapping. + return this->attributes_.name (); +} + + #endif /* TAO_OBJREF_TYPECODE_CPP */ diff --git a/TAO/tao/TypeCode/Struct_TypeCode.cpp b/TAO/tao/TypeCode/Struct_TypeCode.cpp index 2a5e1d328c3..e7fae13b4db 100644 --- a/TAO/tao/TypeCode/Struct_TypeCode.cpp +++ b/TAO/tao/TypeCode/Struct_TypeCode.cpp @@ -298,7 +298,7 @@ TAO::TypeCode::Struct<StringType, FieldArrayType, Kind, RefCountPolicy>::id_i ( - ACE_ENV_SINGLE_ARG_DECL) const + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const { // Ownership is retained by the TypeCode, as required by the C++ // mapping. @@ -314,7 +314,7 @@ TAO::TypeCode::Struct<StringType, FieldArrayType, Kind, RefCountPolicy>::name_i ( - ACE_ENV_SINGLE_ARG_DECL) const + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const { // Ownership is retained by the TypeCode, as required by the C++ // mapping. diff --git a/TAO/tao/TypeCode/Union_TypeCode.cpp b/TAO/tao/TypeCode/Union_TypeCode.cpp index 78f851a3ced..777493202e5 100644 --- a/TAO/tao/TypeCode/Union_TypeCode.cpp +++ b/TAO/tao/TypeCode/Union_TypeCode.cpp @@ -291,7 +291,7 @@ TAO::TypeCode::Union<StringType, template <typename StringType, class CaseArrayType, class RefCountPolicy> char const * TAO::TypeCode::Union<StringType, CaseArrayType, RefCountPolicy>::id_i ( - ACE_ENV_SINGLE_ARG_DECL) const + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const { // Ownership is retained by the TypeCode, as required by the C++ // mapping. @@ -301,7 +301,7 @@ TAO::TypeCode::Union<StringType, CaseArrayType, RefCountPolicy>::id_i ( template <typename StringType, class CaseArrayType, class RefCountPolicy> char const * TAO::TypeCode::Union<StringType, CaseArrayType, RefCountPolicy>::name_i ( - ACE_ENV_SINGLE_ARG_DECL) const + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const { // Ownership is retained by the TypeCode, as required by the C++ // mapping. @@ -378,7 +378,7 @@ CORBA::Long TAO::TypeCode::Union<StringType, CaseArrayType, RefCountPolicy>::default_index_i ( - ACE_ENV_SINGLE_ARG_DECL) const + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const { return this->default_index_; } diff --git a/TAO/tao/TypeCode/Value_Box_TypeCode.cpp b/TAO/tao/TypeCode/Value_Box_TypeCode.cpp index 368d0141d81..d80f0d6b58d 100644 --- a/TAO/tao/TypeCode/Value_Box_TypeCode.cpp +++ b/TAO/tao/TypeCode/Value_Box_TypeCode.cpp @@ -144,4 +144,32 @@ TAO::TypeCode::Value_Box<StringType, RefCountPolicy>::get_compact_typecode_i ( ACE_ENV_ARG_PARAMETER); } +template <typename StringType, class RefCountPolicy> +char const * +TAO::TypeCode::Value_Box<StringType, RefCountPolicy>::id_i ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const +{ + // Ownership is retained by the TypeCode, as required by the C++ + // mapping. + return this->attributes_.id (); +} + +template <typename StringType, class RefCountPolicy> +char const * +TAO::TypeCode::Value_Box<StringType, RefCountPolicy>::name_i ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const +{ + // Ownership is retained by the TypeCode, as required by the C++ + // mapping. + return this->attributes_.name (); +} + +template <typename StringType, class RefCountPolicy> +CORBA::TypeCode_ptr +TAO::TypeCode::Value_Box<StringType, RefCountPolicy>::content_type_i ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const +{ + return CORBA::TypeCode::_duplicate (*this->content_type_); +} + #endif /* TAO_VALUE_BOX_TYPECODE_CPP */ diff --git a/TAO/tao/TypeCode/Value_TypeCode.cpp b/TAO/tao/TypeCode/Value_TypeCode.cpp new file mode 100644 index 00000000000..b29dc0b0863 --- /dev/null +++ b/TAO/tao/TypeCode/Value_TypeCode.cpp @@ -0,0 +1,439 @@ +// $Id$ + +#ifndef TAO_VALUE_TYPECODE_CPP +#define TAO_VALUE_TYPECODE_CPP + +#include "tao/Value_TypeCode.h" +#include "tao/TypeCode_Field.h" + +#ifndef __ACE_INLINE__ +# include "tao/Value_TypeCode.inl" +#endif /* !__ACE_INLINE__ */ + + +template <typename StringType, + class FieldArrayType, + CORBA::TCKind Kind, + class RefCountPolicy> +bool +TAO::TypeCode::Value<StringType, + FieldArrayType, + Kind, + RefCountPolicy>::tao_marshal ( + TAO_OutputCDR & cdr) const +{ + // A tk_value 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. + bool const success = + (cdr << TAO_ENCAP_BYTE_ORDER) + && (cdr << this->base_attributes_.id ()) + && (cdr << this->base_attributes_.name ()) + && (cdr << this->value_modifier_) + && (cdr << *this->concrete_base_) + && (cdr << this->nfields_); + + if (!success) + return false; + + Field<StringType> const * const begin = this->fields (); + Field<StringType> const * const end = begin + this->nfields_; + + for (Field<StringType> const * i = begin; i != end; ++i) + { + Field<StringType> const & field = *i; + + if (!(cdr << field.get_name ()) + || !(cdr << *(field.type)) + || !(cdr << field.visibility)) + return false; + } + + return true; +} + +template <typename StringType, + class FieldArrayType, + CORBA::TCKind Kind, + class RefCountPolicy> +void +TAO::TypeCode::Value<StringType, + FieldArrayType, + Kind, + RefCountPolicy>::tao_duplicate (void) +{ + this->RefCountPolicy::add_ref (void); +} + +template <typename StringType, + class FieldArrayType, + CORBA::TCKind Kind, + class RefCountPolicy> +void +TAO::TypeCode::Value<StringType, + FieldArrayType, + Kind, + RefCountPolicy>::tao_release (void) +{ + this->RefCountPolicy::remove_ref (void); +} + +template <typename StringType, + class FieldArrayType, + CORBA::TCKind Kind, + class RefCountPolicy> +CORBA::Boolean +TAO::TypeCode::Value<StringType, + FieldArrayType, + Kind, + RefCountPolicy>::equal_i ( + CORBA::TypeCode_ptr tc + ACE_ENV_ARG_DECL) const +{ + // This call shouldn't throw since CORBA::TypeCode::equal() verified + // that the TCKind is the same as our's prior to invoking this + // method, meaning that member_count() is supported. + + CORBA::ULong const tc_nfields = + tc->member_count (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + if (tc_nfields != this->nfields_) + return 0; + + for (CORBA::ULong i = 0; i < this->nfields_; ++i) + { + Field<StringType> const & lhs_field = this->fields_[i]; + + char const * const lhs_name = lhs_field.get_name (); + char const * const rhs_name = tc->member_name (i + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + if (ACE_OS::strcmp (lhs_name, rhs_name) != 0) + return 0; + + +ADD MISSING ATTRIBUTES + + + CORBA::TypeCode_ptr const lhs_tc = *(lhs_field.type); + CORBA::TypeCode_var const rhs_tc = + tc->member_type (i + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + CORBA::Boolean const equal_members = + lhs_tc->equal (rhs_tc.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + if (!equal_members) + return 0; + } + + return 1; +} + +template <typename StringType, + class FieldArrayType, + CORBA::TCKind Kind, + class RefCountPolicy> +CORBA::Boolean +TAO::TypeCode::Value<StringType, + FieldArrayType, + Kind, + 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); + + // Call kind_i() instead of using CORBA::tk_value directly since a + // subclass, such as Except_TypeCode, can use this equivalent_i() + // implementation. + CORBA::TCKind const this_kind = + this->kind_i (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + if (tc_kind != this_kind) + return 0; + + char const * const this_id = this->base_attributes_.id (); + char const * const tc_id = tc->id (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + +ADD MISSING ATTRIBUTES + + + if (ACE_OS::strlen (this_id) == 0 + || ACE_OS::strlen (tc_id) == 0) + { + // Perform a structural comparison, excluding the name() and + // member_name() operations. + + CORBA::ULong const tc_nfields = + tc->member_count (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + if (tc_nfields != this->nfields_) + return 0; + + for (CORBA::ULong i = 0; i < this->nfields_; ++i) + { + CORBA::TypeCode_ptr const lhs = *(this->fields_[i].type); + CORBA::TypeCode_var const rhs = + tc->member_type (i + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + CORBA::Boolean const equiv_members = + lhs->equivalent (rhs.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + if (!equiv_members) + return 0; + } + } + else if (ACE_OS::strcmp (this_id, tc_id) != 0) + { + return 0; + } + + return 1; +} + +template <typename StringType, + class FieldArrayType, + CORBA::TCKind Kind, + class RefCountPolicy> +CORBA::TCKind +TAO::TypeCode::Value<StringType, + FieldArrayType, + Kind, + RefCountPolicy>::kind_i ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const +{ + return Value_Traits<Kind>::kind; +} + +template <typename StringType, + class FieldArrayType, + CORBA::TCKind Kind, + class RefCountPolicy> +CORBA::TypeCode_ptr +TAO::TypeCode::Value<StringType, + FieldArrayType, + Kind, + RefCountPolicy>::get_compact_typecode_i ( + ACE_ENV_SINGLE_ARG_DECL) const +{ + Field<StringType> * tc_fields = 0; + + ACE_Auto_Array_Ptr<Field<StringType> > safe_fields; + + if (this->nfields_ > 0) + { + // Dynamically construct a new array of fields stripped of + // member names. + + ACE_NEW_THROW_EX (tc_fields, + Field<StringType> [this->nfields_], + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (CORBA::TypeCode::_nil ()); + + safe_fields.reset (fields); + + static char const * const empty_name = ""; + + for (CORBA::ULong i = 0; i < this->nfields_; ++i) + { + // Member names will be stripped, i.e. not embedded within + // the compact TypeCode. + + tc_fields[i].name = empty_name; + tc_fields[i].type = + &(*(this->fields_[i].type)->get_compact_typecode ( + ACE_ENV_ARG_PARAMETER)); + ACE_CHECK_RETURN (CORBA::TypeCode::_nil ()); + tc_fields[i].visibility = this->fields_[i].visibility; + } + } + + 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::TCKind const this_kind = + this->kind_i (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (CORBA::TypeCode::_nil ()); + + tc = adapter->_tao_create_value_event_tc (this_kind, + this->base_attributes_.id (), + "" /* empty name */, + this->value_modifier_, + *this->concrete_base_, + tc_fields, + this->nfields_ + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (CORBA::TypeCode::_nil ()); + + (void) safe_fields.release (); + + return tc; +} + +template <typename StringType, + class FieldArrayType, + CORBA::TCKind Kind, + class RefCountPolicy> +char const * +TAO::TypeCode::Value<StringType, + FieldArrayType, + Kind, + RefCountPolicy>::id_i ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const +{ + // Ownership is retained by the TypeCode, as required by the C++ + // mapping. + return this->base_attributes_.id (); +} + +template <typename StringType, + class FieldArrayType, + CORBA::TCKind Kind, + class RefCountPolicy> +char const * +TAO::TypeCode::Value<StringType, + FieldArrayType, + Kind, + RefCountPolicy>::name_i ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const +{ + // Ownership is retained by the TypeCode, as required by the C++ + // mapping. + return this->base_attributes_.name (); +} + +template <typename StringType, + class FieldArrayType, + CORBA::TCKind Kind, + class RefCountPolicy> +CORBA::ULong +TAO::TypeCode::Value<StringType, + FieldArrayType, + Kind, + RefCountPolicy>::member_count_i ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const +{ + return this->nfields_; +} + +template <typename StringType, + class FieldArrayType, + CORBA::TCKind Kind, + class RefCountPolicy> +char const * +TAO::TypeCode::Value<StringType, + FieldArrayType, + Kind, + RefCountPolicy>::member_name_i ( + CORBA::ULong index + ACE_ENV_ARG_DECL) const +{ + // Ownership is retained by the TypeCode, as required by the C++ + // mapping. + if (index >= this->nfields_) + ACE_THROW_RETURN (CORBA::TypeCode::Bounds (), 0); + + return this->fields_[index].get_name (); +} + +template <typename StringType, + class FieldArrayType, + CORBA::TCKind Kind, + class RefCountPolicy> +CORBA::TypeCode_ptr +TAO::TypeCode::Value<StringType, + FieldArrayType, + Kind, + RefCountPolicy>::member_type_i ( + CORBA::ULong index + ACE_ENV_ARG_DECL) const +{ + if (index >= this->nfields_) + ACE_THROW_RETURN (CORBA::TypeCode::Bounds (), + CORBA::TypeCode::_nil ()); + + return CORBA::TypeCode::_duplicate (*(this->fields_[index].type)); +} + +template <typename StringType, + class FieldArrayType, + CORBA::TCKind Kind, + class RefCountPolicy> +CORBA::Visibility +TAO::TypeCode::Value<StringType, + FieldArrayType, + Kind, + RefCountPolicy>::member_visibility_i ( + ULong index + ACE_ENV_ARG_DECL) const +{ + if (index >= this->nfields_) + ACE_THROW_RETURN (CORBA::TypeCode::Bounds (), + CORBA::TypeCode::_nil ()); + + return this->fields_[index].visibility)); +} + +template <typename StringType, + class FieldArrayType, + CORBA::TCKind Kind, + class RefCountPolicy> +CORBA::ValueModifier +TAO::TypeCode::Value<StringType, + FieldArrayType, + Kind, + RefCountPolicy>::type_modifier ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const +{ + return this->type_modifier_; +} + +template <typename StringType, + class FieldArrayType, + CORBA::TCKind Kind, + class RefCountPolicy> +CORBA::TypeCode_ptr +TAO::TypeCode::Value<StringType, + FieldArrayType, + Kind, + RefCountPolicy>::concrete_base_type ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const +{ + return CORBA::TypeCode::_duplicate (*(this->concrete_base_)); +} + + +#endif /* TAO_VALUE_TYPECODE_CPP */ diff --git a/TAO/tao/TypeCode/Value_TypeCode.h b/TAO/tao/TypeCode/Value_TypeCode.h new file mode 100644 index 00000000000..3012a0fd592 --- /dev/null +++ b/TAO/tao/TypeCode/Value_TypeCode.h @@ -0,0 +1,185 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Value_TypeCode.h + * + * $Id$ + * + * Header file for a @c tk_value and @c tk_event + * @c CORBA::TypeCodes. + * + * @author Ossama Othman <ossama@dre.vanderbilt.edu> + * @author Carlos O'Ryan + */ +//============================================================================= + +#ifndef TAO_VALUE_TYPECODE_H +#define TAO_VALUE_TYPECODE_H + +#include /**/ "ace/pre.h" + +#include "tao/TypeCode.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/TypeCode_Base_Attributes.h" + + +namespace TAO +{ + namespace TypeCode + { + template <CORBA::TCKind KIND> Value_Traits; + + template <> + struct Value_Traits<CORBA::tk_value> + { + enum { kind = CORBA::tk_value }; + }; + + template <> + struct Value_Traits<CORBA::tk_event> + { + enum { kind = CORBA::tk_event }; + }; + + + /** + * @class Value + * + * @brief @c CORBA::TypeCode implementation for an OMG IDL + * @c valuetype or @c event. + * + * This class implements a @c CORBA::TypeCode for an OMG IDL + * @c valuetype or @c event. + */ + template <typename StringType, + class FieldArrayType, + CORBA::TCKind Kind, + class RefCountPolicy> + class Value + : public CORBA::TypeCode, + private RefCountPolicy + { + public: + + /// Constructor. + Value (char const * id, + char const * name, + CORBA::ValueModifer modifier, + CORBA::TypeCode_ptr * concrete_base, + Field<StringType> const * fields, + CORBA::ULong nfields); + + /** + * @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 or @c tk_event @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 CORBA::ULong member_count_i (ACE_ENV_SINGLE_ARG_DECL) const; + virtual char const * member_name_i (CORBA::ULong index + ACE_ENV_ARG_DECL) const; + virtual CORBA::TypeCode_ptr member_type_i (CORBA::ULong index + ACE_ENV_ARG_DECL) const; + virtual CORBA::Visibility member_visibility_i (ULong index + ACE_ENV_ARG_DECL) const; + virtual CORBA::ValueModifier type_modifier ( + ACE_ENV_SINGLE_ARG_DECL) const; + virtual CORBA::TypeCode_ptr concrete_base_type ( + ACE_ENV_SINGLE_ARG_DECL) const; + //@} + + private: + + /// Get pointer to the underlying @c Field array. + Field<StringType> const * fields (void) const; + + private: + + /** + * @c Valuetype Attributes + * + * Attributes representing the structure of an OMG IDL + * @c valuetype or @c event. + * + * @note These attributes are declared in the order in which + * they are marshaled into a CDR stream in order to + * increase cache hits by improving spatial locality. + */ + //@{ + + /// Base attributes containing repository ID and name of + /// @c valuetype. + Base_Attributes<StringType> const base_attributes_; + + /// The @c ValueModifier of the @c valuetype of @c eventtype + /// represented by this @c TypeCode. + CORBA::ValueModifer const value_modifier_; + + /// The @c TypeCode corresponding to the concrete base + /// @c valuetype or @c eventtype. + CORBA::TypeCode_ptr * const concrete_base_; + + /// The number of fields in the OMG IDL value. + CORBA::ULong const nfields_; + + /// Array of @c TAO::TypeCode fields representing structure of the + /// OMG IDL defined @c value. + FieldArrayType const fields_; + + //@} + + }; + + } // End namespace TypeCode +} // End namespace TAO + + +#ifdef __ACE_INLINE__ +# include "tao/Value_TypeCode.inl" +#endif /* __ACE_INLINE__ */ + +#ifdef ACE_TEMPLATES_REQUIRE_SOURCE +# include "tao/Value_TypeCode.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#ifdef ACE_TEMPLATES_REQUIRE_PRAGMA +# pragma implementation ("Value_TypeCode.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + + +#include /**/ "ace/post.h" + +#endif /* TAO_VALUE_TYPECODE_H */ diff --git a/TAO/tao/TypeCode/Value_TypeCode.inl b/TAO/tao/TypeCode/Value_TypeCode.inl new file mode 100644 index 00000000000..9f9135325f6 --- /dev/null +++ b/TAO/tao/TypeCode/Value_TypeCode.inl @@ -0,0 +1,41 @@ +// -*- C++ -*- +// +// $Id$ + +template <typename StringType, + class FieldArrayType, + CORBA::TCKind Kind, + class RefCountPolicy> +ACE_INLINE +TAO::TypeCode::Struct<StringType, FieldArrayType, RefCountPolicy>::Struct ( + char const * id, + char const * name, + Field<StringType> const * fields, + CORBA::ULong nfields) + : base_attributes_ (id, name) + , nfields_ (nfields) + , fields_ (fields) +{ +} + +template <typename StringType, + class FieldArrayType, + CORBA::TCKind Kind, + class RefCountPolicy> +ACE_INLINE TAO::TypeCode::Field<StringType> const * +TAO::TypeCode::Struct<StringType, + FieldArrayType>::fields (void) const +{ + return this->fields_; +} + +// ------------------------------------------------------------- +// Member specializations +// ------------------------------------------------------------- + +ACE_INLINE TAO::TypeCode::Field<CORBA::String_var> const * +TAO::TypeCode::Struct<CORBA::String_var, + ACE_Auto_Ptr_Array<Field<CORBA::String_var> const> >::fields (void) const +{ + return this->fields_.get (); +} |