diff options
author | William R. Otte <wotte@dre.vanderbilt.edu> | 2006-07-24 15:50:21 +0000 |
---|---|---|
committer | William R. Otte <wotte@dre.vanderbilt.edu> | 2006-07-24 15:50:21 +0000 |
commit | 3aff90f4a822fcf5d902bbfbcc9fa931d6191a8c (patch) | |
tree | 197c810e5f5bce17b1233a7cb8d7b50c0bcd25e2 /TAO/tao/AnyTypeCode | |
parent | 6b846cf03c0bcbd8c276cb0af61a181e5f98eaae (diff) | |
download | ATCD-3aff90f4a822fcf5d902bbfbcc9fa931d6191a8c.tar.gz |
Repo restructuring
Diffstat (limited to 'TAO/tao/AnyTypeCode')
152 files changed, 25435 insertions, 0 deletions
diff --git a/TAO/tao/AnyTypeCode/Alias_TypeCode.cpp b/TAO/tao/AnyTypeCode/Alias_TypeCode.cpp new file mode 100644 index 00000000000..d968f65b205 --- /dev/null +++ b/TAO/tao/AnyTypeCode/Alias_TypeCode.cpp @@ -0,0 +1,204 @@ +// $Id$ + +#ifndef TAO_ALIAS_TYPECODE_CPP +#define TAO_ALIAS_TYPECODE_CPP + +#include "tao/AnyTypeCode/Alias_TypeCode.h" + +#ifndef __ACE_INLINE__ +# include "tao/AnyTypeCode/Alias_TypeCode.inl" +#endif /* !__ACE_INLINE__ */ + +#include "tao/ORB_Core.h" +#include "tao/CDR.h" +#include "tao/AnyTypeCode/TypeCode_Traits.h" + +#include "ace/Dynamic_Service.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +template <typename StringType, + typename TypeCodeType, + class RefCountPolicy> +bool +TAO::TypeCode::Alias<StringType, + TypeCodeType, + RefCountPolicy>::tao_marshal (TAO_OutputCDR & cdr, + CORBA::ULong offset) const +{ + // A tk_alias 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. + + TAO_OutputCDR enc; + + // Account for the encoded CDR encapsulation length and byte order. + // + // Aligning on an octet since the next value after the CDR + // encapsulation length will always be the byte order octet/boolean + // in this case. + offset = ACE_align_binary (offset + 4, + ACE_CDR::OCTET_ALIGN); + + return + enc << TAO_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER) + && enc << TAO_OutputCDR::from_string (this->attributes_.id (), 0) + && enc << TAO_OutputCDR::from_string (this->attributes_.name (), 0) + && marshal (enc, + Traits<StringType>::get_typecode (this->content_type_), + offset + enc.total_length ()) + && cdr << static_cast<CORBA::ULong> (enc.total_length ()) + && cdr.write_octet_array_mb (enc.begin ()); +} + +template<typename StringType, + typename TypeCodeType, + class RefCountPolicy> +void +TAO::TypeCode::Alias<StringType, + TypeCodeType, + RefCountPolicy>::tao_duplicate (void) +{ + this->RefCountPolicy::add_ref (); +} + +template<typename StringType, + typename TypeCodeType, + class RefCountPolicy> +void +TAO::TypeCode::Alias<StringType, + TypeCodeType, + RefCountPolicy>::tao_release (void) +{ + this->RefCountPolicy::remove_ref (); +} + +template<typename StringType, + typename TypeCodeType, + class RefCountPolicy> +CORBA::Boolean +TAO::TypeCode::Alias<StringType, + TypeCodeType, + RefCountPolicy>::equal_i (CORBA::TypeCode_ptr tc + ACE_ENV_ARG_DECL) const +{ + // The CORBA::TypeCode base class already verified equality of the + // base attributes (id and name). Perform an equality comparison of + // the content. + + CORBA::TypeCode_var rhs_content_type = + tc->content_type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + return + Traits<StringType>::get_typecode (this->content_type_)->equal ( + rhs_content_type.in () + ACE_ENV_ARG_PARAMETER); +} + +template<typename StringType, + typename TypeCodeType, + class RefCountPolicy> +CORBA::Boolean +TAO::TypeCode::Alias<StringType, + TypeCodeType, + RefCountPolicy>::equivalent_i ( + CORBA::TypeCode_ptr + ACE_ENV_ARG_DECL_NOT_USED) const +{ + // Equivalence already verified in the base class + // CORBA::TypeCode::equivalent() method. + + return true; +} + +template<typename StringType, + typename TypeCodeType, + class RefCountPolicy> +CORBA::TypeCode_ptr +TAO::TypeCode::Alias<StringType, + TypeCodeType, + RefCountPolicy>::get_compact_typecode_i ( + ACE_ENV_SINGLE_ARG_DECL) const +{ + TAO_TypeCodeFactory_Adapter * const adapter = + ACE_Dynamic_Service<TAO_TypeCodeFactory_Adapter>::instance ( + TAO_ORB_Core::typecodefactory_adapter_name () + ); + + if (adapter == 0) + { + ACE_THROW_RETURN (CORBA::INITIALIZE (), + CORBA::TypeCode::_nil ()); + } + + CORBA::TypeCode_var compact_content_type = + Traits<StringType>::get_typecode ( + this->content_type_)->get_compact_typecode ( + ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (CORBA::TypeCode::_nil ()); + + if (this->kind_ == CORBA::tk_alias) + { + return adapter->create_alias_tc (this->attributes_.id (), + "", /* empty name */ + compact_content_type.in () + ACE_ENV_ARG_PARAMETER); + } + else + { + return adapter->create_value_box_tc (this->attributes_.id (), + "", /* empty name */ + compact_content_type.in () + ACE_ENV_ARG_PARAMETER); + } +} + +template<typename StringType, + typename TypeCodeType, + class RefCountPolicy> +char const * +TAO::TypeCode::Alias<StringType, + TypeCodeType, + 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, + typename TypeCodeType, + class RefCountPolicy> +char const * +TAO::TypeCode::Alias<StringType, + TypeCodeType, + 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, + typename TypeCodeType, + class RefCountPolicy> +CORBA::TypeCode_ptr +TAO::TypeCode::Alias<StringType, + TypeCodeType, + RefCountPolicy>::content_type_i ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const +{ + return + CORBA::TypeCode::_duplicate ( + Traits<StringType>::get_typecode (this->content_type_)); +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +#endif /* TAO_ALIAS_TYPECODE_CPP */ diff --git a/TAO/tao/AnyTypeCode/Alias_TypeCode.h b/TAO/tao/AnyTypeCode/Alias_TypeCode.h new file mode 100644 index 00000000000..201f3f001fc --- /dev/null +++ b/TAO/tao/AnyTypeCode/Alias_TypeCode.h @@ -0,0 +1,144 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Alias_TypeCode.h + * + * $Id$ + * + * Header file for a @c tk_alias and @c tk_value_box + * @c CORBA::TypeCode. + * + * @author Ossama Othman <ossama@dre.vanderbilt.edu> + */ +//============================================================================= + +#ifndef TAO_ALIAS_TYPECODE_H +#define TAO_ALIAS_TYPECODE_H + +#include /**/ "ace/pre.h" + +#include "tao/AnyTypeCode/TypeCode.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/TypeCodeFactory_Adapter.h" +#include "tao/AnyTypeCode/TypeCode_Base_Attributes.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + namespace TypeCode + { + /** + * @class Alias + * + * @brief @c CORBA::TypeCode implementation for an OMG IDL + * @c typedef. + * + * This class implements a @c CORBA::TypeCode for an OMG IDL + * @c typedef. + */ + template <typename StringType, + typename TypeCodeType, + class RefCountPolicy> + class Alias + : public CORBA::TypeCode, + private RefCountPolicy + { + public: + + /// Constructor. + Alias (CORBA::TCKind kind, + char const * id, + char const * name, +#if defined (__BORLANDC__) && (__BORLANDC__ < 0x572) + // Borland C++ currently can't handle a reference to + // const pointer to const CORBA::TypeCode_ptr + TypeCodeType tc); +#else + TypeCodeType const & tc); +#endif + + /** + * @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, + CORBA::ULong offset) const; + virtual void tao_duplicate (void); + virtual void tao_release (void); + //@} + + protected: + + /** + * @name @c TAO CORBA::TypeCode Template Methods + * + * @c tk_alias and @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::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::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 @c typedef. + Base_Attributes<StringType> attributes_; + + /// The @c TypeCode corresponding to the original type upon + /// which the IDL @c typedef 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::Alias. + */ + TypeCodeType const content_type_; + + }; + + } // End namespace TypeCode +} // End namespace TAO + +TAO_END_VERSIONED_NAMESPACE_DECL + + +#ifdef __ACE_INLINE__ +# include "tao/AnyTypeCode/Alias_TypeCode.inl" +#endif /* __ACE_INLINE__ */ + +#ifdef ACE_TEMPLATES_REQUIRE_SOURCE +# include "tao/AnyTypeCode/Alias_TypeCode.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#ifdef ACE_TEMPLATES_REQUIRE_PRAGMA +# pragma implementation ("Alias_TypeCode.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" + +#endif /* TAO_ALIAS_TYPECODE_H */ diff --git a/TAO/tao/AnyTypeCode/Alias_TypeCode.inl b/TAO/tao/AnyTypeCode/Alias_TypeCode.inl new file mode 100644 index 00000000000..d781ee5641f --- /dev/null +++ b/TAO/tao/AnyTypeCode/Alias_TypeCode.inl @@ -0,0 +1,31 @@ +// -*- C++ -*- +// +// $Id$ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +template<typename StringType, + typename TypeCodeType, + class RefCountPolicy> +ACE_INLINE +TAO::TypeCode::Alias<StringType, + TypeCodeType, + RefCountPolicy>::Alias ( + CORBA::TCKind kind, + char const * id, + char const * name, +#if defined (__BORLANDC__) && (__BORLANDC__ < 0x572) + // Borland C++ currently can't handle a reference to + // const pointer to const CORBA::TypeCode_ptr + TypeCodeType tc) +#else + TypeCodeType const & tc) +#endif + : ::CORBA::TypeCode (kind) + , RefCountPolicy () + , attributes_ (id, name) + , content_type_ (tc) +{ +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/Alias_TypeCode_Static.cpp b/TAO/tao/AnyTypeCode/Alias_TypeCode_Static.cpp new file mode 100644 index 00000000000..c3c9e26c1a6 --- /dev/null +++ b/TAO/tao/AnyTypeCode/Alias_TypeCode_Static.cpp @@ -0,0 +1,178 @@ +// $Id$ + +#include "tao/AnyTypeCode/Alias_TypeCode_Static.h" + +#ifndef __ACE_INLINE__ +# include "tao/AnyTypeCode/Alias_TypeCode_Static.inl" +#endif /* !__ACE_INLINE__ */ + +#include "tao/AnyTypeCode/TypeCode_Traits.h" + +#include "tao/ORB_Core.h" +#include "tao/CDR.h" +#include "tao/TypeCodeFactory_Adapter.h" + +#include "ace/Dynamic_Service.h" + + +ACE_RCSID (AnyTypeCode, + Alias_TypeCode_Static, + "$Id$") + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +bool +TAO::TypeCode::Alias<char const *, + CORBA::TypeCode_ptr const *, + TAO::Null_RefCount_Policy>::tao_marshal ( + TAO_OutputCDR & cdr, + CORBA::ULong offset) const +{ + // A tk_alias 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. + + TAO_OutputCDR enc; + + // Account for the encoded CDR encapsulation length and byte order. + // + // Aligning on an octet since the next value after the CDR + // encapsulation length will always be the byte order octet/boolean + // in this case. + offset = ACE_align_binary (offset + 4, + ACE_CDR::OCTET_ALIGN); + + return + enc << TAO_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER) + && enc << TAO_OutputCDR::from_string (this->attributes_.id (), 0) + && enc << TAO_OutputCDR::from_string (this->attributes_.name (), 0) + && marshal (enc, + Traits<char const *>::get_typecode (this->content_type_), + offset + enc.total_length ()) + && cdr << static_cast<CORBA::ULong> (enc.total_length ()) + && cdr.write_octet_array_mb (enc.begin ()); +} + +void +TAO::TypeCode::Alias<char const *, + CORBA::TypeCode_ptr const *, + TAO::Null_RefCount_Policy>::tao_duplicate (void) +{ +} + +void +TAO::TypeCode::Alias<char const *, + CORBA::TypeCode_ptr const *, + TAO::Null_RefCount_Policy>::tao_release (void) +{ +} + +CORBA::Boolean +TAO::TypeCode::Alias<char const *, + CORBA::TypeCode_ptr const *, + TAO::Null_RefCount_Policy>::equal_i (CORBA::TypeCode_ptr tc + ACE_ENV_ARG_DECL) const +{ + // The CORBA::TypeCode base class already verified equality of the + // base attributes (id and name). Perform an equality comparison of + // the content. + + CORBA::TypeCode_var rhs_content_type = + tc->content_type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + return + Traits<char const *>::get_typecode (this->content_type_)->equal ( + rhs_content_type.in () + ACE_ENV_ARG_PARAMETER); +} + +CORBA::Boolean +TAO::TypeCode::Alias<char const *, + CORBA::TypeCode_ptr const *, + TAO::Null_RefCount_Policy>::equivalent_i ( + CORBA::TypeCode_ptr + ACE_ENV_ARG_DECL_NOT_USED) const +{ + // Equivalence already verified in the base class + // CORBA::TypeCode::equivalent() method. + + return true; +} + +CORBA::TypeCode_ptr +TAO::TypeCode::Alias<char const *, + CORBA::TypeCode_ptr const *, + TAO::Null_RefCount_Policy>::get_compact_typecode_i ( + ACE_ENV_SINGLE_ARG_DECL) const +{ + TAO_TypeCodeFactory_Adapter * const adapter = + ACE_Dynamic_Service<TAO_TypeCodeFactory_Adapter>::instance ( + TAO_ORB_Core::typecodefactory_adapter_name () + ); + + if (adapter == 0) + { + ACE_THROW_RETURN (CORBA::INITIALIZE (), + CORBA::TypeCode::_nil ()); + } + + CORBA::TypeCode_var compact_content_type = + Traits<char const *>::get_typecode ( + this->content_type_)->get_compact_typecode ( + ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (CORBA::TypeCode::_nil ()); + + if (this->kind_ == CORBA::tk_alias) + { + return adapter->create_alias_tc (this->attributes_.id (), + "", /* empty name */ + compact_content_type.in () + ACE_ENV_ARG_PARAMETER); + } + else + { + return adapter->create_value_box_tc (this->attributes_.id (), + "", /* empty name */ + compact_content_type.in () + ACE_ENV_ARG_PARAMETER); + } +} + +char const * +TAO::TypeCode::Alias<char const *, + CORBA::TypeCode_ptr const *, + TAO::Null_RefCount_Policy>::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 (); +} + +char const * +TAO::TypeCode::Alias<char const *, + CORBA::TypeCode_ptr const *, + TAO::Null_RefCount_Policy>::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 (); +} + +CORBA::TypeCode_ptr +TAO::TypeCode::Alias<char const *, + CORBA::TypeCode_ptr const *, + TAO::Null_RefCount_Policy>::content_type_i ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const +{ + return + CORBA::TypeCode::_duplicate ( + Traits<char const *>::get_typecode (this->content_type_)); +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/Alias_TypeCode_Static.h b/TAO/tao/AnyTypeCode/Alias_TypeCode_Static.h new file mode 100644 index 00000000000..ce78541df83 --- /dev/null +++ b/TAO/tao/AnyTypeCode/Alias_TypeCode_Static.h @@ -0,0 +1,134 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Alias_TypeCode_Static.h + * + * $Id$ + * + * Header file for a static @c tk_alias and @c tk_value_box + * @c CORBA::TypeCode. + * + * @author Ossama Othman <ossama@dre.vanderbilt.edu> + */ +//============================================================================= + +#ifndef TAO_ALIAS_TYPECODE_STATIC_H +#define TAO_ALIAS_TYPECODE_STATIC_H + +#include /**/ "ace/pre.h" + +#include "tao/AnyTypeCode/TypeCode.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/AnyTypeCode/TypeCode_Base_Attributes.h" +#include "tao/AnyTypeCode/Null_RefCount_Policy.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + namespace TypeCode + { + template <typename StringType, + typename TypeCodeType, + class RefCountPolicy> class Alias; + + /** + * @class Alias + * + * @brief @c CORBA::TypeCode implementation for an OMG IDL + * @c typedef. + * + * This class implements a @c CORBA::TypeCode for an OMG IDL + * @c typedef. + */ + template<> + class TAO_AnyTypeCode_Export Alias<char const *, + CORBA::TypeCode_ptr const *, + TAO::Null_RefCount_Policy> + : public CORBA::TypeCode, + private TAO::Null_RefCount_Policy + { + public: + + /// Constructor. + Alias (CORBA::TCKind kind, + char const * id, + char const * name, + CORBA::TypeCode_ptr const * tc); + + /** + * @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, + CORBA::ULong offset) const; + virtual void tao_duplicate (void); + virtual void tao_release (void); + //@} + + protected: + + /** + * @name @c TAO CORBA::TypeCode Template Methods + * + * @c tk_alias and @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::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::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 @c typedef. + Base_Attributes<char const *> attributes_; + + /// The @c TypeCode corresponding to the original type upon + /// which the IDL @c typedef 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::Alias. + */ + CORBA::TypeCode_ptr const * content_type_; + + }; + + } // End namespace TypeCode +} // End namespace TAO + +TAO_END_VERSIONED_NAMESPACE_DECL + + +#ifdef __ACE_INLINE__ +# include "tao/AnyTypeCode/Alias_TypeCode_Static.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" + +#endif /* TAO_ALIAS_TYPECODE_STATIC_H */ diff --git a/TAO/tao/AnyTypeCode/Alias_TypeCode_Static.inl b/TAO/tao/AnyTypeCode/Alias_TypeCode_Static.inl new file mode 100644 index 00000000000..0f077af6689 --- /dev/null +++ b/TAO/tao/AnyTypeCode/Alias_TypeCode_Static.inl @@ -0,0 +1,22 @@ +// -*- C++ -*- +// +// $Id$ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE +TAO::TypeCode::Alias<char const *, + CORBA::TypeCode_ptr const *, + TAO::Null_RefCount_Policy>::Alias ( + CORBA::TCKind kind, + char const * id, + char const * name, + CORBA::TypeCode_ptr const * tc) + : ::CORBA::TypeCode (kind) + , ::TAO::Null_RefCount_Policy () + , attributes_ (id, name) + , content_type_ (tc) +{ +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/Any.cpp b/TAO/tao/AnyTypeCode/Any.cpp new file mode 100644 index 00000000000..19a025db41e --- /dev/null +++ b/TAO/tao/AnyTypeCode/Any.cpp @@ -0,0 +1,774 @@ +// $Id$ + +#include "tao/AnyTypeCode/Any.h" +#include "tao/AnyTypeCode/Any_Basic_Impl.h" +#include "tao/AnyTypeCode/Any_Impl_T.h" +#include "tao/AnyTypeCode/Any_Special_Impl_T.h" +#include "tao/AnyTypeCode/Any_Dual_Impl_T.h" +#include "tao/AnyTypeCode/Any_Unknown_IDL_Type.h" +#include "tao/AnyTypeCode/TypeCode.h" +#include "tao/AnyTypeCode/TypeCode_Constants.h" +#include "tao/SystemException.h" +#include "tao/CDR.h" + +#include "ace/Log_Msg.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_wchar.h" +#include "ace/OS_Memory.h" + +#if !defined (__ACE_INLINE__) +# include "tao/AnyTypeCode/Any.inl" +#endif /* ! __ACE_INLINE__ */ + +ACE_RCSID (AnyTypeCode, + Any, + "$Id$") + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +using namespace TAO; + +CORBA::Any::Any (void) + : impl_ (0) +{ +} + +CORBA::Any::Any (const CORBA::Any &rhs) + : impl_ (rhs.impl_) +{ + if (this->impl_ != 0) + { + this->impl_->_add_ref (); + } +} + +CORBA::Any::~Any (void) +{ + if (this->impl_ != 0) + { + this->impl_->_remove_ref (); + } +} + +CORBA::Any & +CORBA::Any::operator= (const CORBA::Any &rhs) +{ + if (this->impl_ != rhs.impl_) + { + if (this->impl_ != 0) + { + this->impl_->_remove_ref (); + } + + this->impl_ = rhs.impl_; + + if (this->impl_ != 0) + { + this->impl_->_add_ref (); + } + } + + return *this; +} + +void +CORBA::Any::replace (TAO::Any_Impl *new_impl) +{ + ACE_ASSERT (new_impl != 0); + + if (this->impl_ != 0) + { + this->impl_->_remove_ref (); + } + + this->impl_ = new_impl; +} + +CORBA::TypeCode_ptr +CORBA::Any::type (void) const +{ + if (this->impl_ != 0) + { + return this->impl_->type (); + } + + return CORBA::TypeCode::_duplicate (CORBA::_tc_null); +} + +CORBA::TypeCode_ptr +CORBA::Any::_tao_get_typecode (void) const +{ + if (this->impl_ != 0) + { + return this->impl_->_tao_get_typecode (); + } + + return CORBA::_tc_null; +} + +void +CORBA::Any::_tao_set_typecode (const CORBA::TypeCode_ptr tc) +{ + if (this->impl_ == 0) + { + ACE_NEW (this->impl_, + TAO::Unknown_IDL_Type (tc)); + } + else + { + this->impl_->type (tc); + } +} + +int +CORBA::Any::_tao_byte_order (void) const +{ + if (this->impl_ != 0) + { + return this->impl_->_tao_byte_order (); + } + + return TAO_ENCAP_BYTE_ORDER; +} + +void +CORBA::Any::type (CORBA::TypeCode_ptr tc + ACE_ENV_ARG_DECL) +{ + CORBA::Boolean equiv = false; + + if (this->impl_ != 0) + { + equiv = + this->impl_->_tao_get_typecode ()->equivalent (tc + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } + + if (equiv) + { + this->impl_->type (tc); + } + else + { + ACE_THROW (CORBA::BAD_TYPECODE ()); + } +} + +void +CORBA::Any::_tao_any_destructor (void *x) +{ + CORBA::Any *tmp = static_cast<CORBA::Any *> (x); + delete tmp; +} + +CORBA::Any::to_object::to_object (CORBA::Object_out obj) + : ref_ (obj.ptr ()) +{ +} + +CORBA::Any::to_abstract_base::to_abstract_base (CORBA::AbstractBase_ptr &obj) + : ref_ (obj) +{ +} + +CORBA::Any::to_value::to_value (CORBA::ValueBase *& obj) + : ref_ (obj) +{ +} + +CORBA::Boolean +CORBA::Any::checked_to_object (CORBA::Object_ptr &_tao_elem) const +{ + if (this->impl_ == 0) + { + return 0; + } + + return this->impl_->to_object (_tao_elem); +} + +CORBA::Boolean +CORBA::Any::checked_to_value (CORBA::ValueBase *&_tao_elem) const +{ + if (this->impl_ == 0) + { + return false; + } + + return this->impl_->to_value (_tao_elem); +} + +CORBA::Boolean +CORBA::Any::checked_to_abstract_base ( + CORBA::AbstractBase_ptr &_tao_elem + ) const +{ + if (this->impl_ == 0) + { + return false; + } + + return this->impl_->to_abstract_base (_tao_elem); +} + +// **************************************************************** + +CORBA::Any_var::Any_var (const CORBA::Any_var &r) + : ptr_ (0) +{ + if (r.ptr_ != 0) + { + ACE_NEW (this->ptr_, + CORBA::Any (*r.ptr_)); + } +} + +CORBA::Any_var & +CORBA::Any_var::operator= (CORBA::Any *p) +{ + if (this->ptr_ != p) + { + delete this->ptr_; + this->ptr_ = p; + } + + return *this; +} + +CORBA::Any_var & +CORBA::Any_var::operator= (const CORBA::Any_var &r) +{ + delete this->ptr_; + this->ptr_ = 0; + + if (r.ptr_ != 0) + { + ACE_NEW_RETURN (this->ptr_, + CORBA::Any (*r.ptr_), + *this); + } + + return *this; +} + +// *********************************************************************** + +CORBA::Boolean +operator<< (TAO_OutputCDR &cdr, const CORBA::Any &any) +{ + TAO::Any_Impl *impl = any.impl (); + + if (impl != 0) + { + return impl->marshal (cdr); + } + + return (cdr << CORBA::_tc_null); +} + +CORBA::Boolean +operator>> (TAO_InputCDR &cdr, CORBA::Any &any) +{ + CORBA::TypeCode_var tc; + + if ((cdr >> tc.out ()) == 0) + { + return false; + } + + ACE_TRY_NEW_ENV + { + TAO::Unknown_IDL_Type *impl = 0; + ACE_NEW_RETURN (impl, + TAO::Unknown_IDL_Type (tc.in ()), + false); + + any.replace (impl); + impl->_tao_decode (cdr + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCH (CORBA::Exception, ex) + { + return false; + } + ACE_ENDTRY; + + return true; +} + +// ======================================================================= + +// Insertion of the special basic types. + +void +CORBA::Any::operator<<= (CORBA::Any::from_boolean b) +{ + TAO::Any_Basic_Impl::insert (*this, + CORBA::_tc_boolean, + &b.val_); +} + +void +CORBA::Any::operator<<= (CORBA::Any::from_octet o) +{ + TAO::Any_Basic_Impl::insert (*this, + CORBA::_tc_octet, + &o.val_); +} + +void +CORBA::Any::operator<<= (CORBA::Any::from_char c) +{ + TAO::Any_Basic_Impl::insert (*this, + CORBA::_tc_char, + &c.val_); +} + +void +CORBA::Any::operator<<= (CORBA::Any::from_wchar wc) +{ + TAO::Any_Basic_Impl::insert (*this, + CORBA::_tc_wchar, + &wc.val_); +} + +void +CORBA::Any::operator<<= (CORBA::Any::from_string s) +{ + if (s.bound_ > 0 && s.val_ != 0 && ACE_OS::strlen (s.val_) > s.bound_) + { + return; + } + + TAO::Any_Special_Impl_T< + char, + CORBA::Any::from_string, + CORBA::Any::to_string + >::insert (*this, + TAO::Any_Impl::_tao_any_string_destructor, + CORBA::_tc_string, + s.nocopy_ ? s.val_ : CORBA::string_dup (s.val_), + s.bound_); +} + +void +CORBA::Any::operator<<= (CORBA::Any::from_wstring ws) +{ + if (ws.bound_ > 0 && ws.val_ != 0 && ACE_OS::wslen (ws.val_) > ws.bound_) + { + return; + } + + TAO::Any_Special_Impl_T< + CORBA::WChar, + CORBA::Any::from_wstring, + CORBA::Any::to_wstring + >::insert (*this, + TAO::Any_Impl::_tao_any_wstring_destructor, + CORBA::_tc_wstring, + ws.nocopy_ ? ws.val_ : CORBA::wstring_dup (ws.val_), + ws.bound_); +} + +// Insertion of the other basic types. + +void +operator<<= (CORBA::Any &any, CORBA::Short s) +{ + TAO::Any_Basic_Impl::insert (any, + CORBA::_tc_short, + &s); +} + +void +operator<<= (CORBA::Any &any, CORBA::UShort us) +{ + TAO::Any_Basic_Impl::insert (any, + CORBA::_tc_ushort, + &us); +} + +void +operator<<= (CORBA::Any &any, CORBA::Long l) +{ + TAO::Any_Basic_Impl::insert (any, + CORBA::_tc_long, + &l); +} + +void +operator<<= (CORBA::Any &any, CORBA::ULong ul) +{ + TAO::Any_Basic_Impl::insert (any, + CORBA::_tc_ulong, + &ul); +} + +void +operator<<= (CORBA::Any &any, CORBA::LongLong ll) +{ + TAO::Any_Basic_Impl::insert (any, + CORBA::_tc_longlong, + &ll); +} + +void +operator<<= (CORBA::Any &any, CORBA::ULongLong ull) +{ + TAO::Any_Basic_Impl::insert (any, + CORBA::_tc_ulonglong, + &ull); +} + +void +operator<<= (CORBA::Any &any, CORBA::Float f) +{ + TAO::Any_Basic_Impl::insert (any, + CORBA::_tc_float, + &f); +} + +void +operator<<= (CORBA::Any &any, CORBA::Double d) +{ + TAO::Any_Basic_Impl::insert (any, + CORBA::_tc_double, + &d); +} + +void +operator<<= (CORBA::Any &any, CORBA::LongDouble ld) +{ + TAO::Any_Basic_Impl::insert (any, + CORBA::_tc_longdouble, + &ld); +} + +// Insertion of Any - copying. +void +operator<<= (CORBA::Any &any, const CORBA::Any &a) +{ + if (0 == &a) // Trying to de-reference NULL Any + any <<= static_cast<CORBA::Any *>( 0 ); // Use non-copying insertion of a NULL + else + TAO::Any_Dual_Impl_T<CORBA::Any>::insert_copy ( + any, + CORBA::Any::_tao_any_destructor, + CORBA::_tc_any, + a + ); +} + +// Insertion of Any - non-copying. +void +operator<<= (CORBA::Any &any, CORBA::Any *a) +{ + TAO::Any_Dual_Impl_T<CORBA::Any>::insert (any, + CORBA::Any::_tao_any_destructor, + CORBA::_tc_any, + a); +} + +// Insertion of TypeCode - copying. +void +operator<<= (CORBA::Any &any, CORBA::TypeCode_ptr tc) +{ + CORBA::TypeCode_ptr dup = CORBA::TypeCode::_duplicate (tc); + any <<= &dup; +} + +// Insertion of TypeCode - non-copying. +void +operator<<= (CORBA::Any &any, CORBA::TypeCode_ptr * tc) +{ + TAO::Any_Impl_T<CORBA::TypeCode>::insert ( + any, + CORBA::TypeCode::_tao_any_destructor, + CORBA::_tc_TypeCode, + *tc + ); +} + +// Insertion of CORBA object - copying. +void +operator<<= (CORBA::Any &any, const CORBA::Object_ptr obj) +{ + CORBA::Object_ptr dup = CORBA::Object::_duplicate (obj); + any <<= &dup; +} + +// Insertion of CORBA object - non-copying. +void +operator<<= (CORBA::Any &any, CORBA::Object_ptr *objptr) +{ + TAO::Any_Impl_T<CORBA::Object>::insert (any, + CORBA::Object::_tao_any_destructor, + CORBA::_tc_Object, + *objptr); +} + +// These are copying versions for unbounded (w)strings. They are not inlined, +// to avoid use in Any.i before definition in ORB.i. + +void +operator<<= (CORBA::Any &any, const char *s) +{ + TAO::Any_Special_Impl_T< + char, + CORBA::Any::from_string, + CORBA::Any::to_string + >::insert (any, + TAO::Any_Impl::_tao_any_string_destructor, + CORBA::_tc_string, + CORBA::string_dup (s), + 0); +} + +void +operator<<= (CORBA::Any &any, const CORBA::WChar *ws) +{ + TAO::Any_Special_Impl_T< + CORBA::WChar, + CORBA::Any::from_wstring, + CORBA::Any::to_wstring + >::insert (any, + TAO::Any_Impl::_tao_any_wstring_destructor, + CORBA::_tc_wstring, + CORBA::wstring_dup (ws), + 0); +} + +// Extraction: these are safe and hence we have to check that the +// typecode of the Any is equal to the one we are trying to extract +// into. + +// Extraction into the special basic types. + +CORBA::Boolean +CORBA::Any::operator>>= (CORBA::Any::to_boolean b) const +{ + return TAO::Any_Basic_Impl::extract (*this, + CORBA::_tc_boolean, + &b.ref_); +} + +CORBA::Boolean +CORBA::Any::operator>>= (CORBA::Any::to_octet o) const +{ + return TAO::Any_Basic_Impl::extract (*this, + CORBA::_tc_octet, + &o.ref_); +} + +CORBA::Boolean +CORBA::Any::operator>>= (CORBA::Any::to_char c) const +{ + return TAO::Any_Basic_Impl::extract (*this, + CORBA::_tc_char, + &c.ref_); +} + +CORBA::Boolean +CORBA::Any::operator>>= (CORBA::Any::to_wchar wc) const +{ + return TAO::Any_Basic_Impl::extract (*this, + CORBA::_tc_wchar, + &wc.ref_); +} + +CORBA::Boolean +CORBA::Any::operator>>= (CORBA::Any::to_string s) const +{ + return + TAO::Any_Special_Impl_T< + char, + CORBA::Any::from_string, + CORBA::Any::to_string + >::extract (*this, + TAO::Any_Impl::_tao_any_string_destructor, + CORBA::_tc_string, + s.val_, + s.bound_); +} + +CORBA::Boolean +CORBA::Any::operator>>= (CORBA::Any::to_wstring ws) const +{ + return + TAO::Any_Special_Impl_T< + CORBA::WChar, + CORBA::Any::from_wstring, + CORBA::Any::to_wstring + >::extract (*this, + TAO::Any_Impl::_tao_any_wstring_destructor, + CORBA::_tc_wstring, + ws.val_, + ws.bound_); +} + +CORBA::Boolean +CORBA::Any::operator>>= (CORBA::Any::to_object obj) const +{ + return this->checked_to_object (obj.ref_); +} + +CORBA::Boolean +CORBA::Any::operator>>= (CORBA::Any::to_abstract_base obj) const +{ + return this->checked_to_abstract_base (obj.ref_); +} + +CORBA::Boolean +CORBA::Any::operator>>= (CORBA::Any::to_value obj) const +{ + return this->checked_to_value (obj.ref_); +} + +// Extraction into the other basic types. + +CORBA::Boolean +operator>>= (const CORBA::Any &any, CORBA::Short &s) +{ + return TAO::Any_Basic_Impl::extract (any, + CORBA::_tc_short, + &s); +} + +CORBA::Boolean +operator>>= (const CORBA::Any &any, CORBA::UShort &us) +{ + return TAO::Any_Basic_Impl::extract (any, + CORBA::_tc_ushort, + &us); +} + +CORBA::Boolean +operator>>= (const CORBA::Any &any, CORBA::Long &l) +{ + return TAO::Any_Basic_Impl::extract (any, + CORBA::_tc_long, + &l); +} + +CORBA::Boolean +operator>>= (const CORBA::Any &any, CORBA::ULong &ul) +{ + return TAO::Any_Basic_Impl::extract (any, + CORBA::_tc_ulong, + &ul); +} + +CORBA::Boolean +operator>>= (const CORBA::Any &any, CORBA::LongLong &ll) +{ + return + TAO::Any_Basic_Impl::extract (any, + CORBA::_tc_longlong, + &ll); +} + +CORBA::Boolean +operator>>= (const CORBA::Any &any, CORBA::ULongLong &ull) +{ + return + TAO::Any_Basic_Impl::extract (any, + CORBA::_tc_ulonglong, + &ull); +} + +CORBA::Boolean +operator>>= (const CORBA::Any &any, CORBA::Float &f) +{ + return TAO::Any_Basic_Impl::extract (any, + CORBA::_tc_float, + &f); +} + +CORBA::Boolean +operator>>= (const CORBA::Any &any, CORBA::Double &d) +{ + return TAO::Any_Basic_Impl::extract (any, + CORBA::_tc_double, + &d); +} + +CORBA::Boolean +operator>>= (const CORBA::Any &any, CORBA::LongDouble &ld) +{ + return + TAO::Any_Basic_Impl::extract (any, + CORBA::_tc_longdouble, + &ld); +} + +CORBA::Boolean +operator>>= (const CORBA::Any &any, const CORBA::Any *&a) +{ + return TAO::Any_Dual_Impl_T<CORBA::Any>::extract ( + any, + CORBA::Any::_tao_any_destructor, + CORBA::_tc_any, + a + ); +} + +CORBA::Boolean +operator>>= (const CORBA::Any &any, const CORBA::Char *&s) +{ + return + TAO::Any_Special_Impl_T< + char, + CORBA::Any::from_string, + CORBA::Any::to_string + >::extract (any, + TAO::Any_Impl::_tao_any_string_destructor, + CORBA::_tc_string, + s, + 0); +} + +CORBA::Boolean +operator>>= (const CORBA::Any &any, const CORBA::WChar *&ws) +{ + return + TAO::Any_Special_Impl_T< + CORBA::WChar, + CORBA::Any::from_wstring, + CORBA::Any::to_wstring + >::extract (any, + TAO::Any_Impl::_tao_any_wstring_destructor, + CORBA::_tc_wstring, + ws, + 0); +} + +CORBA::Boolean +operator>>= (const CORBA::Any &any, CORBA::TypeCode_ptr &tc) +{ + return TAO::Any_Impl_T<CORBA::TypeCode>::extract ( + any, + CORBA::TypeCode::_tao_any_destructor, + CORBA::_tc_TypeCode, + tc + ); +} + +// ================================================================ +// Any_Impl_T template specializations. + +namespace TAO +{ + template<> + CORBA::Boolean + Any_Impl_T<CORBA::Object>::to_object ( + CORBA::Object_ptr &_tao_elem + ) const + { + _tao_elem = CORBA::Object::_duplicate (this->value_); + return true; + } +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/Any.h b/TAO/tao/AnyTypeCode/Any.h new file mode 100644 index 00000000000..b158adc7feb --- /dev/null +++ b/TAO/tao/AnyTypeCode/Any.h @@ -0,0 +1,404 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Any.h + * + * $Id$ + * + * @author Carlos O'Ryan + * @author Jeff Parsons + */ +//============================================================================= + +#ifndef TAO_ANY_H +#define TAO_ANY_H + +#include /**/ "ace/pre.h" + +#include "tao/AnyTypeCode/TAO_AnyTypeCode_Export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/AnyTypeCode/AnyTypeCode_methods.h" +#include "tao/Pseudo_VarOut_T.h" +#include "tao/Arg_Traits_T.h" +#include "tao/Object.h" + +#include "ace/CDR_Stream.h" +#include "ace/CORBA_macros.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + class Any_Impl; +} + +namespace CORBA +{ + class Any; + typedef Any *Any_ptr; + class Any_var; + class Any_out; + + class TypeCode; + typedef TypeCode *TypeCode_ptr; + + class AbstractBase; + typedef AbstractBase *AbstractBase_ptr; + + class ValueBase; + class Exception; + class Environment; + + /** + * @class Any + * + * @brief Generic container for IDL types. + * + * This is the top-level class of the Any implementation. It exposes the + * spec-required functionality, but is mostly a wrapper for one of the + * template classes below. + */ + class TAO_AnyTypeCode_Export Any + { + public: + typedef Any_ptr _ptr_type; + typedef Any_var _var_type; + typedef Any_out _out_type; + + Any (void); + Any (const Any &); + + ~Any (void); + + Any &operator= (const Any &); + TAO::Any_Impl *impl (void) const; + + /// Used in our destruction if we ourselves are stored in an Any. + static void _tao_any_destructor (void *); + + /// These are needed for insertion and extraction of booleans, + /// octets, chars, and bounded strings. CORBA spec requires + /// that they be here, we just typedef to the already-defined + /// ACE_OutputCDR types. + + typedef ACE_OutputCDR::from_boolean from_boolean; + typedef ACE_OutputCDR::from_octet from_octet; + typedef ACE_OutputCDR::from_char from_char; + typedef ACE_OutputCDR::from_wchar from_wchar; + typedef ACE_OutputCDR::from_string from_string; + typedef ACE_OutputCDR::from_wstring from_wstring; + + /// Insertion of the special types. + + void operator<<= (from_boolean); + void operator<<= (from_char); + void operator<<= (from_wchar); + void operator<<= (from_octet); + void operator<<= (from_string); + void operator<<= (from_wstring); + + /// These extract octets, chars, booleans, bounded strings, and + /// object references. All these are defined in ACE_InputCDR. + + typedef ACE_InputCDR::to_boolean to_boolean; + typedef ACE_InputCDR::to_char to_char; + typedef ACE_InputCDR::to_wchar to_wchar; + typedef ACE_InputCDR::to_octet to_octet; + typedef ACE_InputCDR::to_string to_string; + typedef ACE_InputCDR::to_wstring to_wstring; + + /// These are not in ACE. + + struct TAO_AnyTypeCode_Export to_object + { + // This signature reflects the change set out in + // issue 154 of the 1.3 RTF. + explicit to_object (Object_out obj); + Object_ptr &ref_; + }; + + struct TAO_AnyTypeCode_Export to_abstract_base + { + explicit to_abstract_base (AbstractBase_ptr &obj); + AbstractBase_ptr &ref_; + }; + + struct TAO_AnyTypeCode_Export to_value + { + explicit to_value (ValueBase *&base); + ValueBase *&ref_; + }; + + /// Extraction of the special types. + + Boolean operator>>= (to_boolean) const; + Boolean operator>>= (to_octet) const; + Boolean operator>>= (to_char) const; + Boolean operator>>= (to_wchar) const; + Boolean operator>>= (to_string) const; + Boolean operator>>= (to_wstring) const; + Boolean operator>>= (to_object) const; + Boolean operator>>= (to_abstract_base) const; + Boolean operator>>= (to_value) const; + + /// TAO-specific signature. + void replace (TAO::Any_Impl *); + + /// Return TypeCode of the element stored in the Any. + TypeCode_ptr type (void) const; + + /// For use along with <<= of a value of aliased type when the alias must + /// be preserved. + void type (TypeCode_ptr + ACE_ENV_ARG_DECL); + + /// TAO extension, does not return a duplicate. + CORBA::TypeCode_ptr _tao_get_typecode (void) const; + + /// TAO extension. + void _tao_set_typecode (const CORBA::TypeCode_ptr); + + int _tao_byte_order (void) const; + + private: + CORBA::Boolean checked_to_object (CORBA::Object_ptr &) const; + CORBA::Boolean checked_to_value (CORBA::ValueBase *&) const; + CORBA::Boolean checked_to_abstract_base (CORBA::AbstractBase_ptr &) const; + + // Unimplemented - hides unsigned char insert/extract. + void operator<<= (unsigned char); + CORBA::Boolean operator>>= (unsigned char&) const; + + private: + TAO::Any_Impl *impl_; + + friend class TAO_Marshal_Any; + }; + + /** + * @class CORBA::Any_var + * + * @brief Provide for automatic storage deallocation on going out of + * scope. + */ + class TAO_AnyTypeCode_Export Any_var + { + public: + Any_var (void); + Any_var (Any *a); + Any_var (const Any_var &); + ~Any_var (void); + + Any_var &operator= (Any *); + + /** + * Assignment from an Any_var + * This operation requires memory allocation. + * If the allocation fails, *this is returned + * unmodified. + */ + Any_var &operator= (const Any_var &); + + /// Arrow operator (smart pointer). + Any *operator-> (void); + + /// Cast. + operator const Any *() const; + + /// Cast. + operator Any *&(); + + /// For in Any parameter. + const Any &in (void) const; + + /// For inout Any parameter. + Any &inout (void); + + /// For out Any parameter. + Any *&out (void); + + /// For Any return type. + Any *_retn (void); + + /// TAO specific extension + Any *ptr (void) const; + private: + /// Holds the Any. + Any *ptr_; + }; + + /** + * @class CORBA::Any_out + * + * @brief CORBA::Any_out + * + * The _out class for CORBA::Any. This is used to help in + * managing the out parameters. + */ + class TAO_AnyTypeCode_Export Any_out + { + public: + Any_out (Any *&); + Any_out (Any_var &); + Any_out (const Any_out &); + + /// Assignment from a Any_out. + Any_out &operator= (const Any_out &s); + + /// Assignment from a Any. + Any_out &operator= (Any *); + + /// Cast. + operator Any *&(); + + /// Return underlying instance. + Any *& ptr (void); + + Any *operator-> (void); + + private: + /// Assignment from _var disallowed. + void operator= (const Any_var &); + + private: + /// Instance. + Any *&ptr_; + }; +} + +TAO_AnyTypeCode_Export CORBA::Boolean operator<< (TAO_OutputCDR &, const CORBA::Any &); +TAO_AnyTypeCode_Export CORBA::Boolean operator>> (TAO_InputCDR &, CORBA::Any &); + +/// Typesafe insertion. + +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, CORBA::Short); +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, CORBA::UShort); +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, CORBA::Long); +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, CORBA::ULong); +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, CORBA::LongLong); +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, CORBA::ULongLong); +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, CORBA::Float); +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, CORBA::Double); +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, CORBA::LongDouble); +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, const CORBA::Any &); +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, CORBA::Any *); +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, const char *); +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, const CORBA::WChar *); +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, CORBA::TypeCode_ptr); +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, CORBA::TypeCode_ptr *); +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, const CORBA::Object_ptr); +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, CORBA::Object_ptr *); + +/// Typesafe extraction. + +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any &, + CORBA::Short &); +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any &, + CORBA::UShort &); +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any &, + CORBA::Long &); +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any &, + CORBA::ULong &); +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any &, + CORBA::LongLong &); +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any &, + CORBA::ULongLong &); +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any &, + CORBA::Float &); +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any &, + CORBA::Double &); +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any &, + CORBA::LongDouble &); +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any &, + const CORBA::Any *&); +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any &, + CORBA::TypeCode_ptr &); +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any &, + const CORBA::Char *&); +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any &, + const CORBA::WChar *&); + +TAO_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +# include "tao/AnyTypeCode/Any.inl" +#else + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +/// Copying versions of insertion operators for basic types +/// must also be defined for CORBA::Any_var. + +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any_var &, CORBA::Short); +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any_var &, CORBA::UShort); +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any_var &, CORBA::Long); +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any_var &, CORBA::ULong); +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any_var &, CORBA::LongLong); +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any_var &, CORBA::ULongLong); +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any_var &, CORBA::Float); +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any_var &, CORBA::Double); +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any_var &, const CORBA::Any *&); +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any_var &, const char *); +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any_var &, CORBA::TypeCode_ptr); +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any_var &, const CORBA::Object_ptr); +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any_var &, ACE_OutputCDR::from_boolean); +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any_var &, CORBA::Any::from_char); +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any_var &, CORBA::Any::from_wchar); +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any_var &, CORBA::Any::from_octet); +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any_var &, CORBA::Any::from_string); +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any_var &, CORBA::Any::from_wstring); + +/// These are not required by the spec, but will make users +/// of other ORBs that are used to them more comfortable. + +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any_var &, + CORBA::Short &); +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any_var &, + CORBA::UShort &); +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any_var &, + CORBA::Long &); +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any_var &, + CORBA::ULong &); +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any_var &, + CORBA::LongLong &); +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any_var &, + CORBA::ULongLong &); +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any_var &, + CORBA::Float &); +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any_var &, + CORBA::Double &); +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any_var &, + CORBA::Any &); +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any_var &, + CORBA::TypeCode_ptr &); +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any_var &, + const char *&); +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any_var &, + const CORBA::WChar *&); +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any_var &, + CORBA::Any::to_boolean); +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any_var &, + CORBA::Any::to_octet); +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any_var &, + CORBA::Any::to_char); +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any_var &, + CORBA::Any::to_wchar); +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any_var &, + CORBA::Any::to_string); +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any_var &, + CORBA::Any::to_wstring); +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any_var &, + CORBA::Any::to_object); + +TAO_END_VERSIONED_NAMESPACE_DECL + +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" + +#endif /* TAO_ANY_H */ diff --git a/TAO/tao/AnyTypeCode/Any.inl b/TAO/tao/AnyTypeCode/Any.inl new file mode 100644 index 00000000000..761f4d13175 --- /dev/null +++ b/TAO/tao/AnyTypeCode/Any.inl @@ -0,0 +1,372 @@ +// -*- C++ -*- +// +// $Id$ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE TAO::Any_Impl * +CORBA::Any::impl (void) const +{ + return this->impl_; +} + +// ************************************************************* +// Inline operations for class CORBA::Any_var +// ************************************************************* + +ACE_INLINE +CORBA::Any_var::Any_var (void) + : ptr_ (0) +{ +} + +ACE_INLINE +CORBA::Any_var::Any_var (CORBA::Any *p) + : ptr_ (p) +{ +} + +ACE_INLINE +CORBA::Any_var::~Any_var (void) +{ + delete this->ptr_; +} + +ACE_INLINE +CORBA::Any_var::operator CORBA::Any *&() +{ + return this->ptr_; +} + +ACE_INLINE +CORBA::Any_var::operator const CORBA::Any *() const +{ + return this->ptr_; +} + +ACE_INLINE CORBA::Any * +CORBA::Any_var::operator-> (void) +{ + return this->ptr_; +} + +ACE_INLINE const CORBA::Any & +CORBA::Any_var::in (void) const +{ + return *this->ptr_; +} + +ACE_INLINE CORBA::Any & +CORBA::Any_var::inout (void) +{ + return *this->ptr_; +} + +ACE_INLINE CORBA::Any *& +CORBA::Any_var::out (void) +{ + delete this->ptr_; + this->ptr_ = 0; + return this->ptr_; +} + +ACE_INLINE CORBA::Any * +CORBA::Any_var::_retn (void) +{ + CORBA::Any *temp = this->ptr_; + this->ptr_ = 0; + return temp; +} + +ACE_INLINE CORBA::Any * +CORBA::Any_var::ptr (void) const +{ + return this->ptr_; +} + +// ************************************************************* +// CORBA::Any_var insertion operators +// ************************************************************* + +ACE_INLINE void +operator <<= (CORBA::Any_var &lhs, CORBA::Short rhs) +{ + lhs.inout () <<= rhs; +} + +ACE_INLINE void +operator <<= (CORBA::Any_var &lhs, CORBA::UShort rhs) +{ + lhs.inout () <<= rhs; +} + +ACE_INLINE void +operator <<= (CORBA::Any_var &lhs, CORBA::Long rhs) +{ + lhs.inout () <<= rhs; +} + +ACE_INLINE void +operator <<= (CORBA::Any_var &lhs, CORBA::ULong rhs) +{ + lhs.inout () <<= rhs; +} + +ACE_INLINE void +operator <<= (CORBA::Any_var &lhs, CORBA::LongLong rhs) +{ + lhs.inout () <<= rhs; +} + +ACE_INLINE void +operator <<= (CORBA::Any_var &lhs, CORBA::ULongLong rhs) +{ + lhs.inout () <<= rhs; +} + +ACE_INLINE void +operator <<= (CORBA::Any_var &lhs, CORBA::Float rhs) +{ + lhs.inout () <<= rhs; +} + +ACE_INLINE void +operator <<= (CORBA::Any_var &lhs, CORBA::Double rhs) +{ + lhs.inout () <<= rhs; +} + +ACE_INLINE void +operator <<= (CORBA::Any_var &lhs, const CORBA::Any& rhs) +{ + lhs.inout () <<= rhs; +} + +ACE_INLINE void +operator <<= (CORBA::Any_var &lhs, const char* rhs) +{ + lhs.inout () <<= rhs; +} + +ACE_INLINE void +operator <<= (CORBA::Any_var &lhs, CORBA::TypeCode_ptr rhs) +{ + lhs.inout () <<= rhs; +} + +ACE_INLINE void +operator <<= (CORBA::Any_var &lhs, const CORBA::Object_ptr rhs) +{ + lhs.inout () <<= rhs; +} + +ACE_INLINE void +operator <<= (CORBA::Any_var &lhs, ACE_OutputCDR::from_boolean rhs) +{ + lhs.inout () <<= rhs; +} + +ACE_INLINE void +operator <<= (CORBA::Any_var &lhs, CORBA::Any::from_char rhs) +{ + lhs.inout () <<= rhs; +} + +ACE_INLINE void +operator <<= (CORBA::Any_var &lhs, CORBA::Any::from_wchar rhs) +{ + lhs.inout () <<= rhs; +} + +ACE_INLINE void +operator <<= (CORBA::Any_var &lhs, CORBA::Any::from_octet rhs) +{ + lhs.inout () <<= rhs; +} + +ACE_INLINE void +operator <<= (CORBA::Any_var &lhs, CORBA::Any::from_string rhs) +{ + lhs.inout () <<= rhs; +} + +ACE_INLINE void +operator <<= (CORBA::Any_var &lhs, CORBA::Any::from_wstring rhs) +{ + lhs.inout () <<= rhs; +} + +// ************************************************************* +// CORBA::Any_var extraction operators +// ************************************************************* + +ACE_INLINE CORBA::Boolean +operator >>= (const CORBA::Any_var &lhs, CORBA::Short &rhs) +{ + return lhs.in () >>= rhs; +} + +ACE_INLINE CORBA::Boolean +operator >>= (const CORBA::Any_var &lhs, CORBA::UShort &rhs) +{ + return lhs.in () >>= rhs; +} + +ACE_INLINE CORBA::Boolean +operator >>= (const CORBA::Any_var &lhs, CORBA::Long &rhs) +{ + return lhs.in () >>= rhs; +} + +ACE_INLINE CORBA::Boolean +operator >>= (const CORBA::Any_var &lhs, CORBA::ULong &rhs) +{ + return lhs.in () >>= rhs; +} + +ACE_INLINE CORBA::Boolean +operator >>= (const CORBA::Any_var &lhs, CORBA::LongLong &rhs) +{ + return lhs.in () >>= rhs; +} + +ACE_INLINE CORBA::Boolean +operator >>= (const CORBA::Any_var &lhs, CORBA::ULongLong &rhs) +{ + return lhs.in () >>= rhs; +} + +ACE_INLINE CORBA::Boolean +operator >>= (const CORBA::Any_var &lhs, CORBA::Float &rhs) +{ + return lhs.in () >>= rhs; +} + +ACE_INLINE CORBA::Boolean +operator >>= (const CORBA::Any_var &lhs, CORBA::Double &rhs) +{ + return lhs.in () >>= rhs; +} + +ACE_INLINE CORBA::Boolean +operator >>= (const CORBA::Any_var &lhs, const CORBA::Any *&rhs) +{ + return lhs.in () >>= rhs; +} + +ACE_INLINE CORBA::Boolean +operator >>= (const CORBA::Any_var &lhs, CORBA::TypeCode_ptr &rhs) +{ + return lhs.in () >>= rhs; +} + +ACE_INLINE CORBA::Boolean +operator >>= (const CORBA::Any_var &lhs, const char *&rhs) +{ + return lhs.in () >>= rhs; +} + +ACE_INLINE CORBA::Boolean +operator >>= (const CORBA::Any_var &lhs, const CORBA::WChar *&rhs) +{ + return lhs.in () >>= rhs; +} + +ACE_INLINE CORBA::Boolean +operator >>= (const CORBA::Any_var &lhs, CORBA::Any::to_boolean rhs) +{ + return lhs.in () >>= rhs; +} + +ACE_INLINE CORBA::Boolean +operator >>= (const CORBA::Any_var &lhs, CORBA::Any::to_octet rhs) +{ + return lhs.in () >>= rhs; +} + +ACE_INLINE CORBA::Boolean +operator >>= (const CORBA::Any_var &lhs, CORBA::Any::to_char rhs) +{ + return lhs.in () >>= rhs; +} + +ACE_INLINE CORBA::Boolean +operator >>= (const CORBA::Any_var &lhs, CORBA::Any::to_wchar rhs) +{ + return lhs.in () >>= rhs; +} + +ACE_INLINE CORBA::Boolean +operator >>= (const CORBA::Any_var &lhs, CORBA::Any::to_string rhs) +{ + return lhs.in () >>= rhs; +} + +ACE_INLINE CORBA::Boolean +operator >>= (const CORBA::Any_var &lhs, CORBA::Any::to_wstring rhs) +{ + return lhs.in () >>= rhs; +} + +ACE_INLINE CORBA::Boolean +operator >>= (const CORBA::Any_var &lhs, CORBA::Any::to_object rhs) +{ + return lhs.in () >>= rhs; +} + +// ************************************************************* +// Inline operations for class CORBA::Any_out +// ************************************************************* + +ACE_INLINE +CORBA::Any_out::Any_out (CORBA::Any *&s) + : ptr_ (s) +{ + this->ptr_ = 0; +} + +ACE_INLINE +CORBA::Any_out::Any_out (CORBA::Any_var &s) + : ptr_ (s.out ()) +{ +} + +ACE_INLINE +CORBA::Any_out::Any_out (const CORBA::Any_out &s) + : ptr_ (s.ptr_) +{ +} + +ACE_INLINE CORBA::Any_out & +CORBA::Any_out::operator= (const CORBA::Any_out &s) +{ + this->ptr_ = s.ptr_; + return *this; +} + +ACE_INLINE CORBA::Any_out & +CORBA::Any_out::operator= (CORBA::Any *s) +{ + this->ptr_ = s; + return *this; +} + +ACE_INLINE +CORBA::Any_out::operator CORBA::Any *&() +{ + return this->ptr_; +} + +ACE_INLINE CORBA::Any *& +CORBA::Any_out::ptr (void) +{ + return this->ptr_; +} + +ACE_INLINE CORBA::Any * +CORBA::Any_out::operator-> (void) +{ + return this->ptr_; +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/AnySeq.pidl b/TAO/tao/AnyTypeCode/AnySeq.pidl new file mode 100644 index 00000000000..18cf94274d6 --- /dev/null +++ b/TAO/tao/AnyTypeCode/AnySeq.pidl @@ -0,0 +1,33 @@ +// -*- IDL -*- +// +// $Id$ + +// ================================================================ +/** + * This file was used to generate the code in AnySeq*.* + * The command used to generate code is: + * + * tao_idl + * -o orig -Ge 1 -GA -SS -Sci + * -Wb,export_macro=TAO_Export + * -Wb,export_include="tao/TAO_Export.h" + * -Wb,pre_include="ace/pre.h" + * -Wb,post_include="ace/post.h" + * -Wb,versioning_begin=TAO_BEGIN_VERSIONED_NAMESPACE_DECL + * -Wb,versioning_end=TAO_END_VERSIONED_NAMESPACE_DECL + * AnySeq.pidl + * + */ +// ================================================================ + +#ifndef TAO_CORBA_ANY_SEQ_IDL +#define TAO_CORBA_ANY_SEQ_IDL + +#pragma prefix "omg.org" + +module CORBA +{ + typedef sequence<any> AnySeq; +}; + +#endif /* TAO_CORBA_ANY_SEQ_IDL */ diff --git a/TAO/tao/AnyTypeCode/AnyTypeCode_Adapter_Impl.cpp b/TAO/tao/AnyTypeCode/AnyTypeCode_Adapter_Impl.cpp new file mode 100644 index 00000000000..86a170d7639 --- /dev/null +++ b/TAO/tao/AnyTypeCode/AnyTypeCode_Adapter_Impl.cpp @@ -0,0 +1,192 @@ +// $Id$ + +#include "tao/AnyTypeCode/AnyTypeCode_Adapter_Impl.h" +#include "tao/AnyTypeCode/SystemExceptionA.h" +#include "tao/AnyTypeCode/WrongTransactionA.h" +#include "tao/AnyTypeCode/PolicyA.h" +#include "tao/AnyTypeCode/Any.h" + +ACE_RCSID (AnyTypeCode, + TAO_AnyTypeCode_Adapter, + "$Id$") + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +#define STANDARD_EXCEPTION_LIST \ + TAO_SYSTEM_EXCEPTION (UNKNOWN) \ + TAO_SYSTEM_EXCEPTION (BAD_PARAM) \ + TAO_SYSTEM_EXCEPTION (NO_MEMORY) \ + TAO_SYSTEM_EXCEPTION (IMP_LIMIT) \ + TAO_SYSTEM_EXCEPTION (COMM_FAILURE) \ + TAO_SYSTEM_EXCEPTION (INV_OBJREF) \ + TAO_SYSTEM_EXCEPTION (OBJECT_NOT_EXIST) \ + TAO_SYSTEM_EXCEPTION (NO_PERMISSION) \ + TAO_SYSTEM_EXCEPTION (INTERNAL) \ + TAO_SYSTEM_EXCEPTION (MARSHAL) \ + TAO_SYSTEM_EXCEPTION (INITIALIZE) \ + TAO_SYSTEM_EXCEPTION (NO_IMPLEMENT) \ + TAO_SYSTEM_EXCEPTION (BAD_TYPECODE) \ + TAO_SYSTEM_EXCEPTION (BAD_OPERATION) \ + TAO_SYSTEM_EXCEPTION (NO_RESOURCES) \ + TAO_SYSTEM_EXCEPTION (NO_RESPONSE) \ + TAO_SYSTEM_EXCEPTION (PERSIST_STORE) \ + TAO_SYSTEM_EXCEPTION (BAD_INV_ORDER) \ + TAO_SYSTEM_EXCEPTION (TRANSIENT) \ + TAO_SYSTEM_EXCEPTION (FREE_MEM) \ + TAO_SYSTEM_EXCEPTION (INV_IDENT) \ + TAO_SYSTEM_EXCEPTION (INV_FLAG) \ + TAO_SYSTEM_EXCEPTION (INTF_REPOS) \ + TAO_SYSTEM_EXCEPTION (BAD_CONTEXT) \ + TAO_SYSTEM_EXCEPTION (OBJ_ADAPTER) \ + TAO_SYSTEM_EXCEPTION (DATA_CONVERSION) \ + TAO_SYSTEM_EXCEPTION (INV_POLICY) \ + TAO_SYSTEM_EXCEPTION (REBIND) \ + TAO_SYSTEM_EXCEPTION (TIMEOUT) \ + TAO_SYSTEM_EXCEPTION (TRANSACTION_UNAVAILABLE) \ + TAO_SYSTEM_EXCEPTION (TRANSACTION_MODE) \ + TAO_SYSTEM_EXCEPTION (TRANSACTION_REQUIRED) \ + TAO_SYSTEM_EXCEPTION (TRANSACTION_ROLLEDBACK) \ + TAO_SYSTEM_EXCEPTION (INVALID_TRANSACTION) \ + TAO_SYSTEM_EXCEPTION (CODESET_INCOMPATIBLE) \ + TAO_SYSTEM_EXCEPTION (BAD_QOS) \ + TAO_SYSTEM_EXCEPTION (INVALID_ACTIVITY) \ + TAO_SYSTEM_EXCEPTION (ACTIVITY_COMPLETED) \ + TAO_SYSTEM_EXCEPTION (ACTIVITY_REQUIRED) \ + TAO_SYSTEM_EXCEPTION (THREAD_CANCELLED) \ + TAO_SYSTEM_EXCEPTION (WrongTransaction) \ + TAO_SYSTEM_EXCEPTION (PolicyError) \ + TAO_SYSTEM_EXCEPTION (InvalidPolicies) + +#define TAO_SYSTEM_EXCEPTION(name) \ +CORBA::TypeCode_ptr \ +TAO_AnyTypeCode_Adapter_Impl::_tao_type_ ## name (void) const \ +{ \ + return CORBA::_tc_ ## name; \ +} + +STANDARD_EXCEPTION_LIST +#undef TAO_SYSTEM_EXCEPTION + +void +TAO_AnyTypeCode_Adapter_Impl::insert_into_any (CORBA::Any * any, CORBA::Char const * mychar) +{ + (*any) <<= mychar; +} + +void +TAO_AnyTypeCode_Adapter_Impl::insert_into_any (CORBA::Any * any, CORBA::WChar const * mywchar) +{ + (*any) <<= mywchar; +} + +void +TAO_AnyTypeCode_Adapter_Impl::insert_into_any (CORBA::Any * any, CORBA::Long value) +{ + (*any) <<= value; +} + +void +TAO_AnyTypeCode_Adapter_Impl::insert_into_any (CORBA::Any * any, CORBA::Short value) +{ + (*any) <<= value; +} + +void +TAO_AnyTypeCode_Adapter_Impl::insert_into_any (CORBA::Any * any, CORBA::UShort value) +{ + (*any) <<= value; +} + +void +TAO_AnyTypeCode_Adapter_Impl::insert_into_any (CORBA::Any * any, CORBA::Float value) +{ + (*any) <<= value; +} + +void +TAO_AnyTypeCode_Adapter_Impl::insert_into_any (CORBA::Any * any, CORBA::Double value) +{ + (*any) <<= value; +} + +void +TAO_AnyTypeCode_Adapter_Impl::insert_into_any (CORBA::Any * any, CORBA::LongLong value) +{ + (*any) <<= value; +} + +void +TAO_AnyTypeCode_Adapter_Impl::insert_into_any (CORBA::Any * any, CORBA::ULongLong value) +{ + (*any) <<= value; +} + +void +TAO_AnyTypeCode_Adapter_Impl::insert_into_any (CORBA::Any * any, CORBA::LongDouble value) +{ + (*any) <<= value; +} + +void +TAO_AnyTypeCode_Adapter_Impl::insert_into_any (CORBA::Any * any, CORBA::Policy_ptr policy) +{ + (*any) <<= policy; +} + +void +TAO_AnyTypeCode_Adapter_Impl::insert_into_any (CORBA::Any * any, CORBA::Policy_ptr * policy) +{ + (*any) <<= policy; +} + +void +TAO_AnyTypeCode_Adapter_Impl::insert_into_any (CORBA::Any * any, CORBA::ULong value) +{ + (*any) <<= value; +} + +void +TAO_AnyTypeCode_Adapter_Impl::insert_into_any (CORBA::Any * any, ACE_OutputCDR::from_wchar value) +{ + (*any) <<= value; +} + +void +TAO_AnyTypeCode_Adapter_Impl::insert_into_any (CORBA::Any * any, ACE_OutputCDR::from_char value) +{ + (*any) <<= value; +} + +void +TAO_AnyTypeCode_Adapter_Impl::insert_into_any (CORBA::Any * any, ACE_OutputCDR::from_octet value) +{ + (*any) <<= value; +} + +void +TAO_AnyTypeCode_Adapter_Impl::insert_into_any (CORBA::Any * any, ACE_OutputCDR::from_boolean value) +{ + (*any) <<= value; +} + +int +TAO_AnyTypeCode_Adapter_Impl::Initializer (void) +{ + return ACE_Service_Config::process_directive ( + ace_svc_desc_TAO_AnyTypeCode_Adapter_Impl + ); +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +ACE_STATIC_SVC_DEFINE ( + TAO_AnyTypeCode_Adapter_Impl, + ACE_TEXT ("AnyTypeCode_Adapter"), + ACE_SVC_OBJ_T, + &ACE_SVC_NAME (TAO_AnyTypeCode_Adapter_Impl), + ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ, + 0) + +ACE_FACTORY_DEFINE (TAO_AnyTypeCode, TAO_AnyTypeCode_Adapter_Impl) + + diff --git a/TAO/tao/AnyTypeCode/AnyTypeCode_Adapter_Impl.h b/TAO/tao/AnyTypeCode/AnyTypeCode_Adapter_Impl.h new file mode 100644 index 00000000000..389623b086c --- /dev/null +++ b/TAO/tao/AnyTypeCode/AnyTypeCode_Adapter_Impl.h @@ -0,0 +1,135 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file AnyTypeCode_Adapter_Impl.h + * + * $Id$ + * + * @author Johnny Willemsen <jwillemsen@remedy.nl> + */ +//============================================================================= + + +#ifndef TAO_ANYTYPECODE_ADAPTER_IMPL_H +#define TAO_ANYTYPECODE_ADAPTER_IMPL_H + +#include /**/ "ace/pre.h" + +#include "tao/AnyTypeCode/TAO_AnyTypeCode_Export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/AnyTypeCode_Adapter.h" +#include "ace/Service_Config.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class TAO_AnyTypeCode_Adapter + */ +class TAO_AnyTypeCode_Export TAO_AnyTypeCode_Adapter_Impl + : public TAO_AnyTypeCode_Adapter +{ +public: + // Used to force the initialization of the code. + static int Initializer (void); + +#define ANYTYPECODE__EXCEPTION_LIST \ + TAO_SYSTEM_EXCEPTION (UNKNOWN) \ + TAO_SYSTEM_EXCEPTION (BAD_PARAM) \ + TAO_SYSTEM_EXCEPTION (NO_MEMORY) \ + TAO_SYSTEM_EXCEPTION (IMP_LIMIT) \ + TAO_SYSTEM_EXCEPTION (COMM_FAILURE) \ + TAO_SYSTEM_EXCEPTION (INV_OBJREF) \ + TAO_SYSTEM_EXCEPTION (OBJECT_NOT_EXIST) \ + TAO_SYSTEM_EXCEPTION (NO_PERMISSION) \ + TAO_SYSTEM_EXCEPTION (INTERNAL) \ + TAO_SYSTEM_EXCEPTION (MARSHAL) \ + TAO_SYSTEM_EXCEPTION (INITIALIZE) \ + TAO_SYSTEM_EXCEPTION (NO_IMPLEMENT) \ + TAO_SYSTEM_EXCEPTION (BAD_TYPECODE) \ + TAO_SYSTEM_EXCEPTION (BAD_OPERATION) \ + TAO_SYSTEM_EXCEPTION (NO_RESOURCES) \ + TAO_SYSTEM_EXCEPTION (NO_RESPONSE) \ + TAO_SYSTEM_EXCEPTION (PERSIST_STORE) \ + TAO_SYSTEM_EXCEPTION (BAD_INV_ORDER) \ + TAO_SYSTEM_EXCEPTION (TRANSIENT) \ + TAO_SYSTEM_EXCEPTION (FREE_MEM) \ + TAO_SYSTEM_EXCEPTION (INV_IDENT) \ + TAO_SYSTEM_EXCEPTION (INV_FLAG) \ + TAO_SYSTEM_EXCEPTION (INTF_REPOS) \ + TAO_SYSTEM_EXCEPTION (BAD_CONTEXT) \ + TAO_SYSTEM_EXCEPTION (OBJ_ADAPTER) \ + TAO_SYSTEM_EXCEPTION (DATA_CONVERSION) \ + TAO_SYSTEM_EXCEPTION (INV_POLICY) \ + TAO_SYSTEM_EXCEPTION (REBIND) \ + TAO_SYSTEM_EXCEPTION (TIMEOUT) \ + TAO_SYSTEM_EXCEPTION (TRANSACTION_UNAVAILABLE) \ + TAO_SYSTEM_EXCEPTION (TRANSACTION_MODE) \ + TAO_SYSTEM_EXCEPTION (TRANSACTION_REQUIRED) \ + TAO_SYSTEM_EXCEPTION (TRANSACTION_ROLLEDBACK) \ + TAO_SYSTEM_EXCEPTION (INVALID_TRANSACTION) \ + TAO_SYSTEM_EXCEPTION (CODESET_INCOMPATIBLE) \ + TAO_SYSTEM_EXCEPTION (BAD_QOS) \ + TAO_SYSTEM_EXCEPTION (INVALID_ACTIVITY) \ + TAO_SYSTEM_EXCEPTION (ACTIVITY_COMPLETED) \ + TAO_SYSTEM_EXCEPTION (ACTIVITY_REQUIRED) \ + TAO_SYSTEM_EXCEPTION (THREAD_CANCELLED) \ + TAO_SYSTEM_EXCEPTION (WrongTransaction) \ + TAO_SYSTEM_EXCEPTION (PolicyError) \ + TAO_SYSTEM_EXCEPTION (InvalidPolicies) + +#define TAO_SYSTEM_EXCEPTION(name) \ + virtual CORBA::TypeCode_ptr _tao_type_ ## name (void) const; + +ANYTYPECODE__EXCEPTION_LIST +#undef TAO_SYSTEM_EXCEPTION + + virtual void insert_into_any (CORBA::Any * any, CORBA::Char const * mychar); + + virtual void insert_into_any (CORBA::Any * any, CORBA::WChar const * mywchar); + + virtual void insert_into_any (CORBA::Any * any, CORBA::Long value); + + virtual void insert_into_any (CORBA::Any * any, CORBA::Short value); + + virtual void insert_into_any (CORBA::Any * any, CORBA::UShort value); + + virtual void insert_into_any (CORBA::Any * any, CORBA::Float value); + + virtual void insert_into_any (CORBA::Any * any, CORBA::Double value); + + virtual void insert_into_any (CORBA::Any * any, CORBA::LongLong value); + + virtual void insert_into_any (CORBA::Any * any, CORBA::ULongLong value); + + virtual void insert_into_any (CORBA::Any * any, CORBA::LongDouble value); + + virtual void insert_into_any (CORBA::Any * any, CORBA::Policy_ptr policy); + + virtual void insert_into_any (CORBA::Any * any, CORBA::Policy_ptr * policy); + + virtual void insert_into_any (CORBA::Any * any, CORBA::ULong value); + + virtual void insert_into_any (CORBA::Any * any, ACE_OutputCDR::from_wchar value); + + virtual void insert_into_any (CORBA::Any * any, ACE_OutputCDR::from_char value); + + virtual void insert_into_any (CORBA::Any * any, ACE_OutputCDR::from_octet value); + + virtual void insert_into_any (CORBA::Any * any, ACE_OutputCDR::from_boolean value); +}; + +TAO_END_VERSIONED_NAMESPACE_DECL + +ACE_STATIC_SVC_DECLARE (TAO_AnyTypeCode_Adapter_Impl) +ACE_FACTORY_DECLARE (TAO_AnyTypeCode, TAO_AnyTypeCode_Adapter_Impl) + +static int TAO_Requires_TAO_AnyTypeCode_Adapter_Impl = + TAO_AnyTypeCode_Adapter_Impl::Initializer (); + +#include /**/ "ace/post.h" +#endif /* TAO_ANYTYPECODE_ADAPTER_IMPL_H */ diff --git a/TAO/tao/AnyTypeCode/AnyTypeCode_methods.h b/TAO/tao/AnyTypeCode/AnyTypeCode_methods.h new file mode 100644 index 00000000000..d954af4b0ad --- /dev/null +++ b/TAO/tao/AnyTypeCode/AnyTypeCode_methods.h @@ -0,0 +1,60 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file AnyTypeCode_methods.h + * + * $Id$ + * + * Declarations of NamedValue and NVlist methods in the CORBA namespace. + * + * @author Jeff Parsons <j.parsons@vanderbilt.edu> + */ +//============================================================================= + +#ifndef TAO_ANYTYPECODE_METHODS_H +#define TAO_ANYTYPECODE_METHODS_H + +#include /**/ "ace/pre.h" +#include "tao/AnyTypeCode/TAO_AnyTypeCode_Export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if defined (TAO_EXPORT_MACRO) +#undef TAO_EXPORT_MACRO +#endif +#define TAO_EXPORT_MACRO TAO_AnyTypeCode_Export + +#include "tao/Basic_Types.h" +#include "tao/orbconf.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace CORBA +{ + class NamedValue; + typedef NamedValue *NamedValue_ptr; + + class NVList; + typedef NVList *NVList_ptr; + + class TypeCode; + typedef TypeCode *TypeCode_ptr; + + TAO_NAMESPACE_INLINE_FUNCTION void release (NamedValue_ptr); + TAO_NAMESPACE_INLINE_FUNCTION Boolean is_nil (NamedValue_ptr); + + TAO_NAMESPACE_INLINE_FUNCTION void release (NVList_ptr); + TAO_NAMESPACE_INLINE_FUNCTION Boolean is_nil (NVList_ptr ); + + TAO_NAMESPACE_INLINE_FUNCTION Boolean is_nil (TypeCode_ptr); + TAO_NAMESPACE_INLINE_FUNCTION void release (TypeCode_ptr); +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" + +#endif /* TAO_ANYTYPECODE_METHODS_H */ diff --git a/TAO/tao/AnyTypeCode/Any_Arg_Traits.h b/TAO/tao/AnyTypeCode/Any_Arg_Traits.h new file mode 100644 index 00000000000..56bdc4ace51 --- /dev/null +++ b/TAO/tao/AnyTypeCode/Any_Arg_Traits.h @@ -0,0 +1,52 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Any_Arg_Traits.h + * + * $Id$ + * + * @author Jeff Parsons + */ +//============================================================================= + + +#ifndef TAO_ANY_ARG_TRAITS_H +#define TAO_ANY_ARG_TRAITS_H + +#include /**/ "ace/pre.h" + +#include "tao/AnyTypeCode/TAO_AnyTypeCode_Export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/Var_Size_Argument_T.h" +#include "tao/Arg_Traits_T.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace CORBA +{ + class Any; +} + +namespace TAO +{ + template<> + class TAO_AnyTypeCode_Export Arg_Traits<CORBA::Any> + : public + Var_Size_Arg_Traits_T< + CORBA::Any, + TAO::Any_Insert_Policy_Stream <CORBA::Any> + > + { + }; +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" + +#endif /* TAO_ANY_ARG_TRAITS_H */ diff --git a/TAO/tao/AnyTypeCode/Any_Array_Impl_T.cpp b/TAO/tao/AnyTypeCode/Any_Array_Impl_T.cpp new file mode 100644 index 00000000000..97cda1e2d59 --- /dev/null +++ b/TAO/tao/AnyTypeCode/Any_Array_Impl_T.cpp @@ -0,0 +1,177 @@ +// $Id$ + +#ifndef TAO_ANY_ARRAY_IMPL_T_CPP +#define TAO_ANY_ARRAY_IMPL_T_CPP + +#include "tao/AnyTypeCode/Any_Array_Impl_T.h" +#include "tao/AnyTypeCode/Any.h" +#include "tao/AnyTypeCode/Any_Unknown_IDL_Type.h" +#include "tao/AnyTypeCode/Marshal.h" +#include "tao/debug.h" +#include "tao/CDR.h" +#include "tao/SystemException.h" + +#include "ace/CORBA_macros.h" +#include "ace/Auto_Ptr.h" + +#if !defined (__ACE_INLINE__) +# include "tao/AnyTypeCode/Any_Array_Impl_T.inl" +#endif /* ! __ACE_INLINE__ */ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +template<typename T_slice, typename T_forany> +TAO::Any_Array_Impl_T<T_slice, T_forany>::Any_Array_Impl_T ( + _tao_destructor destructor, + CORBA::TypeCode_ptr tc, + T_slice * const val + ) + : Any_Impl (destructor, + tc), + value_ (val) +{ +} + +template<typename T_slice, typename T_forany> +TAO::Any_Array_Impl_T<T_slice, T_forany>::~Any_Array_Impl_T (void) +{ +} + +template<typename T_slice, typename T_forany> +void +TAO::Any_Array_Impl_T<T_slice, T_forany>::insert (CORBA::Any & any, + _tao_destructor destructor, + CORBA::TypeCode_ptr tc, + T_slice * const value) +{ + TAO::Any_Array_Impl_T<T_slice, T_forany> *new_impl = 0; + typedef TAO::Any_Array_Impl_T<T_slice, T_forany> ARRAY_ANY_IMPL; + ACE_NEW (new_impl, + ARRAY_ANY_IMPL (destructor, + tc, + value)); + any.replace (new_impl); +} + +template<typename T_slice, typename T_forany> +CORBA::Boolean +TAO::Any_Array_Impl_T<T_slice, T_forany>::extract (const CORBA::Any & any, + _tao_destructor destructor, + CORBA::TypeCode_ptr tc, + T_slice *& _tao_elem) +{ + _tao_elem = 0; + + ACE_TRY_NEW_ENV + { + CORBA::TypeCode_ptr any_tc = any._tao_get_typecode (); + CORBA::Boolean const _tao_equiv = + any_tc->equivalent (tc + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (_tao_equiv == false) + { + return false; + } + + TAO::Any_Impl *impl = any.impl (); + + if (!impl->encoded ()) + { + TAO::Any_Array_Impl_T<T_slice, T_forany> *narrow_impl = + dynamic_cast <TAO::Any_Array_Impl_T <T_slice, T_forany> *> (impl); + + if (narrow_impl == 0) + { + return false; + } + + _tao_elem = reinterpret_cast <T_slice*> (narrow_impl->value_); + return true; + } + + TAO::Any_Array_Impl_T<T_slice, T_forany> *replacement = 0; + typedef TAO::Any_Array_Impl_T<T_slice, T_forany> ARRAY_ANY_IMPL; + ACE_NEW_RETURN (replacement, + ARRAY_ANY_IMPL (destructor, + any_tc, + T_forany::tao_alloc ()), + false); + + auto_ptr<TAO::Any_Array_Impl_T<T_slice, T_forany> > replacement_safety ( + replacement + ); + + // We know this will work since the unencoded case is covered above. + TAO::Unknown_IDL_Type *unk = + dynamic_cast<TAO::Unknown_IDL_Type *> (impl); + + // We don't want the rd_ptr of unk to move, in case it is + // shared by another Any. This copies the state, not the buffer. + TAO_InputCDR for_reading (unk->_tao_get_cdr ()); + + CORBA::Boolean const good_decode = + replacement->demarshal_value (for_reading); + + if (good_decode) + { + _tao_elem = reinterpret_cast <T_slice*> (replacement->value_); + const_cast<CORBA::Any &> (any).replace (replacement); + replacement_safety.release (); + return true; + } + + // Duplicated by Any_Impl base class constructor. + ::CORBA::release (any_tc); + } + ACE_CATCHANY + { + } + ACE_ENDTRY; + + return 0; +} + +template<typename T_slice, typename T_forany> +CORBA::Boolean +TAO::Any_Array_Impl_T<T_slice, T_forany>::marshal_value (TAO_OutputCDR &cdr) +{ + return (cdr << T_forany (this->value_)); +} + +template<typename T_slice, typename T_forany> +const void * +TAO::Any_Array_Impl_T<T_slice, T_forany>::value (void) const +{ + return this->value_; +} + +template<typename T_slice, typename T_forany> +void +TAO::Any_Array_Impl_T<T_slice, T_forany>::free_value (void) +{ + if (this->value_destructor_ != 0) + { + (*this->value_destructor_) (this->value_); + this->value_destructor_ = 0; + } + + this->value_ = 0; + ::CORBA::release (this->type_); +} + +template<typename T_slice, typename T_forany> +void +TAO::Any_Array_Impl_T<T_slice, T_forany>::_tao_decode (TAO_InputCDR &cdr + ACE_ENV_ARG_DECL) +{ + if (! this->demarshal_value (cdr)) + { + ACE_THROW (CORBA::MARSHAL ()); + } +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +#endif /* TAO_ANY_ARRAY_IMPL_T_CPP */ diff --git a/TAO/tao/AnyTypeCode/Any_Array_Impl_T.h b/TAO/tao/AnyTypeCode/Any_Array_Impl_T.h new file mode 100644 index 00000000000..f7c0d1656ab --- /dev/null +++ b/TAO/tao/AnyTypeCode/Any_Array_Impl_T.h @@ -0,0 +1,84 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Any_Array_Impl_T.h + * + * $Id$ + * + * @authors Carlos O'Ryan and Jeff Parsons + */ +//============================================================================= + + +#ifndef TAO_ANY_ARRAY_IMPL_T_H +#define TAO_ANY_ARRAY_IMPL_T_H + +#include /**/ "ace/pre.h" + +#include "tao/AnyTypeCode/Any_Impl.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + /** + * @class Any_Array_Impl_T + * + * @brief Template Any class for array types. + * + * Used for arrays + */ + template<typename T_slice, typename T_forany> + class Any_Array_Impl_T : public Any_Impl + { + public: + Any_Array_Impl_T (_tao_destructor destructor, + CORBA::TypeCode_ptr, + T_slice * const); + virtual ~Any_Array_Impl_T (void); + + static void insert (CORBA::Any &, + _tao_destructor destructor, + CORBA::TypeCode_ptr, + T_slice * const); + static CORBA::Boolean extract (const CORBA::Any &, + _tao_destructor, + CORBA::TypeCode_ptr, + T_slice *&); + + virtual CORBA::Boolean marshal_value (TAO_OutputCDR &); + CORBA::Boolean demarshal_value (TAO_InputCDR &); + virtual void _tao_decode (TAO_InputCDR & + ACE_ENV_ARG_DECL_WITH_DEFAULTS); + + virtual const void *value (void) const; + virtual void free_value (void); + + private: + T_slice * value_; + }; +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +# include "tao/AnyTypeCode/Any_Array_Impl_T.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "tao/AnyTypeCode/Any_Array_Impl_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Any_Array_Impl_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" + +#endif /* TAO_ANY_ARRAY_IMPL_T_H */ + diff --git a/TAO/tao/AnyTypeCode/Any_Array_Impl_T.inl b/TAO/tao/AnyTypeCode/Any_Array_Impl_T.inl new file mode 100644 index 00000000000..939a2e9d3e3 --- /dev/null +++ b/TAO/tao/AnyTypeCode/Any_Array_Impl_T.inl @@ -0,0 +1,16 @@ +// -*- C++ -*- +// +// $Id$ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +template<typename T_slice, typename T_forany> +ACE_INLINE +CORBA::Boolean +TAO::Any_Array_Impl_T<T_slice, T_forany>::demarshal_value (TAO_InputCDR &cdr) +{ + T_forany tmp (this->value_); + return (cdr >> tmp); +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/Any_Basic_Impl.cpp b/TAO/tao/AnyTypeCode/Any_Basic_Impl.cpp new file mode 100644 index 00000000000..d5e0e364af3 --- /dev/null +++ b/TAO/tao/AnyTypeCode/Any_Basic_Impl.cpp @@ -0,0 +1,386 @@ +// $Id$ + +#include "tao/AnyTypeCode/Any_Basic_Impl.h" +#include "tao/AnyTypeCode/Any_Unknown_IDL_Type.h" +#include "tao/AnyTypeCode/Any.h" +#include "tao/AnyTypeCode/TypeCode.h" +#include "tao/CDR.h" +#include "tao/SystemException.h" + +#include "ace/Auto_Ptr.h" +#include "ace/OS_NS_string.h" + +ACE_RCSID (AnyTypeCode, + Any_Basic_Impl, + "$Id$") + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + Any_Basic_Impl::Any_Basic_Impl (CORBA::TypeCode_ptr tc, + void *value) + : Any_Impl (0, tc), + kind_ (CORBA::tk_null) + { + ACE_DECLARE_NEW_CORBA_ENV; + this->kind_ = TAO::unaliased_kind (tc + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + switch (this->kind_) + { + case CORBA::tk_short: + this->u_.s = *static_cast<CORBA::Short *> (value); + break; + case CORBA::tk_ushort: + this->u_.us = *static_cast<CORBA::UShort *> (value); + break; + case CORBA::tk_long: + this->u_.l = *static_cast<CORBA::Long *> (value); + break; + case CORBA::tk_ulong: + this->u_.ul = *static_cast<CORBA::ULong *> (value); + break; + case CORBA::tk_float: + this->u_.f = *static_cast<CORBA::Float *> (value); + break; + case CORBA::tk_double: + this->u_.d = *static_cast<CORBA::Double *> (value); + break; + case CORBA::tk_boolean: + this->u_.b = *static_cast<CORBA::Boolean *> (value); + break; + case CORBA::tk_char: + this->u_.c = *static_cast<CORBA::Char *> (value); + break; + case CORBA::tk_octet: + this->u_.o = *static_cast<CORBA::Octet *> (value); + break; + case CORBA::tk_longlong: + this->u_.ll = *static_cast<CORBA::LongLong *> (value); + break; +#if !defined (ACE_LACKS_LONGLONG_T) + case CORBA::tk_ulonglong: + #if !defined (ACE_LACKS_UNSIGNEDLONGLONG_T) + this->u_.ull = *static_cast<CORBA::ULongLong *> (value); + #else + this->u_.ull = *static_cast<CORBA::LongLong *> (value); + #endif + break; +#endif + case CORBA::tk_longdouble: + this->u_.ld = *static_cast<CORBA::LongDouble *> (value); + break; + case CORBA::tk_wchar: + this->u_.wc = *static_cast<CORBA::WChar *> (value); + break; + default: + break; + } + } + + Any_Basic_Impl::~Any_Basic_Impl (void) + { + } + + void + Any_Basic_Impl::insert (CORBA::Any &any, + CORBA::TypeCode_ptr tc, + const void *value) + { + Any_Basic_Impl *new_impl = 0; + ACE_NEW (new_impl, + Any_Basic_Impl (tc, + const_cast<void *> (value))); + any.replace (new_impl); + } + + CORBA::Boolean + Any_Basic_Impl::extract (const CORBA::Any &any, + CORBA::TypeCode_ptr tc, + void *_tao_elem) + { + ACE_TRY_NEW_ENV + { + CORBA::TypeCode_ptr any_tc = any._tao_get_typecode (); + CORBA::Boolean _tao_equiv = + any_tc->equivalent (tc + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (!_tao_equiv) + { + return false; + } + + TAO::Any_Impl *impl = any.impl (); + + if (!impl->encoded ()) + { + TAO::Any_Basic_Impl *narrow_impl = + dynamic_cast<TAO::Any_Basic_Impl *> (impl); + + if (narrow_impl == 0) + { + return false; + } + + Any_Basic_Impl::assign_value (_tao_elem, + narrow_impl); + return true; + } + + TAO::Any_Basic_Impl *replacement = + TAO::Any_Basic_Impl::create_empty (any_tc); + + auto_ptr<TAO::Any_Basic_Impl> replacement_safety (replacement); + + // We know this will work since the unencoded case is covered above. + TAO::Unknown_IDL_Type *unk = + dynamic_cast<TAO::Unknown_IDL_Type *> (impl); + + // Get the kind of the type where we are extracting in ie. the + // aliased type if there are any. Passing the aliased kind + // will not help. + CORBA::TCKind const tck = tc->kind (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + // We don't want the rd_ptr of unk to move, in case it is + // shared by another Any. This copies the state, not the buffer. + TAO_InputCDR for_reading (unk->_tao_get_cdr ()); + + CORBA::Boolean const good_decode = + replacement->demarshal_value (for_reading, + static_cast<CORBA::Long> (tck)); + + if (good_decode) + { + Any_Basic_Impl::assign_value (_tao_elem, + replacement, + tck); + const_cast<CORBA::Any &> (any).replace (replacement); + replacement_safety.release (); + return true; + } + + // Duplicated by Any_Impl base class constructor. + ::CORBA::release (any_tc); + } + ACE_CATCHANY + { + } + ACE_ENDTRY; + + return false; + } + + CORBA::Boolean + Any_Basic_Impl::marshal_value (TAO_OutputCDR &cdr) + { + CORBA::TCKind tckind = static_cast<CORBA::TCKind> (this->kind_); + + switch (tckind) + { + case CORBA::tk_short: + return cdr << this->u_.s; + case CORBA::tk_ushort: + return cdr << this->u_.us; + case CORBA::tk_long: + return cdr << this->u_.l; + case CORBA::tk_ulong: + return cdr << this->u_.ul; + case CORBA::tk_float: + return cdr << this->u_.f; + case CORBA::tk_double: + return cdr << this->u_.d; + case CORBA::tk_boolean: + return cdr << CORBA::Any::from_boolean (this->u_.b); + case CORBA::tk_char: + return cdr << CORBA::Any::from_char (this->u_.c); + case CORBA::tk_octet: + return cdr << CORBA::Any::from_octet (this->u_.o); + case CORBA::tk_longlong: + return cdr << this->u_.ll; +#if !defined (ACE_LACKS_LONGLONG_T) + case CORBA::tk_ulonglong: + return cdr << this->u_.ull; +#endif + case CORBA::tk_longdouble: + return cdr << this->u_.ld; + case CORBA::tk_wchar: + return cdr << CORBA::Any::from_wchar (this->u_.wc); + default: + return 0; + } + } + + CORBA::Boolean + Any_Basic_Impl::demarshal_value (TAO_InputCDR &cdr) + { + return this->demarshal_value (cdr, + this->kind_); + } + + CORBA::Boolean + Any_Basic_Impl::demarshal_value (TAO_InputCDR &cdr, + CORBA::Long tck) + { + CORBA::TCKind const tckind = static_cast<CORBA::TCKind> (tck); + switch (tckind) + { + case CORBA::tk_short: + return cdr >> this->u_.s; + case CORBA::tk_ushort: + return cdr >> this->u_.us; + case CORBA::tk_long: + return cdr >> this->u_.l; + case CORBA::tk_ulong: + return cdr >> this->u_.ul; + case CORBA::tk_float: + return cdr >> this->u_.f; + case CORBA::tk_double: + return cdr >> this->u_.d; + case CORBA::tk_boolean: + return cdr >> CORBA::Any::to_boolean (this->u_.b); + case CORBA::tk_char: + return cdr >> CORBA::Any::to_char (this->u_.c); + case CORBA::tk_octet: + return cdr >> CORBA::Any::to_octet (this->u_.o); + case CORBA::tk_longlong: + return cdr >> this->u_.ll; +#if !defined (ACE_LACKS_LONGLONG_T) + case CORBA::tk_ulonglong: + return cdr >> this->u_.ull; +#endif + case CORBA::tk_longdouble: + return cdr >> this->u_.ld; + case CORBA::tk_wchar: + return cdr >> CORBA::Any::to_wchar (this->u_.wc); + default: + return 0; + } + } + + void + Any_Basic_Impl::_tao_decode (TAO_InputCDR &cdr + ACE_ENV_ARG_DECL) + { + if (! this->demarshal_value (cdr)) + { + ACE_THROW (CORBA::MARSHAL ()); + } + } + + Any_Basic_Impl * + Any_Basic_Impl::create_empty (CORBA::TypeCode_ptr tc) + { + ACE_DECLARE_NEW_CORBA_ENV; + CORBA::TCKind const kind = tc->kind (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + TAO::Any_Basic_Impl * retval = 0; + + switch (kind) + { + case CORBA::tk_longlong: + { + CORBA::LongLong tmp = ACE_CDR_LONGLONG_INITIALIZER; + ACE_NEW_RETURN (retval, + TAO::Any_Basic_Impl (tc, &tmp), + 0); + } + + break; + case CORBA::tk_longdouble: + { + CORBA::LongDouble tmp = ACE_CDR_LONG_DOUBLE_INITIALIZER; + ACE_NEW_RETURN (retval, + TAO::Any_Basic_Impl (tc, &tmp), + 0); + } + + break; + default: + { + CORBA::ULongLong tmp = 0; + ACE_NEW_RETURN (retval, + TAO::Any_Basic_Impl (tc, &tmp), + 0); + } + + break; + } + + return retval; + } + + void + Any_Basic_Impl::assign_value (void *dest, Any_Basic_Impl *src) + { + Any_Basic_Impl::assign_value (dest, + src, + src->kind_); + } + + void + Any_Basic_Impl::assign_value (void *dest, + Any_Basic_Impl *src, + CORBA::Long tck) + { + CORBA::TCKind const kind = static_cast<CORBA::TCKind> (tck); + + switch (kind) + { + case CORBA::tk_short: + *static_cast<CORBA::Short *> (dest) = src->u_.s; + break; + case CORBA::tk_ushort: + *static_cast<CORBA::UShort *> (dest) = src->u_.us; + break; + case CORBA::tk_long: + *static_cast<CORBA::Long *> (dest) = src->u_.l; + break; + case CORBA::tk_ulong: + *static_cast<CORBA::ULong *> (dest) = src->u_.ul; + break; + case CORBA::tk_float: + *static_cast<CORBA::Float *> (dest) = src->u_.f; + break; + case CORBA::tk_double: + *static_cast<CORBA::Double *> (dest) = src->u_.d; + break; + case CORBA::tk_boolean: + *static_cast<CORBA::Boolean *> (dest) = src->u_.b; + break; + case CORBA::tk_char: + *static_cast<CORBA::Char *> (dest) = src->u_.c; + break; + case CORBA::tk_octet: + *static_cast<CORBA::Octet *> (dest) = src->u_.o; + break; + case CORBA::tk_longlong: + *static_cast<CORBA::LongLong *> (dest) = src->u_.ll; + break; +#if !defined (ACE_LACKS_LONGLONG_T) + case CORBA::tk_ulonglong: + #if !defined (ACE_LACKS_UNSIGNEDLONGLONG_T) + *static_cast<CORBA::ULongLong *> (dest) = src->u_.ull; + break; + #else + *static_cast<CORBA::LongLong *> (dest) = src->u_.ull; + #endif +#endif + case CORBA::tk_longdouble: + *static_cast<CORBA::LongDouble *> (dest) = src->u_.ld; + break; + case CORBA::tk_wchar: + *static_cast<CORBA::WChar *> (dest) = src->u_.wc; + break; + default: + break; + } + } +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/Any_Basic_Impl.h b/TAO/tao/AnyTypeCode/Any_Basic_Impl.h new file mode 100644 index 00000000000..563a252d54a --- /dev/null +++ b/TAO/tao/AnyTypeCode/Any_Basic_Impl.h @@ -0,0 +1,102 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Any_Basic_Impl.h + * + * $Id$ + * + * @authors Carlos O'Ryan and Jeff Parsons + */ +//============================================================================= + +#ifndef TAO_ANY_BASIC_IMPL_H +#define TAO_ANY_BASIC_IMPL_H + +#include /**/ "ace/pre.h" + +#include "tao/AnyTypeCode/Any_Impl.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace CORBA +{ + class Any; +} + +namespace TAO +{ + /** + * @class Any_Basic_Impl + * + * @brief Non-template class for all the basic types. + * + */ + class TAO_AnyTypeCode_Export Any_Basic_Impl : public Any_Impl + { + public: + Any_Basic_Impl (CORBA::TypeCode_ptr, + void *value); + + virtual ~Any_Basic_Impl (void); + + static void insert (CORBA::Any &, + CORBA::TypeCode_ptr, + const void *); + static CORBA::Boolean extract (const CORBA::Any &, + CORBA::TypeCode_ptr, + void *); + + virtual CORBA::Boolean marshal_value (TAO_OutputCDR &); + + CORBA::Boolean demarshal_value (TAO_InputCDR &); + CORBA::Boolean demarshal_value (TAO_InputCDR &, + CORBA::Long); + + virtual void _tao_decode (TAO_InputCDR & + ACE_ENV_ARG_DECL); + + static Any_Basic_Impl *create_empty (CORBA::TypeCode_ptr); + + private: + static void assign_value (void *, Any_Basic_Impl *); + + static void assign_value (void *, + Any_Basic_Impl *, + CORBA::Long tck); + private: + CORBA::Long kind_; + union + { + CORBA::Short s; + CORBA::UShort us; + CORBA::Long l; + CORBA::ULong ul; + CORBA::Float f; + CORBA::Double d; + CORBA::Boolean b; + CORBA::Char c; + CORBA::Octet o; + CORBA::LongLong ll; +#if !defined (ACE_LACKS_LONGLONG_T) && !defined (ACE_LACKS_UNSIGNEDLONGLONG_T) + CORBA::ULongLong ull; +#elif defined (ACE_LACKS_UNSIGNEDLONGLONG_T) + // Platform has signed long long but not unsigned long long. + // Use signed long long as the container. + CORBA::LongLong ull; +#endif + CORBA::LongDouble ld; + CORBA::WChar wc; + }u_; + }; +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" + +#endif /* TAO_ANY_BASIC_IMPL_H */ diff --git a/TAO/tao/AnyTypeCode/Any_Basic_Impl_T.cpp b/TAO/tao/AnyTypeCode/Any_Basic_Impl_T.cpp new file mode 100644 index 00000000000..7c892b754d3 --- /dev/null +++ b/TAO/tao/AnyTypeCode/Any_Basic_Impl_T.cpp @@ -0,0 +1,158 @@ +// $Id$ + +#ifndef TAO_ANY_BASIC_IMPL_T_CPP +#define TAO_ANY_BASIC_IMPL_T_CPP + +#include "tao/AnyTypeCode/Any_Basic_Impl_T.h" +#include "tao/AnyTypeCode/Any.h" +#include "tao/AnyTypeCode/Any_Unknown_IDL_Type.h" +#include "tao/AnyTypeCode/Marshal.h" +#include "tao/Environment.h" +#include "tao/SystemException.h" +#include "tao/CDR.h" + +#include "ace/CORBA_macros.h" +#include "ace/Auto_Ptr.h" + +#if !defined (__ACE_INLINE__) +# include "tao/AnyTypeCode/Any_Basic_Impl_T.inl" +#endif /* ! __ACE_INLINE__ */ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +template<typename T> +TAO::Any_Basic_Impl_T<T>::Any_Basic_Impl_T (CORBA::TypeCode_ptr tc, + const T & val) + : Any_Impl (0, + tc), + value_ (val) +{ +} + +template<typename T> +TAO::Any_Basic_Impl_T<T>::~Any_Basic_Impl_T (void) +{ +} + +template<typename T> +void +TAO::Any_Basic_Impl_T<T>::insert (CORBA::Any & any, + CORBA::TypeCode_ptr tc, + const T & value) +{ + Any_Basic_Impl_T<T> *new_impl = 0; + ACE_NEW (new_impl, + Any_Basic_Impl_T (tc, + value)); + any.replace (new_impl); +} + +template<typename T> +CORBA::Boolean +TAO::Any_Basic_Impl_T<T>::extract (const CORBA::Any & any, + CORBA::TypeCode_ptr tc, + T & _tao_elem) +{ + ACE_TRY_NEW_ENV + { + CORBA::TypeCode_ptr any_tc = any._tao_get_typecode (); + CORBA::Boolean const _tao_equiv = any_tc->equivalent (tc + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (_tao_equiv == false) + { + return false; + } + + TAO::Any_Impl *impl = any.impl (); + + if (!impl->encoded ()) + { + TAO::Any_Basic_Impl_T<T> *narrow_impl = + dynamic_cast <TAO::Any_Basic_Impl_T<T> *> (impl); + + if (narrow_impl == 0) + { + return false; + } + + _tao_elem = narrow_impl->value_; + return true; + } + + TAO::Any_Basic_Impl_T<T> *replacement = + TAO::Any_Basic_Impl_T<T>::create_empty (any_tc); + + auto_ptr<TAO::Any_Basic_Impl_T<T> > replacement_safety (replacement); + + // We know this will work since the unencoded case is covered above. + TAO::Unknown_IDL_Type *unk = + dynamic_cast<TAO::Unknown_IDL_Type *> (impl); + + // We don't want the rd_ptr of unk to move, in case it is + // shared by another Any. This copies the state, not the buffer. + TAO_InputCDR for_reading (unk->_tao_get_cdr ()); + + CORBA::Boolean const good_decode = + replacement->demarshal_value (for_reading); + + if (good_decode) + { + _tao_elem = replacement->value_; + const_cast<CORBA::Any &> (any).replace (replacement); + replacement_safety.release (); + return true; + } + + // Duplicated by Any_Impl base class constructor. + ::CORBA::release (any_tc); + } + ACE_CATCHANY + { + } + ACE_ENDTRY; + + return false; +} + +template<typename T> +CORBA::Boolean +TAO::Any_Basic_Impl_T<T>::marshal_value (TAO_OutputCDR &cdr) +{ + return (cdr << this->value_); +} + +template<typename T> +const void * +TAO::Any_Basic_Impl_T<T>::value (void) const +{ + return &this->value_; +} + +template<typename T> +TAO::Any_Basic_Impl_T<T> * +TAO::Any_Basic_Impl_T<T>::create_empty (CORBA::TypeCode_ptr tc) +{ + TAO::Any_Basic_Impl_T<T> * retval = 0; + ACE_NEW_RETURN (retval, + TAO::Any_Basic_Impl_T<T> (tc, + static_cast<T> (0)), + 0); + return retval; +} + +template<typename T> +void +TAO::Any_Basic_Impl_T<T>::_tao_decode (TAO_InputCDR &cdr + ACE_ENV_ARG_DECL) +{ + if (! this->demarshal_value (cdr)) + { + ACE_THROW (CORBA::MARSHAL ()); + } +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +#endif /* TAO_ANY_BASIC_IMPL_T_CPP */ diff --git a/TAO/tao/AnyTypeCode/Any_Basic_Impl_T.h b/TAO/tao/AnyTypeCode/Any_Basic_Impl_T.h new file mode 100644 index 00000000000..aff9109b34b --- /dev/null +++ b/TAO/tao/AnyTypeCode/Any_Basic_Impl_T.h @@ -0,0 +1,81 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Any_Basic_Impl_T.h + * + * $Id$ + * + * @authors Carlos O'Ryan and Jeff Parsons + */ +//============================================================================= + + +#ifndef TAO_ANY_BASIC_IMPL_T_H +#define TAO_ANY_BASIC_IMPL_T_H + +#include /**/ "ace/pre.h" + +#include "tao/AnyTypeCode/Any_Impl.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + /** + * @class Any_Basic_Impl_T + * + * @brief Template Any class for basic types. + * + * Used for all basic IDL types except bounded (w)strings. + */ + template<typename T> + class Any_Basic_Impl_T : public Any_Impl + { + public: + Any_Basic_Impl_T (CORBA::TypeCode_ptr, + const T & val); + virtual ~Any_Basic_Impl_T (void); + + static void insert (CORBA::Any &, + CORBA::TypeCode_ptr, + const T &); + static CORBA::Boolean extract (const CORBA::Any &, + CORBA::TypeCode_ptr, + T &); + + virtual CORBA::Boolean marshal_value (TAO_OutputCDR &); + CORBA::Boolean demarshal_value (TAO_InputCDR &); + virtual void _tao_decode (TAO_InputCDR & + ACE_ENV_ARG_DECL_WITH_DEFAULTS); + + virtual const void *value (void) const; + static Any_Basic_Impl_T<T> *create_empty (CORBA::TypeCode_ptr); + + private: + T value_; + }; +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +# include "tao/AnyTypeCode/Any_Basic_Impl_T.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "tao/AnyTypeCode/Any_Basic_Impl_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Any_Basic_Impl_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" + +#endif /* TAO_ANY_BASIC_IMPL_T_H */ + diff --git a/TAO/tao/AnyTypeCode/Any_Basic_Impl_T.inl b/TAO/tao/AnyTypeCode/Any_Basic_Impl_T.inl new file mode 100644 index 00000000000..3114614a725 --- /dev/null +++ b/TAO/tao/AnyTypeCode/Any_Basic_Impl_T.inl @@ -0,0 +1,15 @@ +// -*- C++ -*- +// +// $Id$ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +template<typename T> +ACE_INLINE +CORBA::Boolean +TAO::Any_Basic_Impl_T<T>::demarshal_value (TAO_InputCDR &cdr) +{ + return (cdr >> this->value_); +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/Any_Dual_Impl_T.cpp b/TAO/tao/AnyTypeCode/Any_Dual_Impl_T.cpp new file mode 100644 index 00000000000..91dc8bdab29 --- /dev/null +++ b/TAO/tao/AnyTypeCode/Any_Dual_Impl_T.cpp @@ -0,0 +1,216 @@ +// $Id$ + +#ifndef TAO_ANY_DUAL_IMPL_T_CPP +#define TAO_ANY_DUAL_IMPL_T_CPP + +#include "tao/AnyTypeCode/Any_Dual_Impl_T.h" +#include "tao/AnyTypeCode/Any.h" +#include "tao/AnyTypeCode/Any_Unknown_IDL_Type.h" +#include "tao/AnyTypeCode/Marshal.h" +#include "tao/CORBA_String.h" +#include "tao/Environment.h" +#include "tao/SystemException.h" +#include "tao/CDR.h" +#include "tao/AnyTypeCode/TypeCode.h" + +#include "ace/CORBA_macros.h" +#include "ace/Auto_Ptr.h" +#include "ace/OS_Memory.h" + +#if !defined (__ACE_INLINE__) +# include "tao/AnyTypeCode/Any_Dual_Impl_T.inl" +#endif /* ! __ACE_INLINE__ */ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +template<typename T> +TAO::Any_Dual_Impl_T<T>::Any_Dual_Impl_T (_tao_destructor destructor, + CORBA::TypeCode_ptr tc, + T * const val) + : Any_Impl (destructor, + tc), + value_ (val) +{ +} + +template<typename T> void +TAO::Any_Dual_Impl_T<T>::value (const T & val) +{ + ACE_NEW (this->value_, + T (val)); +} + +template<typename T> +TAO::Any_Dual_Impl_T<T>::Any_Dual_Impl_T (_tao_destructor destructor, + CORBA::TypeCode_ptr tc, + const T & val) + : Any_Impl (destructor, + tc) +{ + this->value (val); +} + +template<typename T> +TAO::Any_Dual_Impl_T<T>::Any_Dual_Impl_T (CORBA::TypeCode_ptr tc) + : Any_Impl (0, + tc) +{ +} + +template<typename T> +TAO::Any_Dual_Impl_T<T>::~Any_Dual_Impl_T (void) +{ +} + +template<typename T> +void +TAO::Any_Dual_Impl_T<T>::insert (CORBA::Any & any, + _tao_destructor destructor, + CORBA::TypeCode_ptr tc, + T * const value) +{ + Any_Dual_Impl_T<T> *new_impl = 0; + ACE_NEW (new_impl, + Any_Dual_Impl_T (destructor, + tc, + value)); + any.replace (new_impl); +} + +template<typename T> +void +TAO::Any_Dual_Impl_T<T>::insert_copy (CORBA::Any & any, + _tao_destructor destructor, + CORBA::TypeCode_ptr tc, + const T & value) +{ + Any_Dual_Impl_T<T> *new_impl = 0; + ACE_NEW (new_impl, + Any_Dual_Impl_T (destructor, + tc, + value)); + any.replace (new_impl); +} + +template<typename T> +CORBA::Boolean +TAO::Any_Dual_Impl_T<T>::extract (const CORBA::Any & any, + _tao_destructor destructor, + CORBA::TypeCode_ptr tc, + const T *& _tao_elem) +{ + _tao_elem = 0; + + ACE_TRY_NEW_ENV + { + CORBA::TypeCode_ptr any_tc = any._tao_get_typecode (); + CORBA::Boolean _tao_equiv = any_tc->equivalent (tc + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (_tao_equiv == false) + { + return false; + } + + TAO::Any_Impl *impl = any.impl (); + + if (!impl->encoded ()) + { + TAO::Any_Dual_Impl_T<T> *narrow_impl = + dynamic_cast <TAO::Any_Dual_Impl_T<T> *> (impl); + + if (narrow_impl == 0) + { + return false; + } + + _tao_elem = narrow_impl->value_; + return true; + } + + T *empty_value = 0; + ACE_NEW_RETURN (empty_value, + T, + false); + TAO::Any_Dual_Impl_T<T> *replacement = 0; + ACE_NEW_RETURN (replacement, + TAO::Any_Dual_Impl_T<T> (destructor, + any_tc, + empty_value), + false); + + auto_ptr<TAO::Any_Dual_Impl_T<T> > replacement_safety (replacement); + + // We know this will work since the unencoded case is covered above. + TAO::Unknown_IDL_Type *unk = + dynamic_cast<TAO::Unknown_IDL_Type *> (impl); + + // We don't want the rd_ptr of unk to move, in case it is + // shared by another Any. This copies the state, not the buffer. + TAO_InputCDR for_reading (unk->_tao_get_cdr ()); + + CORBA::Boolean const good_decode = + replacement->demarshal_value (for_reading); + + if (good_decode) + { + _tao_elem = replacement->value_; + const_cast<CORBA::Any &> (any).replace (replacement); + replacement_safety.release (); + return true; + } + + // Duplicated by Any_Impl base class constructor. + ::CORBA::release (any_tc); + } + ACE_CATCHANY + { + } + ACE_ENDTRY; + + return false; +} + +template<typename T> +CORBA::Boolean +TAO::Any_Dual_Impl_T<T>::marshal_value (TAO_OutputCDR &cdr) +{ + return (cdr << *this->value_); +} + +template<typename T> +const void * +TAO::Any_Dual_Impl_T<T>::value (void) const +{ + return this->value_; +} + +template<typename T> +void +TAO::Any_Dual_Impl_T<T>::free_value (void) +{ + if (this->value_destructor_ != 0) + { + (*this->value_destructor_) (this->value_); + this->value_destructor_ = 0; + } + + ::CORBA::release (this->type_); + this->value_ = 0; +} + +template<typename T> +void +TAO::Any_Dual_Impl_T<T>::_tao_decode (TAO_InputCDR &cdr + ACE_ENV_ARG_DECL) +{ + if (! this->demarshal_value (cdr)) + { + ACE_THROW (CORBA::MARSHAL ()); + } +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +#endif /* TAO_ANY_DUAL_IMPL_T_CPP */ diff --git a/TAO/tao/AnyTypeCode/Any_Dual_Impl_T.h b/TAO/tao/AnyTypeCode/Any_Dual_Impl_T.h new file mode 100644 index 00000000000..e09cdad1f77 --- /dev/null +++ b/TAO/tao/AnyTypeCode/Any_Dual_Impl_T.h @@ -0,0 +1,97 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Any_Dual_Impl_T.h + * + * $Id$ + * + * @authors Carlos O'Ryan and Jeff Parsons + */ +//============================================================================= + + +#ifndef TAO_ANY_DUAL_IMPL_T_H +#define TAO_ANY_DUAL_IMPL_T_H + +#include /**/ "ace/pre.h" + +#include "tao/AnyTypeCode/Any_Impl.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + /** + * @class Any_Dual_Impl_T + * + * @brief Template Any class for IDL types with 2 modes of insertion + * + * Used for the IDL types that have copying and non-copying insertion, + * but which are not (de)marshaled as pointers - struct, union, sequence, + * and exception. + */ + template<typename T> + class Any_Dual_Impl_T : public Any_Impl + { + public: + Any_Dual_Impl_T (_tao_destructor destructor, + CORBA::TypeCode_ptr, + T * const); + Any_Dual_Impl_T (_tao_destructor destructor, + CORBA::TypeCode_ptr, + const T &); + Any_Dual_Impl_T (CORBA::TypeCode_ptr); + virtual ~Any_Dual_Impl_T (void); + + static void insert (CORBA::Any &, + _tao_destructor, + CORBA::TypeCode_ptr, + T * const); + static void insert_copy (CORBA::Any &, + _tao_destructor destructor, + CORBA::TypeCode_ptr, + const T &); + static CORBA::Boolean extract (const CORBA::Any &, + _tao_destructor, + CORBA::TypeCode_ptr, + const T *&); + + virtual CORBA::Boolean marshal_value (TAO_OutputCDR &); + CORBA::Boolean demarshal_value (TAO_InputCDR &); + virtual void _tao_decode (TAO_InputCDR & + ACE_ENV_ARG_DECL); + + virtual const void *value (void) const; + virtual void free_value (void); + + protected: + void value (const T &); + + T * value_; + }; +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +# include "tao/AnyTypeCode/Any_Dual_Impl_T.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "tao/AnyTypeCode/Any_Dual_Impl_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Any_Dual_Impl_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" + +#endif /* TAO_ANY_DUAL_IMPL_T_H */ + diff --git a/TAO/tao/AnyTypeCode/Any_Dual_Impl_T.inl b/TAO/tao/AnyTypeCode/Any_Dual_Impl_T.inl new file mode 100644 index 00000000000..f1fa29d7a4c --- /dev/null +++ b/TAO/tao/AnyTypeCode/Any_Dual_Impl_T.inl @@ -0,0 +1,16 @@ +// -*- C++ -*- +// +// $Id$ + + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +template<typename T> +ACE_INLINE +CORBA::Boolean +TAO::Any_Dual_Impl_T<T>::demarshal_value (TAO_InputCDR &cdr) +{ + return (cdr >> *this->value_); +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/Any_Impl.cpp b/TAO/tao/AnyTypeCode/Any_Impl.cpp new file mode 100644 index 00000000000..f00e5898d4d --- /dev/null +++ b/TAO/tao/AnyTypeCode/Any_Impl.cpp @@ -0,0 +1,140 @@ +// $Id$ + +#include "tao/AnyTypeCode/Any_Impl.h" +#include "tao/AnyTypeCode/TypeCode.h" +#include "tao/AnyTypeCode/Marshal.h" + +#include "tao/CORBA_String.h" +#include "tao/SystemException.h" + +#include "ace/Guard_T.h" + +ACE_RCSID (AnyTypeCode, + Any_Impl, + "$Id$") + + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +TAO::Any_Impl::Any_Impl (_tao_destructor destructor, + CORBA::TypeCode_ptr tc, + bool encoded) + : value_destructor_ (destructor) + , type_ (CORBA::TypeCode::_duplicate (tc)) + , encoded_ (encoded) + , refcount_ (1) +{ +} + +TAO::Any_Impl::~Any_Impl (void) +{ +} + +CORBA::Boolean +TAO::Any_Impl::marshal (TAO_OutputCDR &cdr) +{ + if ((cdr << this->type_) == 0) + { + return false; + } + + return this->marshal_value (cdr); +} + +void +TAO::Any_Impl::free_value (void) +{ + // We always have to do this. + ::CORBA::release (this->type_); +} + +CORBA::TypeCode_ptr +TAO::Any_Impl::type (void) const +{ + return CORBA::TypeCode::_duplicate (this->type_); +} + +CORBA::TypeCode_ptr +TAO::Any_Impl::_tao_get_typecode (void) const +{ + return this->type_; +} + +void +TAO::Any_Impl::type (CORBA::TypeCode_ptr tc) +{ + ::CORBA::release (this->type_); + this->type_ = CORBA::TypeCode::_duplicate (tc); +} + +int +TAO::Any_Impl::_tao_byte_order (void) const +{ + return TAO_ENCAP_BYTE_ORDER; +} + +void +TAO::Any_Impl::_tao_any_string_destructor (void *x) +{ + char *tmp = static_cast<char *> (x); + CORBA::string_free (tmp); +} + +void +TAO::Any_Impl::_tao_any_wstring_destructor (void *x) +{ + CORBA::WChar *tmp = static_cast<CORBA::WChar *> (x); + CORBA::wstring_free (tmp); +} + +void +TAO::Any_Impl::_add_ref (void) +{ + ++this->refcount_; +} + +void +TAO::Any_Impl::_remove_ref (void) +{ + const CORBA::ULong new_count = --this->refcount_; + + if (new_count != 0) + return; + + this->free_value (); + + delete this; +} + +void +TAO::Any_Impl::_tao_decode (TAO_InputCDR & + ACE_ENV_ARG_DECL) +{ + ACE_THROW (CORBA::NO_IMPLEMENT ()); +} + +CORBA::Boolean +TAO::Any_Impl::to_object (CORBA::Object_ptr &) const +{ + return false; +} + +CORBA::Boolean +TAO::Any_Impl::to_value (CORBA::ValueBase *&) const +{ + return false; +} + +CORBA::Boolean +TAO::Any_Impl::to_abstract_base (CORBA::AbstractBase_ptr &) const +{ + return false; +} + +bool +TAO::Any_Impl::encoded (void) const +{ + return this->encoded_; +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/Any_Impl.h b/TAO/tao/AnyTypeCode/Any_Impl.h new file mode 100644 index 00000000000..0e04ce527b5 --- /dev/null +++ b/TAO/tao/AnyTypeCode/Any_Impl.h @@ -0,0 +1,121 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Any_Impl.h + * + * $Id$ + * + * @author Carlos O'Ryan + * @author Jeff Parsons + */ +//============================================================================= + +#ifndef TAO_ANY_IMPL_H +#define TAO_ANY_IMPL_H + +#include /**/ "ace/pre.h" +#include "ace/CORBA_macros.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/AnyTypeCode/TAO_AnyTypeCode_Export.h" + +#include "tao/Basic_Types.h" +#include "tao/orbconf.h" + +#include "ace/Synch_Traits.h" +#include "ace/Null_Mutex.h" +#include "ace/Thread_Mutex.h" +#include "ace/Atomic_Op.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL +class ACE_Message_Block; +ACE_END_VERSIONED_NAMESPACE_DECL + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +class TAO_OutputCDR; +class TAO_InputCDR; + +namespace CORBA +{ + class TypeCode; + typedef TypeCode *TypeCode_ptr; + + class Object; + typedef Object *Object_ptr; + + class ValueBase; + class AbstractBase; + typedef AbstractBase *AbstractBase_ptr; + + class Environment; +} + +namespace TAO +{ + /** + * @class Any_Impl + * + * @brief Base class for the Any template subclasses. + * + * Contains common functionality and some pure virtual methods. + */ + class TAO_AnyTypeCode_Export Any_Impl + { + public: + /// Generated data types define a 'destructor' function that + /// correctly destroys an object stored in an Any. + typedef void (*_tao_destructor)(void *); + + CORBA::Boolean marshal (TAO_OutputCDR &); + virtual CORBA::Boolean marshal_value (TAO_OutputCDR &) = 0; + + virtual void free_value (void); + + CORBA::TypeCode_ptr type (void) const; + CORBA::TypeCode_ptr _tao_get_typecode (void) const; + void type (CORBA::TypeCode_ptr); + + virtual int _tao_byte_order (void) const; + + virtual void _add_ref (void); + virtual void _remove_ref (void); + + /// Used to release these CORBA basic types. + static void _tao_any_string_destructor (void *); + static void _tao_any_wstring_destructor (void *); + + virtual void _tao_decode (TAO_InputCDR & + ACE_ENV_ARG_DECL); + + virtual CORBA::Boolean to_object (CORBA::Object_ptr &) const; + virtual CORBA::Boolean to_value (CORBA::ValueBase *&) const; + virtual CORBA::Boolean to_abstract_base (CORBA::AbstractBase_ptr &) const; + + bool encoded (void) const; + + protected: + Any_Impl (_tao_destructor, + CORBA::TypeCode_ptr, + bool encoded = false); + virtual ~Any_Impl (void); + + TAO::Any_Impl::_tao_destructor value_destructor_; + CORBA::TypeCode_ptr type_; + bool encoded_; + + private: + /// Reference counter. + ACE_Atomic_Op<TAO_SYNCH_MUTEX, unsigned long> refcount_; + }; +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" + +#endif /* TAO_ANY_IMPL_H */ diff --git a/TAO/tao/AnyTypeCode/Any_Impl_T.cpp b/TAO/tao/AnyTypeCode/Any_Impl_T.cpp new file mode 100644 index 00000000000..4555bf32e9e --- /dev/null +++ b/TAO/tao/AnyTypeCode/Any_Impl_T.cpp @@ -0,0 +1,193 @@ +// $Id$ + +#ifndef TAO_ANY_IMPL_T_CPP +#define TAO_ANY_IMPL_T_CPP + +#include "tao/AnyTypeCode/Any_Impl_T.h" +#include "tao/AnyTypeCode/Any_Unknown_IDL_Type.h" +#include "tao/AnyTypeCode/Marshal.h" +#include "tao/CDR.h" +#include "tao/Environment.h" +#include "tao/SystemException.h" +#include "tao/AnyTypeCode/TypeCode.h" + +#include "ace/CORBA_macros.h" +#include "ace/Auto_Ptr.h" +#include "ace/OS_Memory.h" + +#if !defined (__ACE_INLINE__) +# include "tao/AnyTypeCode/Any_Impl_T.inl" +#endif /* ! __ACE_INLINE__ */ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +template<typename T> +TAO::Any_Impl_T<T>::Any_Impl_T (_tao_destructor destructor, + CORBA::TypeCode_ptr tc, + T * const val) + : Any_Impl (destructor, + tc), + value_ (val) +{ +} + +template<typename T> +TAO::Any_Impl_T<T>::~Any_Impl_T (void) +{ +} + +template<typename T> +void +TAO::Any_Impl_T<T>::insert (CORBA::Any & any, + _tao_destructor destructor, + CORBA::TypeCode_ptr tc, + T * const value) +{ + TAO::Any_Impl_T<T> *new_impl = 0; + ACE_NEW (new_impl, + TAO::Any_Impl_T<T> (destructor, + tc, + value)); + any.replace (new_impl); +} + +template<typename T> +CORBA::Boolean +TAO::Any_Impl_T<T>::extract (const CORBA::Any & any, + _tao_destructor destructor, + CORBA::TypeCode_ptr tc, + T *& _tao_elem) +{ + _tao_elem = 0; + + ACE_TRY_NEW_ENV + { + CORBA::TypeCode_ptr any_tc = any._tao_get_typecode (); + CORBA::Boolean _tao_equiv = any_tc->equivalent (tc + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (_tao_equiv == 0) + { + return false; + } + + TAO::Any_Impl *impl = any.impl (); + + if (!impl->encoded ()) + { + TAO::Any_Impl_T<T> *narrow_impl = + dynamic_cast <TAO::Any_Impl_T<T> *> (impl); + + if (narrow_impl == 0) + { + return false; + } + + _tao_elem = (T *) narrow_impl->value_; + return true; + } + + TAO::Any_Impl_T<T> *replacement = 0; + ACE_NEW_RETURN (replacement, + TAO::Any_Impl_T<T> (destructor, + any_tc, + 0), + false); + + auto_ptr<TAO::Any_Impl_T<T> > replacement_safety (replacement); + + // We know this will work since the unencoded case is covered above. + TAO::Unknown_IDL_Type *unk = + dynamic_cast<TAO::Unknown_IDL_Type *> (impl); + + // We don't want the rd_ptr of unk to move, in case it is + // shared by another Any. This copies the state, not the buffer. + TAO_InputCDR for_reading (unk->_tao_get_cdr ()); + + CORBA::Boolean const good_decode = + replacement->demarshal_value (for_reading); + + if (good_decode) + { + _tao_elem = const_cast<T *> (replacement->value_); + const_cast<CORBA::Any &> (any).replace (replacement); + replacement_safety.release (); + return true; + } + + // Duplicated by Any_Impl base class constructor. + ::CORBA::release (any_tc); + } + ACE_CATCHANY + { + } + ACE_ENDTRY; + + return 0; +} + +template<typename T> +CORBA::Boolean +TAO::Any_Impl_T<T>::to_object (CORBA::Object_ptr &) const +{ + return 0; +} + +template<typename T> +CORBA::Boolean +TAO::Any_Impl_T<T>::to_value (CORBA::ValueBase *&) const +{ + return 0; +} + +template<typename T> + +CORBA::Boolean +TAO::Any_Impl_T<T>::to_abstract_base (CORBA::AbstractBase_ptr &) const +{ + return 0; +} + +template<typename T> +CORBA::Boolean +TAO::Any_Impl_T<T>::marshal_value (TAO_OutputCDR &cdr) +{ + return (cdr << this->value_); +} + +template<typename T> +const void * +TAO::Any_Impl_T<T>::value (void) const +{ + return this->value_; +} + +template<typename T> +void +TAO::Any_Impl_T<T>::free_value (void) +{ + if (this->value_destructor_ != 0) + { + (*this->value_destructor_) (this->value_); + this->value_destructor_ = 0; + } + + ::CORBA::release (this->type_); + this->value_ = 0; +} + +template<typename T> +void +TAO::Any_Impl_T<T>::_tao_decode (TAO_InputCDR &cdr + ACE_ENV_ARG_DECL) +{ + if (! this->demarshal_value (cdr)) + { + ACE_THROW (CORBA::MARSHAL ()); + } +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +#endif /* TAO_ANY_IMPL_T_CPP */ diff --git a/TAO/tao/AnyTypeCode/Any_Impl_T.h b/TAO/tao/AnyTypeCode/Any_Impl_T.h new file mode 100644 index 00000000000..bddd912ecc9 --- /dev/null +++ b/TAO/tao/AnyTypeCode/Any_Impl_T.h @@ -0,0 +1,96 @@ +// This may look like C, but it's really -*- C++ -*- + +//============================================================================= +/** + * @file Any_Impl_T.h + * + * $Id$ + * + * @authors Carlos O'Ryan and Jeff Parsons + */ +//============================================================================= + + +#ifndef TAO_ANY_IMPL_T_H +#define TAO_ANY_IMPL_T_H + +#include /**/ "ace/pre.h" + +#include "tao/AnyTypeCode/Any_Impl.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace CORBA +{ + class Any; + class Environment; +} + +namespace TAO +{ + /** + * @class Any_Impl_T + * + * @brief Template Any class for pointer types. + * + * Used for interfaces and typecodes + */ + template<typename T> + class Any_Impl_T : public Any_Impl + { + public: + Any_Impl_T (_tao_destructor destructor, + CORBA::TypeCode_ptr, + T * const); + virtual ~Any_Impl_T (void); + + static void insert (CORBA::Any &, + _tao_destructor destructor, + CORBA::TypeCode_ptr, + T * const); + static CORBA::Boolean extract (const CORBA::Any &, + _tao_destructor, + CORBA::TypeCode_ptr, + T *&); + + virtual CORBA::Boolean to_object (CORBA::Object_ptr &) const; + virtual CORBA::Boolean to_value (CORBA::ValueBase *&) const; + virtual CORBA::Boolean to_abstract_base (CORBA::AbstractBase_ptr &) const; + + virtual CORBA::Boolean marshal_value (TAO_OutputCDR &); + CORBA::Boolean demarshal_value (TAO_InputCDR &); + virtual void _tao_decode (TAO_InputCDR & ACE_ENV_ARG_DECL); + virtual const void *value (void) const; + virtual void free_value (void); + + private: + T * value_; + }; +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +# include "tao/AnyTypeCode/Any_Impl_T.inl" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "tao/AnyTypeCode/Any_Impl_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Any_Impl_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" + +#endif /* TAO_ANY_IMPL_T_H */ diff --git a/TAO/tao/AnyTypeCode/Any_Impl_T.inl b/TAO/tao/AnyTypeCode/Any_Impl_T.inl new file mode 100644 index 00000000000..d459bc57e67 --- /dev/null +++ b/TAO/tao/AnyTypeCode/Any_Impl_T.inl @@ -0,0 +1,17 @@ +// -*- C++ -*- +// +// $Id$ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +// These three are overridden in generated code where appropriate. + +template<typename T> +ACE_INLINE +CORBA::Boolean +TAO::Any_Impl_T<T>::demarshal_value (TAO_InputCDR &cdr) +{ + return (cdr >> this->value_); +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/Any_Special_Impl_T.cpp b/TAO/tao/AnyTypeCode/Any_Special_Impl_T.cpp new file mode 100644 index 00000000000..adc32568b3f --- /dev/null +++ b/TAO/tao/AnyTypeCode/Any_Special_Impl_T.cpp @@ -0,0 +1,230 @@ +// $Id$ + +#ifndef TAO_ANY_SPECIAL_IMPL_T_CPP +#define TAO_ANY_SPECIAL_IMPL_T_CPP + +#include "tao/AnyTypeCode/Any_Special_Impl_T.h" +#include "tao/AnyTypeCode/Any_Unknown_IDL_Type.h" +#include "tao/AnyTypeCode/Marshal.h" +#include "tao/Environment.h" +#include "tao/AnyTypeCode/String_TypeCode_Traits.h" + +#include "ace/CORBA_macros.h" + +#if !defined (__ACE_INLINE__) +# include "tao/AnyTypeCode/Any_Special_Impl_T.inl" +#endif /* ! __ACE_INLINE__ */ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +template<typename T, typename from_T, typename to_T> +TAO::Any_Special_Impl_T<T, from_T, to_T>::Any_Special_Impl_T ( + _tao_destructor destructor, + CORBA::TypeCode_ptr tc, + T * const val, + CORBA::ULong bound + ) + : Any_Impl (destructor, + tc), + value_ (val), + bound_ (bound) +{ +} + +template<typename T, typename from_T, typename to_T> +TAO::Any_Special_Impl_T<T, from_T, to_T>::~Any_Special_Impl_T (void) +{ +} + +template<typename T, typename from_T, typename to_T> +void +TAO::Any_Special_Impl_T<T, from_T, to_T>::insert (CORBA::Any & any, + _tao_destructor destructor, + CORBA::TypeCode_ptr tc, + T * const value, + CORBA::ULong bound + ) +{ + CORBA::TypeCode_var bounded_tc; + + if (bound > 0) + { + ACE_DECLARE_NEW_CORBA_ENV; + CORBA::TCKind const kind = tc->kind (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + bounded_tc = + TAO::TypeCodeFactory::String_Traits<from_T>::create_typecode (kind, + bound); + } + else + { + bounded_tc = CORBA::TypeCode::_duplicate (tc); + } + + if (CORBA::is_nil (bounded_tc.in ())) + return; + + Any_Special_Impl_T<T, from_T, to_T> * new_impl; + ACE_NEW (new_impl, + Any_Special_Impl_T (destructor, + bounded_tc.in (), + value, + bound)); + + any.replace (new_impl); +} + +template<typename T, typename from_T, typename to_T> +CORBA::Boolean +TAO::Any_Special_Impl_T<T, from_T, to_T>::extract (const CORBA::Any & any, + _tao_destructor destructor, + CORBA::TypeCode_ptr tc, + const T *& _tao_elem, + CORBA::ULong bound + ) +{ + _tao_elem = 0; + + ACE_TRY_NEW_ENV + { + CORBA::TypeCode_ptr any_type = any._tao_get_typecode (); + CORBA::TypeCode_var unaliased_any_type = + TAO::unaliased_typecode (any_type + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::TCKind any_kind = + unaliased_any_type->kind (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::TCKind try_kind = tc->kind (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (any_kind != try_kind) + { + return false; + } + + CORBA::ULong length = + unaliased_any_type->length (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (length != bound) + { + return false; + } + + TAO::Any_Impl *impl = any.impl (); + + typedef TAO::Any_Special_Impl_T<T, from_T, to_T> + BOUNDED_TSTRING_ANY_IMPL; + + if (!impl->encoded ()) + { + TAO::Any_Special_Impl_T<T, from_T, to_T> *narrow_impl = + dynamic_cast <BOUNDED_TSTRING_ANY_IMPL *> (impl); + + if (narrow_impl == 0) + { + return false; + } + + _tao_elem = (T *) narrow_impl->value_; + return true; + } + + TAO::Any_Special_Impl_T<T, from_T, to_T> *replacement = 0; + ACE_NEW_RETURN (replacement, + BOUNDED_TSTRING_ANY_IMPL (destructor, + tc, + 0, + bound), + false); + + auto_ptr<TAO::Any_Special_Impl_T<T, from_T, to_T> > replacement_safety ( + replacement + ); + + // We know this will work since the unencoded case is covered above. + TAO::Unknown_IDL_Type *unk = + dynamic_cast<TAO::Unknown_IDL_Type *> (impl); + + // We don't want the rd_ptr of unk to move, in case it is + // shared by another Any. This copies the state, not the buffer. + TAO_InputCDR for_reading (unk->_tao_get_cdr ()); + + CORBA::Boolean const good_decode = + replacement->demarshal_value (for_reading); + + if (good_decode) + { + _tao_elem = replacement->value_; + const_cast<CORBA::Any &> (any).replace (replacement); + replacement_safety.release (); + return true; + } + + // Duplicated by Any_Impl base class constructor. + ::CORBA::release (tc); + } + ACE_CATCHANY + { + } + ACE_ENDTRY; + + return 0; +} + +template<typename T, typename from_T, typename to_T> +CORBA::Boolean +TAO::Any_Special_Impl_T<T, from_T, to_T>::marshal_value ( + TAO_OutputCDR &cdr + ) +{ + return (cdr << from_T (this->value_, this->bound_)); +} + +template<typename T, typename from_T, typename to_T> +const void * +TAO::Any_Special_Impl_T<T, from_T, to_T>::value (void) const +{ + return this->value_; +} + +template<typename T, typename from_T, typename to_T> +void +TAO::Any_Special_Impl_T<T, from_T, to_T>::free_value (void) +{ + if (this->value_destructor_ != 0) + { + (*this->value_destructor_) (this->value_); + this->value_destructor_ = 0; + } + + ::CORBA::release (this->type_); + this->value_ = 0; +} + +template<typename T, typename from_T, typename to_T> +void +TAO::Any_Special_Impl_T<T, from_T, to_T>::_tao_decode ( + TAO_InputCDR &cdr + ACE_ENV_ARG_DECL + ) +{ + if (this->value_destructor_ != 0) + { + (*this->value_destructor_) (this->value_); + this->value_ = 0; + } + + if (! this->demarshal_value (cdr)) + { + ACE_THROW (CORBA::MARSHAL ()); + } +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +#endif /* TAO_ANY_T_CPP */ diff --git a/TAO/tao/AnyTypeCode/Any_Special_Impl_T.h b/TAO/tao/AnyTypeCode/Any_Special_Impl_T.h new file mode 100644 index 00000000000..c166c9293ca --- /dev/null +++ b/TAO/tao/AnyTypeCode/Any_Special_Impl_T.h @@ -0,0 +1,86 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Any_Special_Impl_T.h + * + * $Id$ + * + * @author Carlos O'Ryan and Jeff Parsons + */ +//============================================================================= + + +#ifndef TAO_ANY_SPECIAL_IMPL_T_H +#define TAO_ANY_SPECIAL_IMPL_T_H + +#include /**/ "ace/pre.h" + +#include "tao/AnyTypeCode/Any_Impl.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + /** + * @class Any_Special_Impl_T + * + * @brief Template Any class for bounded IDL (w)strings. + */ + template<typename T, typename from_T, typename to_T> + class Any_Special_Impl_T : public Any_Impl + { + public: + Any_Special_Impl_T (_tao_destructor destructor, + CORBA::TypeCode_ptr, + T * const, + CORBA::ULong bound); + virtual ~Any_Special_Impl_T (void); + + static void insert (CORBA::Any &, + _tao_destructor destructor, + CORBA::TypeCode_ptr, + T * const, + CORBA::ULong bound); + static CORBA::Boolean extract (const CORBA::Any &, + _tao_destructor, + CORBA::TypeCode_ptr, + const T *&, + CORBA::ULong bound); + + virtual CORBA::Boolean marshal_value (TAO_OutputCDR &); + CORBA::Boolean demarshal_value (TAO_InputCDR &); + virtual void _tao_decode (TAO_InputCDR & + ACE_ENV_ARG_DECL_WITH_DEFAULTS); + + virtual const void *value (void) const; + virtual void free_value (void); + + private: + T * value_; + CORBA::ULong bound_; + }; +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +# include "tao/AnyTypeCode/Any_Special_Impl_T.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "tao/AnyTypeCode/Any_Special_Impl_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Any_Special_Impl_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" + +#endif /* TAO_ANY_SPECIAL_IMPL_T_H */ + diff --git a/TAO/tao/AnyTypeCode/Any_Special_Impl_T.inl b/TAO/tao/AnyTypeCode/Any_Special_Impl_T.inl new file mode 100644 index 00000000000..257a7681bd9 --- /dev/null +++ b/TAO/tao/AnyTypeCode/Any_Special_Impl_T.inl @@ -0,0 +1,17 @@ +// -*- C++ -*- +// +// $Id$ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +template<typename T, typename from_T, typename to_T> +ACE_INLINE +CORBA::Boolean +TAO::Any_Special_Impl_T<T, from_T, to_T>::demarshal_value ( + TAO_InputCDR &cdr + ) +{ + return (cdr >> to_T (this->value_, this->bound_)); +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/Any_SystemException.cpp b/TAO/tao/AnyTypeCode/Any_SystemException.cpp new file mode 100644 index 00000000000..015d7231ce5 --- /dev/null +++ b/TAO/tao/AnyTypeCode/Any_SystemException.cpp @@ -0,0 +1,210 @@ +// $Id$ + +#include "tao/AnyTypeCode/Any_SystemException.h" +#include "tao/AnyTypeCode/Any.h" +#include "tao/AnyTypeCode/Any_Unknown_IDL_Type.h" +#include "tao/AnyTypeCode/Marshal.h" +#include "tao/AnyTypeCode/TypeCode.h" + +#include "tao/CDR.h" +#include "tao/Exception.h" +#include "tao/Environment.h" +#include "tao/CORBA_String.h" +#include "tao/SystemException.h" + +#include "ace/Auto_Ptr.h" +#include "ace/CORBA_macros.h" +#include "ace/Auto_Ptr.h" + +ACE_RCSID (AnyTypeCode, + Any_SystemException, + "$Id$") + + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +TAO::Any_SystemException::Any_SystemException (_tao_destructor destructor, + CORBA::TypeCode_ptr tc, + CORBA::SystemException * const val) + : Any_Impl (destructor, + tc), + value_ (val) +{ +} + +TAO::Any_SystemException::Any_SystemException (_tao_destructor destructor, + CORBA::TypeCode_ptr tc, + const CORBA::SystemException & val) + : Any_Impl (destructor, + tc) +{ + this->value_ = + dynamic_cast <CORBA::SystemException *> (val._tao_duplicate ()); +} + +TAO::Any_SystemException::Any_SystemException (CORBA::TypeCode_ptr tc) + : Any_Impl (0, + tc) +{ +} + +TAO::Any_SystemException::~Any_SystemException (void) +{ +} + +void +TAO::Any_SystemException::insert (CORBA::Any & any, + _tao_destructor destructor, + CORBA::TypeCode_ptr tc, + CORBA::SystemException * const value) +{ + Any_SystemException *new_impl = 0; + ACE_NEW (new_impl, + Any_SystemException (destructor, + tc, + value)); + any.replace (new_impl); +} + +void +TAO::Any_SystemException::insert_copy (CORBA::Any & any, + _tao_destructor destructor, + CORBA::TypeCode_ptr tc, + const CORBA::SystemException & value) +{ + Any_SystemException *new_impl = 0; + ACE_NEW (new_impl, + Any_SystemException (destructor, + tc, + value)); + any.replace (new_impl); +} + +CORBA::Boolean +TAO::Any_SystemException::extract (const CORBA::Any & any, + _tao_destructor destructor, + CORBA::TypeCode_ptr tc, + const CORBA::SystemException *& _tao_elem, + TAO::excp_factory f) +{ + _tao_elem = 0; + + ACE_TRY_NEW_ENV + { + CORBA::TypeCode_ptr any_tc = any._tao_get_typecode (); + CORBA::Boolean const _tao_equiv = any_tc->equivalent (tc + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (_tao_equiv == false) + { + return false; + } + + TAO::Any_Impl *impl = any.impl (); + + if (!impl->encoded ()) + { + TAO::Any_SystemException *narrow_impl = + dynamic_cast <TAO::Any_SystemException *> (impl); + + if (narrow_impl == 0) + { + return false; + } + + _tao_elem = narrow_impl->value_; + return true; + } + + CORBA::SystemException *empty_value = (*f) (); + + TAO::Any_SystemException *replacement = 0; + ACE_NEW_RETURN (replacement, + TAO::Any_SystemException (destructor, + any_tc, + empty_value), + false); + + auto_ptr<TAO::Any_SystemException > replacement_safety (replacement); + + // We know this will work since the unencoded case is covered above. + TAO::Unknown_IDL_Type *unk = + dynamic_cast<TAO::Unknown_IDL_Type *> (impl); + + // We don't want the rd_ptr of unk to move, in case it is + // shared by another Any. This copies the state, not the buffer. + TAO_InputCDR for_reading (unk->_tao_get_cdr ()); + + CORBA::Boolean const good_decode = + replacement->demarshal_value (for_reading); + + if (good_decode) + { + _tao_elem = replacement->value_; + const_cast<CORBA::Any &> (any).replace (replacement); + replacement_safety.release (); + return true; + } + } + ACE_CATCHANY + { + } + ACE_ENDTRY; + + return 0; +} + +void +TAO::Any_SystemException::free_value (void) +{ + if (this->value_destructor_ != 0) + { + (*this->value_destructor_) (this->value_); + this->value_destructor_ = 0; + } + + this->value_ = 0; +} + +const void * +TAO::Any_SystemException::value (void) const +{ + return this->value_; +} + +CORBA::Boolean +TAO::Any_SystemException::marshal_value (TAO_OutputCDR &cdr) +{ + ACE_TRY_NEW_ENV + { + this->value_->_tao_encode (cdr + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + return true; + } + ACE_CATCHANY + { + } + ACE_ENDTRY; + return false; +} + +CORBA::Boolean +TAO::Any_SystemException::demarshal_value (TAO_InputCDR &cdr) +{ + ACE_TRY_NEW_ENV + { + this->value_->_tao_decode (cdr + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + return true; + } + ACE_CATCHANY + { + } + ACE_ENDTRY; + return false; +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/Any_SystemException.h b/TAO/tao/AnyTypeCode/Any_SystemException.h new file mode 100644 index 00000000000..a26dacfe1c1 --- /dev/null +++ b/TAO/tao/AnyTypeCode/Any_SystemException.h @@ -0,0 +1,87 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Any_SystemException.h + * + * $Id$ + * + * @authors Carlos O'Ryan and Jeff Parsons + */ +//============================================================================= +#ifndef TAO_ANY_SYSTEMEXCEPTION_H +#define TAO_ANY_SYSTEMEXCEPTION_H + +#include /**/ "ace/pre.h" + +#include "tao/AnyTypeCode/Any_Impl.h" +#include "tao/SystemException.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace CORBA +{ + class Any; +} + +namespace TAO +{ + /** + * @class Any_SystemException + * + * @brief Template Any class for IDL types with 2 modes of insertion + * + * Used for the IDL types that have copying and non-copying insertion, + * but which are not (de)marshaled as pointers - struct, union, sequence, + * and exception. + */ + class Any_SystemException : public Any_Impl + { + public: + Any_SystemException (_tao_destructor destructor, + CORBA::TypeCode_ptr, + CORBA::SystemException* const); + + Any_SystemException (_tao_destructor destructor, + CORBA::TypeCode_ptr, + const CORBA::SystemException &); + + Any_SystemException (CORBA::TypeCode_ptr); + + virtual ~Any_SystemException (void); + + static void insert (CORBA::Any &, + _tao_destructor, + CORBA::TypeCode_ptr, + CORBA::SystemException * const); + + static void insert_copy (CORBA::Any &, + _tao_destructor destructor, + CORBA::TypeCode_ptr, + const CORBA::SystemException &); + + static CORBA::Boolean extract (const CORBA::Any &, + _tao_destructor, + CORBA::TypeCode_ptr, + const CORBA::SystemException *&, + excp_factory f); + + virtual CORBA::Boolean marshal_value (TAO_OutputCDR &); + CORBA::Boolean demarshal_value (TAO_InputCDR &); + + virtual const void *value (void) const; + virtual void free_value (void); + + protected: + CORBA::SystemException *value_; + }; +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" +#endif /*TAO_ANY_SYSTEMEXCEPTION_H*/ diff --git a/TAO/tao/AnyTypeCode/Any_Unknown_IDL_Type.cpp b/TAO/tao/AnyTypeCode/Any_Unknown_IDL_Type.cpp new file mode 100644 index 00000000000..e9a050dde77 --- /dev/null +++ b/TAO/tao/AnyTypeCode/Any_Unknown_IDL_Type.cpp @@ -0,0 +1,311 @@ +// $Id$ + +#include "tao/AnyTypeCode/Any_Unknown_IDL_Type.h" +#include "tao/AnyTypeCode/Marshal.h" +#include "tao/AnyTypeCode/TypeCode.h" +#include "tao/Valuetype_Adapter.h" +#include "tao/ORB_Core.h" +#include "tao/SystemException.h" +#include "tao/CDR.h" + +#include "ace/Dynamic_Service.h" +#include "ace/OS_NS_string.h" + +ACE_RCSID (AnyTypeCode, + Any_Unknown_IDL_Type, + "$Id$") + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + + +ACE_Lock * +TAO::Unknown_IDL_Type::lock_i (void) +{ + static ACE_Auto_Ptr<ACE_Lock> lock_ (new ACE_Lock_Adapter<TAO_SYNCH_MUTEX>()); + return lock_.get (); +} + +TAO::Unknown_IDL_Type::Unknown_IDL_Type ( + CORBA::TypeCode_ptr tc, + TAO_InputCDR &cdr + ) + : TAO::Any_Impl (0, tc, true) + , cdr_ (static_cast<ACE_Message_Block*>(0), lock_i ()) +{ + ACE_TRY_NEW_ENV + { + this->_tao_decode (cdr ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCH (CORBA::Exception, ex) + { + } + ACE_ENDTRY; +} + +TAO::Unknown_IDL_Type::Unknown_IDL_Type ( + CORBA::TypeCode_ptr tc + ) + : TAO::Any_Impl (0, tc, true) + , cdr_ (static_cast<ACE_Message_Block*>(0), lock_i ()) +{ +} + +TAO::Unknown_IDL_Type::~Unknown_IDL_Type (void) +{ +} + +CORBA::Boolean +TAO::Unknown_IDL_Type::marshal_value (TAO_OutputCDR &cdr) +{ + ACE_TRY_NEW_ENV + { + // We don't want the rd_ptr to move, in case we are shared by + // another Any, so we use this to copy the state, not the buffer. + TAO_InputCDR for_reading (this->cdr_); + + TAO::traverse_status status = + TAO_Marshal_Object::perform_append (this->type_, + &for_reading, + &cdr + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (status != TAO::TRAVERSE_CONTINUE) + { + return false; + } + } + ACE_CATCH (CORBA::Exception, ex) + { + return false; + } + ACE_ENDTRY; + + return true; +} + +const void * +TAO::Unknown_IDL_Type::value (void) const +{ + return this->cdr_.start (); +} + +void +TAO::Unknown_IDL_Type::free_value (void) +{ + ::CORBA::release (this->type_); +} + +TAO_InputCDR & +TAO::Unknown_IDL_Type::_tao_get_cdr (void) +{ + return this->cdr_; +} + +int +TAO::Unknown_IDL_Type::_tao_byte_order (void) const +{ + return this->cdr_.byte_order (); +} +void +TAO::Unknown_IDL_Type::_tao_decode (TAO_InputCDR &cdr + ACE_ENV_ARG_DECL) +{ + // @@ (JP) The following code depends on the fact that + // TAO_InputCDR does not contain chained message blocks, + // otherwise <begin> and <end> could be part of + // different buffers! + + // This will be the start of a new message block. + char *begin = cdr.rd_ptr (); + + // Skip over the next argument. + TAO::traverse_status status = + TAO_Marshal_Object::perform_skip (this->type_, + &cdr + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (status != TAO::TRAVERSE_CONTINUE) + { + ACE_THROW (CORBA::MARSHAL ()); + } + + // This will be the end of the new message block. + char *end = cdr.rd_ptr (); + + // The ACE_CDR::mb_align() call can shift the rd_ptr by up to + // ACE_CDR::MAX_ALIGNMENT - 1 bytes. Similarly, the offset adjustment + // can move the rd_ptr by up to the same amount. We accommodate + // this by including 2 * ACE_CDR::MAX_ALIGNMENT bytes of additional + // space in the message block. + size_t const size = end - begin; + + ACE_Message_Block new_mb (size + 2 * ACE_CDR::MAX_ALIGNMENT); + + ACE_CDR::mb_align (&new_mb); + ptrdiff_t offset = ptrdiff_t (begin) % ACE_CDR::MAX_ALIGNMENT; + + if (offset < 0) + { + offset += ACE_CDR::MAX_ALIGNMENT; + } + + new_mb.rd_ptr (offset); + new_mb.wr_ptr (offset + size); + + ACE_OS::memcpy (new_mb.rd_ptr (), + begin, + size); + + this->cdr_.reset (&new_mb, cdr.byte_order ()); + this->cdr_.char_translator (cdr.char_translator ()); + this->cdr_.wchar_translator (cdr.wchar_translator ()); + + // Take over the GIOP version, the input cdr can have a different + // version then our current GIOP version. + ACE_CDR::Octet major_version; + ACE_CDR::Octet minor_version; + cdr.get_version (major_version, minor_version); + this->cdr_.set_version (major_version, minor_version); +} + +CORBA::Boolean +TAO::Unknown_IDL_Type::to_object (CORBA::Object_ptr &obj) const +{ + ACE_TRY_NEW_ENV + { + CORBA::ULong kind = + this->type_->kind (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::TypeCode_var tcvar = + CORBA::TypeCode::_duplicate (this->type_); + + while (kind == CORBA::tk_alias) + { + tcvar = tcvar->content_type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + kind = tcvar->kind (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + + if (kind != CORBA::tk_objref) + { + return 0; + } + + return this->cdr_ >> obj; + } + ACE_CATCH (CORBA::Exception, ex) + { + } + ACE_ENDTRY; + + return 0; +} + +CORBA::Boolean +TAO::Unknown_IDL_Type::to_value (CORBA::ValueBase *&val) const +{ + ACE_TRY_NEW_ENV + { + CORBA::ULong kind = + this->type_->kind (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::TypeCode_var tcvar = + CORBA::TypeCode::_duplicate (this->type_); + + while (kind == CORBA::tk_alias) + { + tcvar = tcvar->content_type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + kind = tcvar->kind (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + + if (kind != CORBA::tk_value) + { + return 0; + } + + TAO_ORB_Core *orb_core = this->cdr_.orb_core (); + if (orb_core == 0) + { + orb_core = TAO_ORB_Core_instance (); + + if (TAO_debug_level > 0) + { + ACE_DEBUG ((LM_WARNING, + "TAO (%P|%t) WARNING: extracting " + "valuetype using default ORB_Core\n")); + } + } + + TAO_Valuetype_Adapter *adapter = orb_core->valuetype_adapter(); + return adapter->stream_to_value (this->cdr_, val); + } + ACE_CATCH (CORBA::Exception, ex) + { + } + ACE_ENDTRY; + + return 0; +} + +CORBA::Boolean +TAO::Unknown_IDL_Type::to_abstract_base (CORBA::AbstractBase_ptr &obj) const +{ + ACE_TRY_NEW_ENV + { + CORBA::ULong kind = + this->type_->kind (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::TypeCode_var tcvar = + CORBA::TypeCode::_duplicate (this->type_); + + while (kind == CORBA::tk_alias) + { + tcvar = tcvar->content_type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + kind = tcvar->kind (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + + if (kind != CORBA::tk_value) + { + return 0; + } + + TAO_ORB_Core *orb_core = this->cdr_.orb_core (); + if (orb_core == 0) + { + orb_core = TAO_ORB_Core_instance (); + + if (TAO_debug_level > 0) + { + ACE_DEBUG ((LM_WARNING, + "TAO (%P|%t) WARNING: extracting " + "valuetype using default ORB_Core\n")); + } + } + + TAO_Valuetype_Adapter *adapter = orb_core->valuetype_adapter(); + return adapter->stream_to_abstract_base (this->cdr_, + obj); + } + ACE_CATCH (CORBA::Exception, ex) + { + } + ACE_ENDTRY; + + return 0; +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/Any_Unknown_IDL_Type.h b/TAO/tao/AnyTypeCode/Any_Unknown_IDL_Type.h new file mode 100644 index 00000000000..063fb77aeba --- /dev/null +++ b/TAO/tao/AnyTypeCode/Any_Unknown_IDL_Type.h @@ -0,0 +1,89 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Any_Unknown_IDL_Type.h + * + * $Id$ + * + * @author Carlos O'Ryan + * @author Jeff Parsons + */ +//============================================================================= + +#ifndef TAO_ANY_UNKNOWN_IDL_TYPE_H +#define TAO_ANY_UNKNOWN_IDL_TYPE_H + +#include /**/ "ace/pre.h" + +#include "tao/AnyTypeCode/Any_Impl.h" +#include "tao/CDR.h" + +#include "ace/Auto_Ptr.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + /** + * @class Unknown_IDL_Type + * + * @brief CDR-based Any impl class. + * + * Used when demarshaling an Any, and with DII/DSI, and Dynamic Anys. + */ + class TAO_AnyTypeCode_Export Unknown_IDL_Type : public Any_Impl + { + public: + Unknown_IDL_Type (CORBA::TypeCode_ptr, + TAO_InputCDR &cdr); + + Unknown_IDL_Type (CORBA::TypeCode_ptr); + + virtual ~Unknown_IDL_Type (void); + + virtual CORBA::Boolean marshal_value (TAO_OutputCDR &); + virtual const void *value (void) const; + virtual void free_value (void); + + virtual TAO_InputCDR &_tao_get_cdr (void); + virtual int _tao_byte_order (void) const; + + virtual void _tao_decode (TAO_InputCDR & + ACE_ENV_ARG_DECL); + + virtual CORBA::Boolean to_object (CORBA::Object_ptr &) const; + virtual CORBA::Boolean to_value (CORBA::ValueBase *&) const; + virtual CORBA::Boolean to_abstract_base (CORBA::AbstractBase_ptr &) const; + + private: + // We make the lock global, so that it won't be deleted when shared. + // For instance, see Any_Basic_Impl::extract() which copies the insides + // from an Unknown_IDL_Type to an Any_Basic_Impl. + + // [Iliyan] However, having a global static makes this a subject + // to the whim of the specific compiler implentation. It is the + // one deciding the order in which our instance is initialized and + // destroyed and that is boundto be a problem + // somewhere. Typically, it becomes a problem when a code that + // depends on that instance finds that the runtime has already + // destroyed it. The scenario plays allmost always in the process + // shutdown code, after main() exits, having to debug which is a + // lot of fun :) ... Bottom line, use a static function, which + // encapsulates a local static initializer, guaranteed to be + // initialized at the first invocation. + static ACE_Lock *lock_i (void); + + mutable TAO_InputCDR cdr_; + }; +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" + +#endif /* TAO_ANY_UNKNOWN_IDL_TYPE_H */ diff --git a/TAO/tao/AnyTypeCode/Bounds.pidl b/TAO/tao/AnyTypeCode/Bounds.pidl new file mode 100644 index 00000000000..f0155c854ab --- /dev/null +++ b/TAO/tao/AnyTypeCode/Bounds.pidl @@ -0,0 +1,45 @@ +/** + * @file Bounds.pidl + * + * $Id$ + * + * @brief Pre-compiled IDL source for the CORBA::Bounds + * exception. + * + * This file is used to generate BoundsC.{h,inl,cpp}, using the + * following command: + * + * tao_idl + * -o orig -Ge 1 -GA -Sci + * -Wb,export_macro=TAO_Export + * -Wb,export_include=TAO_Export.h + * -Wb,pre_include="ace/pre.h" + * -Wb,post_include="ace/post.h" + * -Wb,versioning_begin=TAO_BEGIN_VERSIONED_NAMESPACE_DECL + * -Wb,versioning_end=TAO_END_VERSIONED_NAMESPACE_DECL + * Bounds.pidl + * + * and then: + * + * cp orig/BoundsC.{h,cpp} . + * + */ +#ifndef TAO_CORBA_BOUNDS_PIDL +#define TAO_CORBA_BOUNDS_PIDL + +#pragma prefix "omg.org" + +module CORBA +{ + /** + * @exception Bounds + * + * @brief UserException for NVList::item() + * + * This exception is thrown on attempts to access 'out of bounds' + * items in an NVList. + */ + exception Bounds {}; +}; + +#endif /* TAO_CORBA_BOUNDS_PIDL */ diff --git a/TAO/tao/AnyTypeCode/DomainA.cpp b/TAO/tao/AnyTypeCode/DomainA.cpp new file mode 100644 index 00000000000..6f6db000bc2 --- /dev/null +++ b/TAO/tao/AnyTypeCode/DomainA.cpp @@ -0,0 +1,300 @@ +// -*- C++ -*- +// +// $Id$ + +// **** Code generated by the The ACE ORB (TAO) IDL Compiler **** +// TAO and the TAO IDL Compiler have been developed by: +// Center for Distributed Object Computing +// Washington University +// St. Louis, MO +// USA +// http://www.cs.wustl.edu/~schmidt/doc-center.html +// and +// Distributed Object Computing Laboratory +// University of California at Irvine +// Irvine, CA +// USA +// http://doc.ece.uci.edu/ +// and +// Institute for Software Integrated Systems +// Vanderbilt University +// Nashville, TN +// USA +// http://www.isis.vanderbilt.edu/ +// +// Information about TAO is available at: +// http://www.cs.wustl.edu/~schmidt/TAO.html + +#include "tao/AnyTypeCode/DomainA.h" +#include "tao/AnyTypeCode/Null_RefCount_Policy.h" +#include "tao/AnyTypeCode/TypeCode_Constants.h" +#include "tao/AnyTypeCode/Alias_TypeCode_Static.h" +#include "tao/AnyTypeCode/Objref_TypeCode_Static.h" +#include "tao/AnyTypeCode/Sequence_TypeCode_Static.h" +#include "tao/CDR.h" +#include "tao/AnyTypeCode/Any.h" +#include "tao/AnyTypeCode/Any_Impl_T.h" +#include "tao/AnyTypeCode/Any_Dual_Impl_T.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +// TAO_IDL - Generated from +// be\be_visitor_typecode/objref_typecode.cpp:76 + +static TAO::TypeCode::Objref<char const *, + TAO::Null_RefCount_Policy> + _tao_tc_CORBA_DomainManager ( + CORBA::tk_objref, + "IDL:omg.org/CORBA/DomainManager:1.0", + "DomainManager"); + +namespace CORBA +{ + ::CORBA::TypeCode_ptr const _tc_DomainManager = + &_tao_tc_CORBA_DomainManager; +} + + + +// TAO_IDL - Generated from +// be\be_visitor_typecode/objref_typecode.cpp:76 + +static TAO::TypeCode::Objref<char const *, + TAO::Null_RefCount_Policy> + _tao_tc_CORBA_ConstructionPolicy ( + CORBA::tk_objref, + "IDL:omg.org/CORBA/ConstructionPolicy:1.0", + "ConstructionPolicy"); + +namespace CORBA +{ + ::CORBA::TypeCode_ptr const _tc_ConstructionPolicy = + &_tao_tc_CORBA_ConstructionPolicy; +} + + + +// TAO_IDL - Generated from +// be\be_visitor_typecode/alias_typecode.cpp:50 + + + +// TAO_IDL - Generated from +// be\be_visitor_typecode/typecode_defn.cpp:937 + + +#ifndef _TAO_TYPECODE_CORBA_DomainManagerList_GUARD +#define _TAO_TYPECODE_CORBA_DomainManagerList_GUARD +namespace TAO +{ + namespace TypeCode + { + TAO::TypeCode::Sequence< ::CORBA::TypeCode_ptr const *, + TAO::Null_RefCount_Policy> + CORBA_DomainManagerList_0 ( + CORBA::tk_sequence, + &CORBA::_tc_DomainManager, + 0U); + + ::CORBA::TypeCode_ptr const tc_CORBA_DomainManagerList_0 = + &CORBA_DomainManagerList_0; + + } +} + + +#endif /* _TAO_TYPECODE_CORBA_DomainManagerList_GUARD */ + +static TAO::TypeCode::Alias<char const *, + CORBA::TypeCode_ptr const *, + TAO::Null_RefCount_Policy> + _tao_tc_CORBA_DomainManagerList ( + CORBA::tk_alias, + "IDL:omg.org/CORBA/DomainManagerList:1.0", + "DomainManagerList", + &TAO::TypeCode::tc_CORBA_DomainManagerList_0); + +namespace CORBA +{ + ::CORBA::TypeCode_ptr const _tc_DomainManagerList = + &_tao_tc_CORBA_DomainManagerList; +} + + + +// TAO_IDL - Generated from +// be\be_visitor_interface/any_op_cs.cpp:50 + +namespace TAO +{ + template<> + CORBA::Boolean + Any_Impl_T<CORBA::DomainManager>::to_object ( + CORBA::Object_ptr &_tao_elem + ) const + { + _tao_elem = CORBA::Object::_duplicate (this->value_); + return true; + } +} + +// Copying insertion. +void +operator<<= ( + CORBA::Any &_tao_any, + CORBA::DomainManager_ptr _tao_elem + ) +{ + CORBA::DomainManager_ptr _tao_objptr = + CORBA::DomainManager::_duplicate (_tao_elem); + _tao_any <<= &_tao_objptr; +} + +// Non-copying insertion. +void +operator<<= ( + CORBA::Any &_tao_any, + CORBA::DomainManager_ptr *_tao_elem + ) +{ + TAO::Any_Impl_T<CORBA::DomainManager>::insert ( + _tao_any, + CORBA::DomainManager::_tao_any_destructor, + CORBA::_tc_DomainManager, + *_tao_elem + ); +} + +CORBA::Boolean +operator>>= ( + const CORBA::Any &_tao_any, + CORBA::DomainManager_ptr &_tao_elem + ) +{ + return + TAO::Any_Impl_T<CORBA::DomainManager>::extract ( + _tao_any, + CORBA::DomainManager::_tao_any_destructor, + CORBA::_tc_DomainManager, + _tao_elem + ); +} + +// TAO_IDL - Generated from +// be\be_visitor_interface/any_op_cs.cpp:50 + +namespace TAO +{ + template<> + CORBA::Boolean + Any_Impl_T<CORBA::ConstructionPolicy>::to_object ( + CORBA::Object_ptr &_tao_elem + ) const + { + _tao_elem = CORBA::Object::_duplicate (this->value_); + return true; + } +} + +// Copying insertion. +void +operator<<= ( + CORBA::Any &_tao_any, + CORBA::ConstructionPolicy_ptr _tao_elem + ) +{ + CORBA::ConstructionPolicy_ptr _tao_objptr = + CORBA::ConstructionPolicy::_duplicate (_tao_elem); + _tao_any <<= &_tao_objptr; +} + +// Non-copying insertion. +void +operator<<= ( + CORBA::Any &_tao_any, + CORBA::ConstructionPolicy_ptr *_tao_elem + ) +{ + TAO::Any_Impl_T<CORBA::ConstructionPolicy>::insert ( + _tao_any, + CORBA::ConstructionPolicy::_tao_any_destructor, + CORBA::_tc_ConstructionPolicy, + *_tao_elem + ); +} + +CORBA::Boolean +operator>>= ( + const CORBA::Any &_tao_any, + CORBA::ConstructionPolicy_ptr &_tao_elem + ) +{ + return + TAO::Any_Impl_T<CORBA::ConstructionPolicy>::extract ( + _tao_any, + CORBA::ConstructionPolicy::_tao_any_destructor, + CORBA::_tc_ConstructionPolicy, + _tao_elem + ); +} + +// TAO_IDL - Generated from +// be\be_visitor_sequence/any_op_cs.cpp:54 + + +// Copying insertion. +void operator<<= ( + CORBA::Any &_tao_any, + const CORBA::DomainManagerList &_tao_elem + ) +{ + TAO::Any_Dual_Impl_T<CORBA::DomainManagerList>::insert_copy ( + _tao_any, + CORBA::DomainManagerList::_tao_any_destructor, + TAO::TypeCode::tc_CORBA_DomainManagerList_0, + _tao_elem + ); +} + +// Non-copying insertion. +void operator<<= ( + CORBA::Any &_tao_any, + CORBA::DomainManagerList *_tao_elem + ) +{ + TAO::Any_Dual_Impl_T<CORBA::DomainManagerList>::insert ( + _tao_any, + CORBA::DomainManagerList::_tao_any_destructor, + TAO::TypeCode::tc_CORBA_DomainManagerList_0, + _tao_elem + ); +} + +// Extraction to non-const pointer (deprecated). +CORBA::Boolean operator>>= ( + const CORBA::Any &_tao_any, + CORBA::DomainManagerList *&_tao_elem + ) +{ + return _tao_any >>= const_cast< + const CORBA::DomainManagerList *&> ( + _tao_elem + ); +} + +// Extraction to const pointer. +CORBA::Boolean operator>>= ( + const CORBA::Any &_tao_any, + const CORBA::DomainManagerList *&_tao_elem + ) +{ + return + TAO::Any_Dual_Impl_T<CORBA::DomainManagerList>::extract ( + _tao_any, + CORBA::DomainManagerList::_tao_any_destructor, + TAO::TypeCode::tc_CORBA_DomainManagerList_0, + _tao_elem + ); +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/DomainA.h b/TAO/tao/AnyTypeCode/DomainA.h new file mode 100644 index 00000000000..72c5b0f95ac --- /dev/null +++ b/TAO/tao/AnyTypeCode/DomainA.h @@ -0,0 +1,136 @@ +// -*- C++ -*- +// +// $Id$ + +// **** Code generated by the The ACE ORB (TAO) IDL Compiler **** +// TAO and the TAO IDL Compiler have been developed by: +// Center for Distributed Object Computing +// Washington University +// St. Louis, MO +// USA +// http://www.cs.wustl.edu/~schmidt/doc-center.html +// and +// Distributed Object Computing Laboratory +// University of California at Irvine +// Irvine, CA +// USA +// http://doc.ece.uci.edu/ +// and +// Institute for Software Integrated Systems +// Vanderbilt University +// Nashville, TN +// USA +// http://www.isis.vanderbilt.edu/ +// +// Information about TAO is available at: +// http://www.cs.wustl.edu/~schmidt/TAO.html + +// TAO_IDL - Generated from +// be\be_codegen.cpp:153 + +#ifndef _TAO_IDL_ORIG_DOMAINA_H_ +#define _TAO_IDL_ORIG_DOMAINA_H_ + +#include /**/ "ace/pre.h" + + +#include "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/AnyTypeCode/TAO_AnyTypeCode_Export.h" +#include "tao/AnyTypeCode/AnyTypeCode_methods.h" +#include "tao/DomainC.h" + +#if defined (TAO_EXPORT_MACRO) +#undef TAO_EXPORT_MACRO +#endif +#define TAO_EXPORT_MACRO TAO_AnyTypeCode_Export + +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +#if defined (__BORLANDC__) +#pragma option push -w-rvl -w-rch -w-ccc -w-inl +#endif /* __BORLANDC__ */ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +// TAO_IDL - Generated from +// be\be_visitor_root/root_ch.cpp:62 + +namespace TAO +{ + class Collocation_Proxy_Broker; + template<typename T> class Narrow_Utils; +} + +// TAO_IDL - Generated from +// be\be_visitor_module/module_ch.cpp:48 + +namespace CORBA +{ + // TAO_IDL - Generated from + // be\be_visitor_typecode/typecode_decl.cpp:44 + + extern TAO_AnyTypeCode_Export ::CORBA::TypeCode_ptr const _tc_DomainManager; + + // TAO_IDL - Generated from + // be\be_visitor_typecode/typecode_decl.cpp:44 + + extern TAO_AnyTypeCode_Export ::CORBA::TypeCode_ptr const _tc_ConstructionPolicy; + + // TAO_IDL - Generated from + // be\be_visitor_typecode/typecode_decl.cpp:44 + + extern TAO_AnyTypeCode_Export ::CORBA::TypeCode_ptr const _tc_DomainManagerList; + +// TAO_IDL - Generated from +// be\be_visitor_module/module_ch.cpp:66 + +} // module CORBA + +// TAO_IDL - Generated from +// be\be_visitor_interface/any_op_ch.cpp:52 + +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, CORBA::DomainManager_ptr); // copying +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, CORBA::DomainManager_ptr *); // non-copying +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any &, CORBA::DomainManager_ptr &); + +// TAO_IDL - Generated from +// be\be_visitor_interface/any_op_ch.cpp:52 + +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, CORBA::ConstructionPolicy_ptr); // copying +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, CORBA::ConstructionPolicy_ptr *); // non-copying +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any &, CORBA::ConstructionPolicy_ptr &); + +// TAO_IDL - Generated from +// be\be_visitor_sequence/any_op_ch.cpp:52 + +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, const CORBA::DomainManagerList &); // copying version +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, CORBA::DomainManagerList*); // noncopying version +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any &, CORBA::DomainManagerList *&); // deprecated +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any &, const CORBA::DomainManagerList *&); + +// TAO_IDL - Generated from +// be\be_codegen.cpp:955 + +TAO_END_VERSIONED_NAMESPACE_DECL + +#if defined(_MSC_VER) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#if defined (__BORLANDC__) +#pragma option pop +#endif /* __BORLANDC__ */ + +#include /**/ "ace/post.h" + +#endif /* ifndef */ + + diff --git a/TAO/tao/AnyTypeCode/Dynamic.pidl b/TAO/tao/AnyTypeCode/Dynamic.pidl new file mode 100644 index 00000000000..48bd24f4971 --- /dev/null +++ b/TAO/tao/AnyTypeCode/Dynamic.pidl @@ -0,0 +1,52 @@ +// -*- IDL -*- + +// ================================================================ +/** + * @file Dynamic.pidl + * + * $Id$ + * + * This file was used to generate the code in DynamicC.* The command + * used to generate code is: + * + * tao_idl + * -o orig -Ge 1 -GA -SS -Sci + * -Wb,export_macro=TAO_Export + * -Wb,export_include="tao/TAO_Export.h" + * -Wb,pre_include="ace/pre.h" + * -Wb,post_include="ace/post.h" + * -Wb,versioning_begin=TAO_BEGIN_VERSIONED_NAMESPACE_DECL + * -Wb,versioning_end=TAO_END_VERSIONED_NAMESPACE_DECL + * Dynamic.pidl + * + */ +// ================================================================ + +// File: Dynamic.idl +// Used primarily for Interceptors + +#include "tao/AnyTypeCode/Dynamic_Parameter.pidl" +#include "tao/StringSeq.pidl" + +#ifndef _DYNAMIC_IDL_ +#define _DYNAMIC_IDL_ + +module CORBA +{ + interface TypeCode; +}; + +module Dynamic +{ + typeprefix Dynamic "omg.org"; + + typedef sequence<Parameter> ParameterList; + + typedef CORBA::StringSeq ContextList; + + typedef sequence<CORBA::TypeCode> ExceptionList; + + typedef CORBA::StringSeq RequestContext; +}; + +#endif // _DYNAMIC_IDL_ diff --git a/TAO/tao/AnyTypeCode/DynamicA.cpp b/TAO/tao/AnyTypeCode/DynamicA.cpp new file mode 100644 index 00000000000..4f17ea24008 --- /dev/null +++ b/TAO/tao/AnyTypeCode/DynamicA.cpp @@ -0,0 +1,291 @@ +// -*- C++ -*- +// +// $Id$ + +// **** Code generated by the The ACE ORB (TAO) IDL Compiler **** +// TAO and the TAO IDL Compiler have been developed by: +// Center for Distributed Object Computing +// Washington University +// St. Louis, MO +// USA +// http://www.cs.wustl.edu/~schmidt/doc-center.html +// and +// Distributed Object Computing Laboratory +// University of California at Irvine +// Irvine, CA +// USA +// http://doc.ece.uci.edu/ +// and +// Institute for Software Integrated Systems +// Vanderbilt University +// Nashville, TN +// USA +// http://www.isis.vanderbilt.edu/ +// +// Information about TAO is available at: +// http://www.cs.wustl.edu/~schmidt/TAO.html + +#include "tao/AnyTypeCode/DynamicA.h" +#include "tao/AnyTypeCode/Null_RefCount_Policy.h" +#include "tao/AnyTypeCode/TypeCode_Constants.h" +#include "tao/AnyTypeCode/Alias_TypeCode_Static.h" +#include "tao/AnyTypeCode/Sequence_TypeCode_Static.h" +#include "tao/AnyTypeCode/String_TypeCode_Static.h" +#include "tao/CDR.h" +#include "tao/AnyTypeCode/Any.h" +#include "tao/AnyTypeCode/Any_Dual_Impl_T.h" + +#include "tao/AnyTypeCode/StringSeqA.h" +#include "tao/AnyTypeCode/Dynamic_ParameterA.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +#ifndef _TAO_TYPECODE_Dynamic_ParameterList_GUARD +#define _TAO_TYPECODE_Dynamic_ParameterList_GUARD +namespace TAO +{ + namespace TypeCode + { + TAO::TypeCode::Sequence< ::CORBA::TypeCode_ptr const *, + TAO::Null_RefCount_Policy> + Dynamic_ParameterList_0 ( + CORBA::tk_sequence, + &Dynamic::_tc_Parameter, + 0U); + + ::CORBA::TypeCode_ptr const tc_Dynamic_ParameterList_0 = + &Dynamic_ParameterList_0; + + } +} + + +#endif /* _TAO_TYPECODE_Dynamic_ParameterList_GUARD */ + +static TAO::TypeCode::Alias<char const *, + CORBA::TypeCode_ptr const *, + TAO::Null_RefCount_Policy> + _tao_tc_Dynamic_ParameterList ( + CORBA::tk_alias, + "IDL:omg.org/Dynamic/ParameterList:1.0", + "ParameterList", + &TAO::TypeCode::tc_Dynamic_ParameterList_0); + +namespace Dynamic +{ + ::CORBA::TypeCode_ptr const _tc_ParameterList = + &_tao_tc_Dynamic_ParameterList; +} + +// TAO_IDL - Generated from +// be\be_visitor_typecode/alias_typecode.cpp:50 + +static TAO::TypeCode::Alias<char const *, + CORBA::TypeCode_ptr const *, + TAO::Null_RefCount_Policy> + _tao_tc_Dynamic_ContextList ( + CORBA::tk_alias, + "IDL:omg.org/Dynamic/ContextList:1.0", + "ContextList", + &CORBA::_tc_StringSeq); + +namespace Dynamic +{ + ::CORBA::TypeCode_ptr const _tc_ContextList = + &_tao_tc_Dynamic_ContextList; +} + + + +// TAO_IDL - Generated from +// be\be_visitor_typecode/alias_typecode.cpp:50 + + + +// TAO_IDL - Generated from +// be\be_visitor_typecode/typecode_defn.cpp:937 + +namespace CORBA +{ + extern ::CORBA::TypeCode_ptr const _tc_TypeCode; +} + + +#ifndef _TAO_TYPECODE_Dynamic_ExceptionList_GUARD +#define _TAO_TYPECODE_Dynamic_ExceptionList_GUARD +namespace TAO +{ + namespace TypeCode + { + TAO::TypeCode::Sequence< ::CORBA::TypeCode_ptr const *, + TAO::Null_RefCount_Policy> + Dynamic_ExceptionList_0 ( + CORBA::tk_sequence, + &CORBA::_tc_TypeCode, + 0U); + + ::CORBA::TypeCode_ptr const tc_Dynamic_ExceptionList_0 = + &Dynamic_ExceptionList_0; + + } +} + + +#endif /* _TAO_TYPECODE_Dynamic_ExceptionList_GUARD */ + +static TAO::TypeCode::Alias<char const *, + CORBA::TypeCode_ptr const *, + TAO::Null_RefCount_Policy> + _tao_tc_Dynamic_ExceptionList ( + CORBA::tk_alias, + "IDL:omg.org/Dynamic/ExceptionList:1.0", + "ExceptionList", + &TAO::TypeCode::tc_Dynamic_ExceptionList_0); + +namespace Dynamic +{ + ::CORBA::TypeCode_ptr const _tc_ExceptionList = + &_tao_tc_Dynamic_ExceptionList; +} + + + +// TAO_IDL - Generated from +// be\be_visitor_typecode/alias_typecode.cpp:50 + +static TAO::TypeCode::Alias<char const *, + CORBA::TypeCode_ptr const *, + TAO::Null_RefCount_Policy> + _tao_tc_Dynamic_RequestContext ( + CORBA::tk_alias, + "IDL:omg.org/Dynamic/RequestContext:1.0", + "RequestContext", + &CORBA::_tc_StringSeq); + +namespace Dynamic +{ + ::CORBA::TypeCode_ptr const _tc_RequestContext = + &_tao_tc_Dynamic_RequestContext; +} + +// TAO_IDL - Generated from +// be\be_visitor_sequence/any_op_cs.cpp:54 + + +// Copying insertion. +void operator<<= ( + CORBA::Any &_tao_any, + const Dynamic::ParameterList &_tao_elem + ) +{ + TAO::Any_Dual_Impl_T<Dynamic::ParameterList>::insert_copy ( + _tao_any, + Dynamic::ParameterList::_tao_any_destructor, + TAO::TypeCode::tc_Dynamic_ParameterList_0, + _tao_elem + ); +} + +// Non-copying insertion. +void operator<<= ( + CORBA::Any &_tao_any, + Dynamic::ParameterList *_tao_elem + ) +{ + TAO::Any_Dual_Impl_T<Dynamic::ParameterList>::insert ( + _tao_any, + Dynamic::ParameterList::_tao_any_destructor, + TAO::TypeCode::tc_Dynamic_ParameterList_0, + _tao_elem + ); +} + +// Extraction to non-const pointer (deprecated). +CORBA::Boolean operator>>= ( + const CORBA::Any &_tao_any, + Dynamic::ParameterList *&_tao_elem + ) +{ + return _tao_any >>= const_cast< + const Dynamic::ParameterList *&> ( + _tao_elem + ); +} + +// Extraction to const pointer. +CORBA::Boolean operator>>= ( + const CORBA::Any &_tao_any, + const Dynamic::ParameterList *&_tao_elem + ) +{ + return + TAO::Any_Dual_Impl_T<Dynamic::ParameterList>::extract ( + _tao_any, + Dynamic::ParameterList::_tao_any_destructor, + TAO::TypeCode::tc_Dynamic_ParameterList_0, + _tao_elem + ); +} + + + +// TAO_IDL - Generated from +// be\be_visitor_sequence/any_op_cs.cpp:54 + + +// Copying insertion. +void operator<<= ( + CORBA::Any &_tao_any, + const Dynamic::ExceptionList &_tao_elem + ) +{ + TAO::Any_Dual_Impl_T<Dynamic::ExceptionList>::insert_copy ( + _tao_any, + Dynamic::ExceptionList::_tao_any_destructor, + TAO::TypeCode::tc_Dynamic_ExceptionList_0, + _tao_elem + ); +} + +// Non-copying insertion. +void operator<<= ( + CORBA::Any &_tao_any, + Dynamic::ExceptionList *_tao_elem + ) +{ + TAO::Any_Dual_Impl_T<Dynamic::ExceptionList>::insert ( + _tao_any, + Dynamic::ExceptionList::_tao_any_destructor, + TAO::TypeCode::tc_Dynamic_ExceptionList_0, + _tao_elem + ); +} + +// Extraction to non-const pointer (deprecated). +CORBA::Boolean operator>>= ( + const CORBA::Any &_tao_any, + Dynamic::ExceptionList *&_tao_elem + ) +{ + return _tao_any >>= const_cast< + const Dynamic::ExceptionList *&> ( + _tao_elem + ); +} + +// Extraction to const pointer. +CORBA::Boolean operator>>= ( + const CORBA::Any &_tao_any, + const Dynamic::ExceptionList *&_tao_elem + ) +{ + return + TAO::Any_Dual_Impl_T<Dynamic::ExceptionList>::extract ( + _tao_any, + Dynamic::ExceptionList::_tao_any_destructor, + TAO::TypeCode::tc_Dynamic_ExceptionList_0, + _tao_elem + ); +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/DynamicA.h b/TAO/tao/AnyTypeCode/DynamicA.h new file mode 100644 index 00000000000..a327a5a461a --- /dev/null +++ b/TAO/tao/AnyTypeCode/DynamicA.h @@ -0,0 +1,146 @@ +// -*- C++ -*- +// +// $Id$ + +// **** Code generated by the The ACE ORB (TAO) IDL Compiler **** +// TAO and the TAO IDL Compiler have been developed by: +// Center for Distributed Object Computing +// Washington University +// St. Louis, MO +// USA +// http://www.cs.wustl.edu/~schmidt/doc-center.html +// and +// Distributed Object Computing Laboratory +// University of California at Irvine +// Irvine, CA +// USA +// http://doc.ece.uci.edu/ +// and +// Institute for Software Integrated Systems +// Vanderbilt University +// Nashville, TN +// USA +// http://www.isis.vanderbilt.edu/ +// +// Information about TAO is available at: +// http://www.cs.wustl.edu/~schmidt/TAO.html + +// TAO_IDL - Generated from +// be\be_codegen.cpp:153 + +#ifndef _TAO_IDL_ORIG_DYNAMICA_H_ +#define _TAO_IDL_ORIG_DYNAMICA_H_ + +#include /**/ "ace/pre.h" + + +#include "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/AnyTypeCode/TAO_AnyTypeCode_Export.h" +#include "tao/AnyTypeCode/DynamicC.h" + +#if defined (TAO_EXPORT_MACRO) +#undef TAO_EXPORT_MACRO +#endif +#define TAO_EXPORT_MACRO TAO_AnyTypeCode_Export + +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +#if defined (__BORLANDC__) +#pragma option push -w-rvl -w-rch -w-ccc -w-inl +#endif /* __BORLANDC__ */ + +// TAO_IDL - Generated from +// be\be_visitor_module/module_ch.cpp:48 + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace CORBA +{ +} // module CORBA + +// TAO_IDL - Generated from +// be\be_visitor_module/module_ch.cpp:48 + +namespace Dynamic +{ + // TAO_IDL - Generated from + // be\be_visitor_typecode/typecode_decl.cpp:44 + + extern TAO_AnyTypeCode_Export ::CORBA::TypeCode_ptr const _tc_ParameterList; + + extern TAO_AnyTypeCode_Export ::CORBA::TypeCode_ptr const _tc_ContextList; + + // TAO_IDL - Generated from + // be\be_visitor_typecode/typecode_decl.cpp:44 + + extern TAO_AnyTypeCode_Export ::CORBA::TypeCode_ptr const _tc_ExceptionList; + + // TAO_IDL - Generated from + // be\be_visitor_typecode/typecode_decl.cpp:44 + + extern TAO_AnyTypeCode_Export ::CORBA::TypeCode_ptr const _tc_RequestContext; + +// TAO_IDL - Generated from +// be\be_visitor_module/module_ch.cpp:66 + +} // module Dynamic + +// TAO_IDL - Generated from +// be\be_visitor_traits.cpp:61 + +// TAO_IDL - Generated from +// be\be_visitor_sequence/any_op_ch.cpp:52 + +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, const Dynamic::ParameterList &); // copying version +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, Dynamic::ParameterList*); // noncopying version +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any &, Dynamic::ParameterList *&); // deprecated +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any &, const Dynamic::ParameterList *&); + +// TAO_IDL - Generated from +// be\be_visitor_interface_fwd/any_op_ch.cpp:63 + +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, CORBA::TypeCode_ptr); // copying +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, CORBA::TypeCode_ptr *); // non-copying +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any &, CORBA::TypeCode *&); + +// TAO_IDL - Generated from +// be\be_visitor_sequence/any_op_ch.cpp:52 + +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, const Dynamic::ExceptionList &); // copying version +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, Dynamic::ExceptionList*); // noncopying version +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any &, Dynamic::ExceptionList *&); // deprecated +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any &, const Dynamic::ExceptionList *&); + +// TAO_IDL - Generated from +// be\be_visitor_interface_fwd/cdr_op_ch.cpp:66 + +TAO_AnyTypeCode_Export CORBA::Boolean operator<< (TAO_OutputCDR &, const CORBA::TypeCode_ptr ); +TAO_AnyTypeCode_Export CORBA::Boolean operator>> (TAO_InputCDR &, CORBA::TypeCode_ptr &); + + +// TAO_IDL - Generated from +// be\be_codegen.cpp:955 + +TAO_END_VERSIONED_NAMESPACE_DECL + +#if defined(_MSC_VER) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#if defined (__BORLANDC__) +#pragma option pop +#endif /* __BORLANDC__ */ + +#include /**/ "ace/post.h" + +#endif /* ifndef */ + + diff --git a/TAO/tao/AnyTypeCode/DynamicC.cpp b/TAO/tao/AnyTypeCode/DynamicC.cpp new file mode 100644 index 00000000000..4cd49b59b28 --- /dev/null +++ b/TAO/tao/AnyTypeCode/DynamicC.cpp @@ -0,0 +1,208 @@ +// -*- C++ -*- +// +// $Id$ + +// **** Code generated by the The ACE ORB (TAO) IDL Compiler **** +// TAO and the TAO IDL Compiler have been developed by: +// Center for Distributed Object Computing +// Washington University +// St. Louis, MO +// USA +// http://www.cs.wustl.edu/~schmidt/doc-center.html +// and +// Distributed Object Computing Laboratory +// University of California at Irvine +// Irvine, CA +// USA +// http://doc.ece.uci.edu/ +// and +// Institute for Software Integrated Systems +// Vanderbilt University +// Nashville, TN +// USA +// http://www.isis.vanderbilt.edu/ +// +// Information about TAO is available at: +// http://www.cs.wustl.edu/~schmidt/TAO.html + +// TAO_IDL - Generated from +// be\be_codegen.cpp:291 + + +#include "tao/AnyTypeCode/DynamicC.h" +#include "tao/CDR.h" + +#if defined (__BORLANDC__) +#pragma option -w-rvl -w-rch -w-ccc -w-aus -w-sig +#endif /* __BORLANDC__ */ + +// TAO_IDL - Generated from +// be\be_visitor_arg_traits.cpp:70 + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +// Arg traits specializations. +namespace TAO +{ +} + +// TAO_IDL - Generated from +// be\be_visitor_sequence/sequence_cs.cpp:65 + +#if !defined (_DYNAMIC_PARAMETERLIST_CS_) +#define _DYNAMIC_PARAMETERLIST_CS_ + +Dynamic::ParameterList::ParameterList (void) +{} + +Dynamic::ParameterList::ParameterList ( + CORBA::ULong max + ) + : TAO::unbounded_value_sequence< + Dynamic::Parameter + > + (max) +{} + +Dynamic::ParameterList::ParameterList ( + CORBA::ULong max, + CORBA::ULong length, + Dynamic::Parameter * buffer, + CORBA::Boolean release + ) + : TAO::unbounded_value_sequence< + Dynamic::Parameter + > + (max, length, buffer, release) +{} + +Dynamic::ParameterList::ParameterList ( + const ParameterList &seq + ) + : TAO::unbounded_value_sequence< + Dynamic::Parameter + > + (seq) +{} + +Dynamic::ParameterList::~ParameterList (void) +{} + +void Dynamic::ParameterList::_tao_any_destructor ( + void * _tao_void_pointer + ) +{ + ParameterList * _tao_tmp_pointer = + static_cast<ParameterList *> (_tao_void_pointer); + delete _tao_tmp_pointer; +} + +#endif /* end #if !defined */ + + +// TAO_IDL - Generated from +// be\be_visitor_sequence/sequence_cs.cpp:65 + +#if !defined (_DYNAMIC_EXCEPTIONLIST_CS_) +#define _DYNAMIC_EXCEPTIONLIST_CS_ + +Dynamic::ExceptionList::ExceptionList (void) +{} + +Dynamic::ExceptionList::ExceptionList ( + CORBA::ULong max + ) + : TAO::unbounded_object_reference_sequence< + CORBA::TypeCode, + CORBA::TypeCode_var + > + (max) +{} + +Dynamic::ExceptionList::ExceptionList ( + CORBA::ULong max, + CORBA::ULong length, + CORBA::TypeCode_ptr * buffer, + CORBA::Boolean release + ) + : TAO::unbounded_object_reference_sequence< + CORBA::TypeCode, + CORBA::TypeCode_var + > + (max, length, buffer, release) +{} + +Dynamic::ExceptionList::ExceptionList ( + const ExceptionList &seq + ) + : TAO::unbounded_object_reference_sequence< + CORBA::TypeCode, + CORBA::TypeCode_var + > + (seq) +{} + +Dynamic::ExceptionList::~ExceptionList (void) +{} + +void Dynamic::ExceptionList::_tao_any_destructor ( + void * _tao_void_pointer + ) +{ + ExceptionList * _tao_tmp_pointer = + static_cast<ExceptionList *> (_tao_void_pointer); + delete _tao_tmp_pointer; +} + +#endif /* end #if !defined */ + +// TAO_IDL - Generated from +// be\be_visitor_sequence/cdr_op_cs.cpp:96 + +#if !defined _TAO_CDR_OP_Dynamic_ParameterList_CPP_ +#define _TAO_CDR_OP_Dynamic_ParameterList_CPP_ + +CORBA::Boolean operator<< ( + TAO_OutputCDR &strm, + const Dynamic::ParameterList &_tao_sequence + ) +{ + return TAO::marshal_sequence(strm, _tao_sequence); +} + +CORBA::Boolean operator>> ( + TAO_InputCDR &strm, + Dynamic::ParameterList &_tao_sequence + ) +{ + return TAO::demarshal_sequence(strm, _tao_sequence); +} + +#endif /* _TAO_CDR_OP_Dynamic_ParameterList_CPP_ */ + + +// TAO_IDL - Generated from +// be\be_visitor_sequence/cdr_op_cs.cpp:96 + +#if !defined _TAO_CDR_OP_Dynamic_ExceptionList_CPP_ +#define _TAO_CDR_OP_Dynamic_ExceptionList_CPP_ + +CORBA::Boolean operator<< ( + TAO_OutputCDR &strm, + const Dynamic::ExceptionList &_tao_sequence + ) +{ + return TAO::marshal_sequence(strm, _tao_sequence); +} + +CORBA::Boolean operator>> ( + TAO_InputCDR &strm, + Dynamic::ExceptionList &_tao_sequence + ) +{ + return TAO::demarshal_sequence(strm, _tao_sequence); +} + +#endif /* _TAO_CDR_OP_Dynamic_ExceptionList_CPP_ */ + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/DynamicC.h b/TAO/tao/AnyTypeCode/DynamicC.h new file mode 100644 index 00000000000..92e2d9ba9b9 --- /dev/null +++ b/TAO/tao/AnyTypeCode/DynamicC.h @@ -0,0 +1,258 @@ +// -*- C++ -*- +// +// $Id$ + +// **** Code generated by the The ACE ORB (TAO) IDL Compiler **** +// TAO and the TAO IDL Compiler have been developed by: +// Center for Distributed Object Computing +// Washington University +// St. Louis, MO +// USA +// http://www.cs.wustl.edu/~schmidt/doc-center.html +// and +// Distributed Object Computing Laboratory +// University of California at Irvine +// Irvine, CA +// USA +// http://doc.ece.uci.edu/ +// and +// Institute for Software Integrated Systems +// Vanderbilt University +// Nashville, TN +// USA +// http://www.isis.vanderbilt.edu/ +// +// Information about TAO is available at: +// http://www.cs.wustl.edu/~schmidt/TAO.html + +// TAO_IDL - Generated from +// be\be_codegen.cpp:153 + +#ifndef _TAO_IDL_ORIG_DYNAMICC_H_ +#define _TAO_IDL_ORIG_DYNAMICC_H_ + +#include /**/ "ace/pre.h" + + +#include "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/AnyTypeCode/TAO_AnyTypeCode_Export.h" +#include "tao/AnyTypeCode/TypeCode.h" +#include "tao/AnyTypeCode/TypeCode_Constants.h" +#include "tao/AnyTypeCode/Dynamic_ParameterC.h" +#include "tao/ORB.h" +#include "tao/Environment.h" +#include "tao/Sequence_T.h" +#include "tao/Objref_VarOut_T.h" +#include "tao/Seq_Var_T.h" +#include "tao/Seq_Out_T.h" + +#include "tao/StringSeqC.h" + +#if defined (TAO_EXPORT_MACRO) +#undef TAO_EXPORT_MACRO +#endif +#define TAO_EXPORT_MACRO TAO_AnyTypeCode_Export + +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +#if defined (__BORLANDC__) +#pragma option push -w-rvl -w-rch -w-ccc -w-inl +#endif /* __BORLANDC__ */ + +// TAO_IDL - Generated from +// be\be_visitor_module/module_ch.cpp:48 + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace CORBA +{ + + // TAO_IDL - Generated from + // be\be_interface.cpp:598 + +// TAO_IDL - Generated from +// be\be_visitor_module/module_ch.cpp:66 + +} // module CORBA + +// TAO_IDL - Generated from +// be\be_visitor_module/module_ch.cpp:48 + +namespace Dynamic +{ + // TAO_IDL - Generated from + // be\be_visitor_sequence/sequence_ch.cpp:101 + +#if !defined (_DYNAMIC_PARAMETERLIST_CH_) +#define _DYNAMIC_PARAMETERLIST_CH_ + + class ParameterList; + + typedef + TAO_VarSeq_Var_T< + ParameterList + > + ParameterList_var; + + typedef + TAO_Seq_Out_T< + ParameterList + > + ParameterList_out; + + class TAO_AnyTypeCode_Export ParameterList + : public + TAO::unbounded_value_sequence< + Parameter + > + { + public: + ParameterList (void); + ParameterList (CORBA::ULong max); + ParameterList ( + CORBA::ULong max, + CORBA::ULong length, + Parameter* buffer, + CORBA::Boolean release = false + ); + ParameterList (const ParameterList &); + ~ParameterList (void); + + static void _tao_any_destructor (void *); + + typedef ParameterList_var _var_type; + }; + +#endif /* end #if !defined */ + + + // TAO_IDL - Generated from + // be\be_visitor_typedef/typedef_ch.cpp:472 + + typedef CORBA::StringSeq ContextList; + typedef CORBA::StringSeq_var ContextList_var; + typedef CORBA::StringSeq_out ContextList_out; + + // TAO_IDL - Generated from + // be\be_visitor_sequence/sequence_ch.cpp:101 + +#if !defined (_DYNAMIC_EXCEPTIONLIST_CH_) +#define _DYNAMIC_EXCEPTIONLIST_CH_ + + class ExceptionList; + + typedef + TAO_VarSeq_Var_T< + ExceptionList + > + ExceptionList_var; + + typedef + TAO_Seq_Out_T< + ExceptionList + > + ExceptionList_out; + + class TAO_AnyTypeCode_Export ExceptionList + : public + TAO::unbounded_object_reference_sequence< + CORBA::TypeCode, + CORBA::TypeCode_var + > + { + public: + ExceptionList (void); + ExceptionList (CORBA::ULong max); + ExceptionList ( + CORBA::ULong max, + CORBA::ULong length, + CORBA::TypeCode_ptr* buffer, + CORBA::Boolean release = false + ); + ExceptionList (const ExceptionList &); + ~ExceptionList (void); + + static void _tao_any_destructor (void *); + + typedef ExceptionList_var _var_type; + }; + +#endif /* end #if !defined */ + + // TAO_IDL - Generated from + // be\be_visitor_typedef/typedef_ch.cpp:472 + + typedef CORBA::StringSeq RequestContext; + typedef CORBA::StringSeq_var RequestContext_var; + typedef CORBA::StringSeq_out RequestContext_out; + +// TAO_IDL - Generated from +// be\be_visitor_module/module_ch.cpp:66 + +} // module Dynamic + +// TAO_IDL - Generated from +// be\be_visitor_traits.cpp:61 + +// TAO_IDL - Generated from +// be\be_visitor_sequence/cdr_op_ch.cpp:71 + +#if !defined _TAO_CDR_OP_Dynamic_ParameterList_H_ +#define _TAO_CDR_OP_Dynamic_ParameterList_H_ + +TAO_AnyTypeCode_Export CORBA::Boolean operator<< ( + TAO_OutputCDR &, + const Dynamic::ParameterList & + ); +TAO_AnyTypeCode_Export CORBA::Boolean operator>> ( + TAO_InputCDR &, + Dynamic::ParameterList & + ); + +#endif /* _TAO_CDR_OP_Dynamic_ParameterList_H_ */ + + +// Traits specializations. +// TAO_IDL - Generated from +// be\be_visitor_sequence/cdr_op_ch.cpp:71 + +#if !defined _TAO_CDR_OP_Dynamic_ExceptionList_H_ +#define _TAO_CDR_OP_Dynamic_ExceptionList_H_ + +TAO_AnyTypeCode_Export CORBA::Boolean operator<< ( + TAO_OutputCDR &, + const Dynamic::ExceptionList & + ); +TAO_AnyTypeCode_Export CORBA::Boolean operator>> ( + TAO_InputCDR &, + Dynamic::ExceptionList & + ); + +#endif /* _TAO_CDR_OP_Dynamic_ExceptionList_H_ */ + +// TAO_IDL - Generated from +// be\be_codegen.cpp:955 + +TAO_END_VERSIONED_NAMESPACE_DECL + +#if defined(_MSC_VER) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#if defined (__BORLANDC__) +#pragma option pop +#endif /* __BORLANDC__ */ + +#include /**/ "ace/post.h" + +#endif /* ifndef */ + + diff --git a/TAO/tao/AnyTypeCode/DynamicS.h b/TAO/tao/AnyTypeCode/DynamicS.h new file mode 100644 index 00000000000..17b1360599e --- /dev/null +++ b/TAO/tao/AnyTypeCode/DynamicS.h @@ -0,0 +1,28 @@ +// -*- C++ -*- +// +// $Id$ + +// **** Code generated by the The ACE ORB (TAO) IDL Compiler **** +// TAO and the TAO IDL Compiler have been developed by: +// Center for Distributed Object Computing +// Washington University +// St. Louis, MO +// USA +// http://www.cs.wustl.edu/~schmidt/doc-center.html +// and +// Distributed Object Computing Laboratory +// University of California at Irvine +// Irvine, CA +// USA +// http://doc.ece.uci.edu/ +// and +// Institute for Software Integrated Systems +// Vanderbilt University +// Nashville, TN +// USA +// http://www.isis.vanderbilt.edu/ +// +// Information about TAO is available at: +// http://www.cs.wustl.edu/~schmidt/TAO.html + +// Skeleton file generation suppressed with command line option -SS diff --git a/TAO/tao/AnyTypeCode/Dynamic_Parameter.pidl b/TAO/tao/AnyTypeCode/Dynamic_Parameter.pidl new file mode 100644 index 00000000000..aee0f76d991 --- /dev/null +++ b/TAO/tao/AnyTypeCode/Dynamic_Parameter.pidl @@ -0,0 +1,43 @@ +// -*- IDL -*- + +// ================================================================ +/** + * @file Dynamic_Parameter.pidl + * + * $Id$ + * + * This file was used to generate the code in Dynamic_ParameterC.* The command + * used to generate code is: + * + * tao_idl + * -o orig -Ge 1 -GA -Sci + * -Wb,export_macro=TAO_Export + * -Wb,export_include="tao/TAO_Export.h" + * -Wb,pre_include="ace/pre.h" + * -Wb,post_include="ace/post.h" + * -Wb,versioning_begin=TAO_BEGIN_VERSIONED_NAMESPACE_DECL + * -Wb,versioning_end=TAO_END_VERSIONED_NAMESPACE_DECL + * Dynamic_Parameter.pidl + * + */ +// ================================================================ + +// File: Dynamic_Parameter.idl +// Piece of module Dynamic generated separately for use by +// template argument helper classes. + +#ifndef _DYNAMIC_PARAMETER_IDL_ +#define _DYNAMIC_PARAMETER_IDL_ + +#include "tao/ParameterMode.pidl" + +module Dynamic +{ + struct Parameter + { + any argument; + CORBA::ParameterMode mode; + }; +}; + +#endif // _DYNAMIC_PARAMETER_IDL_ diff --git a/TAO/tao/AnyTypeCode/Empty_Param_TypeCode.cpp b/TAO/tao/AnyTypeCode/Empty_Param_TypeCode.cpp new file mode 100644 index 00000000000..9c77532c4e3 --- /dev/null +++ b/TAO/tao/AnyTypeCode/Empty_Param_TypeCode.cpp @@ -0,0 +1,87 @@ +// $Id$ + +#include "tao/AnyTypeCode/Empty_Param_TypeCode.h" + +#ifndef __ACE_INLINE__ +# include "tao/AnyTypeCode/Empty_Param_TypeCode.inl" +#endif /* !__ACE_INLINE__ */ + + +ACE_RCSID (AnyTypeCode, + Empty_Param_TypeCode, + "$Id$") + + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +bool +TAO::TypeCode::Empty_Param::tao_marshal (TAO_OutputCDR &, + CORBA::ULong) const +{ + // Empty parameter list. Nothing to marshal. + + return true; +} + +void +TAO::TypeCode::Empty_Param::tao_duplicate (void) +{ + // No-op since empty parameter TypeCodes are never created + // dynamically, meaning there is no need to implement reference + // counting. +} + +void +TAO::TypeCode::Empty_Param::tao_release (void) +{ + // No-op since empty parameter TypeCodes are never created + // dynamically, meaning there is no need to implement reference + // counting. +} + +CORBA::Boolean +TAO::TypeCode::Empty_Param::equal_i (CORBA::TypeCode_ptr + ACE_ENV_ARG_DECL_NOT_USED) const +{ + // Equality has already been established in the + // CORBA::TypeCode base class. + + return true; +} + +CORBA::Boolean +TAO::TypeCode::Empty_Param::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 (false); + + if (tc_kind != this->kind_) + return false; + + return true; +} + +CORBA::TypeCode_ptr +TAO::TypeCode::Empty_Param::get_compact_typecode_i ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const +{ + // Already compact since parameter list is empty. + + // Since empty parameter TypeCodes are never created + // dynamically, there is no need to manipulate a reference count. + + static TAO::TypeCode::Empty_Param compact_typecode (this->kind_); + + return &compact_typecode; +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/Empty_Param_TypeCode.h b/TAO/tao/AnyTypeCode/Empty_Param_TypeCode.h new file mode 100644 index 00000000000..62b9936a1a9 --- /dev/null +++ b/TAO/tao/AnyTypeCode/Empty_Param_TypeCode.h @@ -0,0 +1,102 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Empty_Param_TypeCode.h + * + * $Id$ + * + * Header file for @c CORBA::TypeCodes with empty parameter lists. + * + * @author Ossama Othman <ossama@dre.vanderbilt.edu> + */ +//============================================================================= + +#ifndef TAO_EMPTY_PARAM_TYPECODE_H +#define TAO_EMPTY_PARAM_TYPECODE_H + +#include /**/ "ace/pre.h" + +#include "tao/AnyTypeCode/TypeCode.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + namespace TypeCode + { + + /** + * @class Empty_Param + * + * @brief @c CORBA::TypeCode implementation for OMG IDL types with + * empty parameter lists. + * + * This class implements a @c CORBA::TypeCode for OMG IDL types + * with empty parameter lists. + * + * @note @c Empty_Param @c TypeCodes are not reference counted in + * TAO since they are static, exist as constants for the + * length of a given OS process, and cannot be created + * through the @c CORBA::ORB or @c CORBA::TypeCodeFactory + * interfaces. + */ + class Empty_Param : public CORBA::TypeCode + { + public: + + /// Constructor. + Empty_Param (CORBA::TCKind k); + + /** + * @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, + CORBA::ULong offset) const; + virtual void tao_duplicate (void); + virtual void tao_release (void); + //@} + + protected: + + /** + * @name @c TAO CORBA::TypeCode Template Methods + * + * @c CORBA::TypeCode template methods specific to @c TypeCodes + * with empty parameter lists. + * + * @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::TypeCode_ptr get_compact_typecode_i ( + ACE_ENV_SINGLE_ARG_DECL) const; + + }; + + } // End namespace TypeCode +} // End namespace TAO + +TAO_END_VERSIONED_NAMESPACE_DECL + + +#ifdef __ACE_INLINE__ +# include "tao/AnyTypeCode/Empty_Param_TypeCode.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" + +#endif /* TAO_EMPTY_PARAM_TYPECODE_H */ diff --git a/TAO/tao/AnyTypeCode/Empty_Param_TypeCode.inl b/TAO/tao/AnyTypeCode/Empty_Param_TypeCode.inl new file mode 100644 index 00000000000..0cf77cec3bc --- /dev/null +++ b/TAO/tao/AnyTypeCode/Empty_Param_TypeCode.inl @@ -0,0 +1,13 @@ +// -*- C++ -*- +// +// $Id$ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE +TAO::TypeCode::Empty_Param::Empty_Param (CORBA::TCKind k) + : ::CORBA::TypeCode (k) +{ +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/Enum_TypeCode.cpp b/TAO/tao/AnyTypeCode/Enum_TypeCode.cpp new file mode 100644 index 00000000000..b84a50f9b72 --- /dev/null +++ b/TAO/tao/AnyTypeCode/Enum_TypeCode.cpp @@ -0,0 +1,224 @@ +// $Id$ + +#ifndef TAO_ENUM_TYPECODE_CPP +#define TAO_ENUM_TYPECODE_CPP + +#include "tao/AnyTypeCode/Enum_TypeCode.h" +#include "tao/AnyTypeCode/TypeCode_Traits.h" +#include "tao/TypeCodeFactory_Adapter.h" +#include "tao/ORB_Core.h" +#include "tao/CDR.h" + +#include "ace/Dynamic_Service.h" + +#ifndef __ACE_INLINE__ +# include "tao/AnyTypeCode/Enum_TypeCode.inl" +#endif /* !__ACE_INLINE__ */ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +template <typename StringType, class EnumeratorArrayType, class RefCountPolicy> +bool +TAO::TypeCode::Enum<StringType, + EnumeratorArrayType, + RefCountPolicy>::tao_marshal (TAO_OutputCDR & cdr, + CORBA::ULong) const +{ + // A tk_enum 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. + TAO_OutputCDR enc; + + bool const success = + (enc << TAO_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER)) + && (enc << TAO_OutputCDR::from_string (this->base_attributes_.id (), 0)) + && (enc << TAO_OutputCDR::from_string (this->base_attributes_.name (), 0)) + && (enc << this->nenumerators_); + + if (!success) + return false; + + StringType const * const begin = &this->enumerators_[0]; + StringType const * const end = begin + this->nenumerators_; + + for (StringType const * i = begin; i != end; ++i) + { + StringType const & enumerator = *i; + + if (!(enc << TAO_OutputCDR::from_string ( + Traits<StringType>::get_string (enumerator), 0))) + return false; + } + + return + cdr << static_cast<CORBA::ULong> (enc.total_length ()) + && cdr.write_octet_array_mb (enc.begin ()); +} + +template <typename StringType, class EnumeratorArrayType, class RefCountPolicy> +void +TAO::TypeCode::Enum<StringType, + EnumeratorArrayType, + RefCountPolicy>::tao_duplicate (void) +{ + this->RefCountPolicy::add_ref (); +} + +template <typename StringType, class EnumeratorArrayType, class RefCountPolicy> +void +TAO::TypeCode::Enum<StringType, + EnumeratorArrayType, + RefCountPolicy>::tao_release (void) +{ + this->RefCountPolicy::remove_ref (); +} + +template <typename StringType, class EnumeratorArrayType, class RefCountPolicy> +CORBA::Boolean +TAO::TypeCode::Enum<StringType, + EnumeratorArrayType, + 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_nenumerators = + tc->member_count (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + if (tc_nenumerators != this->nenumerators_) + return false; + + for (CORBA::ULong i = 0; i < this->nenumerators_; ++i) + { + StringType const & lhs_enumerator = this->enumerators_[i]; + + char const * const lhs_name = + Traits<StringType>::get_string (lhs_enumerator); + char const * const rhs_name = tc->member_name (i + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + if (ACE_OS::strcmp (lhs_name, rhs_name) != 0) + return false; + } + + return true; +} + +template <typename StringType, class EnumeratorArrayType, class RefCountPolicy> +CORBA::Boolean +TAO::TypeCode::Enum<StringType, + EnumeratorArrayType, + RefCountPolicy>::equivalent_i ( + CORBA::TypeCode_ptr tc + ACE_ENV_ARG_DECL) const +{ + // Perform a structural comparison, excluding the name() and + // member_name() operations. + + CORBA::ULong const tc_nenumerators = + tc->member_count (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + if (tc_nenumerators != this->nenumerators_) + return false; + + return true; +} + +template <typename StringType, class EnumeratorArrayType, class RefCountPolicy> +CORBA::TypeCode_ptr +TAO::TypeCode::Enum<StringType, + EnumeratorArrayType, + RefCountPolicy>::get_compact_typecode_i ( + ACE_ENV_SINGLE_ARG_DECL) const +{ + ACE_Array_Base<CORBA::String_var> tc_enumerators (this->nenumerators_); + + // Dynamically construct a new array of enumerators stripped of + // member names. + + static char const empty_name[] = ""; + + for (CORBA::ULong i = 0; i < this->nenumerators_; ++i) + { + // Member names will be stripped, i.e. not embedded within + // the compact TypeCode. + + tc_enumerators[i] = empty_name; + } + + 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 ()); + } + + return + adapter->create_enum_tc (this->base_attributes_.id (), + "" /* empty name */, + tc_enumerators, + this->nenumerators_ + ACE_ENV_ARG_PARAMETER); +} + +template <typename StringType, class EnumeratorArrayType, class RefCountPolicy> +char const * +TAO::TypeCode::Enum<StringType, EnumeratorArrayType, 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 EnumeratorArrayType, class RefCountPolicy> +char const * +TAO::TypeCode::Enum<StringType, EnumeratorArrayType, 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 EnumeratorArrayType, class RefCountPolicy> +CORBA::ULong +TAO::TypeCode::Enum<StringType, + EnumeratorArrayType, + RefCountPolicy>::member_count_i ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const +{ + return this->nenumerators_; +} + +template <typename StringType, class EnumeratorArrayType, class RefCountPolicy> +char const * +TAO::TypeCode::Enum<StringType, + EnumeratorArrayType, + 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->nenumerators_) + ACE_THROW_RETURN (CORBA::TypeCode::Bounds (), 0); + + return Traits<StringType>::get_string (this->enumerators_[index]); +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +#endif /* TAO_ENUM_TYPECODE_CPP */ diff --git a/TAO/tao/AnyTypeCode/Enum_TypeCode.h b/TAO/tao/AnyTypeCode/Enum_TypeCode.h new file mode 100644 index 00000000000..64a4d7bf9b0 --- /dev/null +++ b/TAO/tao/AnyTypeCode/Enum_TypeCode.h @@ -0,0 +1,143 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Enum_TypeCode.h + * + * $Id$ + * + * Header file for a @c tk_enum CORBA::TypeCode. + * + * @author Ossama Othman <ossama@dre.vanderbilt.edu> + */ +//============================================================================= + +#ifndef TAO_ENUM_TYPECODE_H +#define TAO_ENUM_TYPECODE_H + +#include /**/ "ace/pre.h" + +#include "tao/AnyTypeCode/TypeCode.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/AnyTypeCode/TypeCode_Base_Attributes.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + namespace TypeCode + { + /** + * @class Enum + * + * @brief @c CORBA::TypeCode implementation for an OMG IDL + * @c enum. + * + * This class implements a @c CORBA::TypeCode for an OMG IDL + * @c enum. + */ + template <typename StringType, + class EnumeratorArrayType, + class RefCountPolicy> + class Enum + : public CORBA::TypeCode, + private RefCountPolicy + { + public: + + /// Constructor. + Enum (char const * id, + char const * name, + EnumeratorArrayType const & enumerators, + CORBA::ULong nenumerators); + + /** + * @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, + CORBA::ULong offset) const; + virtual void tao_duplicate (void); + virtual void tao_release (void); + //@} + + protected: + + /** + * @name @c TAO CORBA::TypeCode Template Methods + * + * @c tk_enum @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::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; + //@} + + private: + + /** + * @c Enum Attributes + * + * Attributes representing the structure of an OMG IDL + * @c enum. + * + * @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 + /// structure type. + Base_Attributes<StringType> base_attributes_; + + /// The number of enumerators in the OMG IDL enumeration. + CORBA::ULong const nenumerators_; + + /// Array of @c TAO::TypeCode enumerators representing + /// enumerators in the OMG IDL defined @c enum. + EnumeratorArrayType const enumerators_; + + }; + + } // End namespace TypeCode +} // End namespace TAO + +TAO_END_VERSIONED_NAMESPACE_DECL + +#ifdef __ACE_INLINE__ +# include "tao/AnyTypeCode/Enum_TypeCode.inl" +#endif /* __ACE_INLINE__ */ + +#ifdef ACE_TEMPLATES_REQUIRE_SOURCE +# include "tao/AnyTypeCode/Enum_TypeCode.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#ifdef ACE_TEMPLATES_REQUIRE_PRAGMA +# pragma implementation ("Enum_TypeCode.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + + +#include /**/ "ace/post.h" + +#endif /* TAO_ENUM_TYPECODE_H */ diff --git a/TAO/tao/AnyTypeCode/Enum_TypeCode.inl b/TAO/tao/AnyTypeCode/Enum_TypeCode.inl new file mode 100644 index 00000000000..64c14e65f51 --- /dev/null +++ b/TAO/tao/AnyTypeCode/Enum_TypeCode.inl @@ -0,0 +1,24 @@ +// -*- C++ -*- +// +// $Id$ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +template <typename StringType, + class EnumeratorArrayType, + class RefCountPolicy> +ACE_INLINE +TAO::TypeCode::Enum<StringType, EnumeratorArrayType, RefCountPolicy>::Enum ( + char const * id, + char const * name, + EnumeratorArrayType const & enumerators, + CORBA::ULong nenumerators) + : ::CORBA::TypeCode (CORBA::tk_enum) + , RefCountPolicy () + , base_attributes_ (id, name) + , nenumerators_ (nenumerators) + , enumerators_ (enumerators) +{ +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/Enum_TypeCode_Static.cpp b/TAO/tao/AnyTypeCode/Enum_TypeCode_Static.cpp new file mode 100644 index 00000000000..64cd8f00d37 --- /dev/null +++ b/TAO/tao/AnyTypeCode/Enum_TypeCode_Static.cpp @@ -0,0 +1,217 @@ +// $Id$ + +#include "tao/AnyTypeCode/Enum_TypeCode_Static.h" +#include "tao/AnyTypeCode/TypeCode_Traits.h" +#include "tao/ORB_Core.h" +#include "tao/CDR.h" +#include "tao/TypeCodeFactory_Adapter.h" + +#include "ace/Dynamic_Service.h" + +#ifndef __ACE_INLINE__ +# include "tao/AnyTypeCode/Enum_TypeCode_Static.inl" +#endif /* !__ACE_INLINE__ */ + + +ACE_RCSID (AnyTypeCode, + Enum_TypeCode_Static, + "$Id$") + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +bool +TAO::TypeCode::Enum<char const *, + char const * const *, + TAO::Null_RefCount_Policy>::tao_marshal ( + TAO_OutputCDR & cdr, + CORBA::ULong) const +{ + // A tk_enum 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. + TAO_OutputCDR enc; + + bool const success = + (enc << TAO_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER)) + && (enc << TAO_OutputCDR::from_string (this->base_attributes_.id (), 0)) + && (enc << TAO_OutputCDR::from_string (this->base_attributes_.name (), 0)) + && (enc << this->nenumerators_); + + if (!success) + return false; + + char const * const * const begin = &this->enumerators_[0]; + char const * const * const end = begin + this->nenumerators_; + + for (char const * const * i = begin; i != end; ++i) + { + char const * const & enumerator = *i; + + if (!(enc << TAO_OutputCDR::from_string ( + Traits<char const *>::get_string (enumerator), 0))) + return false; + } + + return + cdr << static_cast<CORBA::ULong> (enc.total_length ()) + && cdr.write_octet_array_mb (enc.begin ()); +} + +void +TAO::TypeCode::Enum<char const *, + char const * const *, + TAO::Null_RefCount_Policy>::tao_duplicate (void) +{ +} + +void +TAO::TypeCode::Enum<char const *, + char const * const *, + TAO::Null_RefCount_Policy>::tao_release (void) +{ +} + +CORBA::Boolean +TAO::TypeCode::Enum<char const *, + char const * const *, + TAO::Null_RefCount_Policy>::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_nenumerators = + tc->member_count (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + if (tc_nenumerators != this->nenumerators_) + return false; + + for (CORBA::ULong i = 0; i < this->nenumerators_; ++i) + { + char const * const & lhs_enumerator = this->enumerators_[i]; + + char const * const lhs_name = + Traits<char const *>::get_string (lhs_enumerator); + char const * const rhs_name = tc->member_name (i + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + if (ACE_OS::strcmp (lhs_name, rhs_name) != 0) + return false; + } + + return true; +} + +CORBA::Boolean +TAO::TypeCode::Enum<char const *, + char const * const *, + TAO::Null_RefCount_Policy>::equivalent_i ( + CORBA::TypeCode_ptr tc + ACE_ENV_ARG_DECL) const +{ + // Perform a structural comparison, excluding the name() and + // member_name() operations. + + CORBA::ULong const tc_nenumerators = + tc->member_count (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + if (tc_nenumerators != this->nenumerators_) + return false; + + return true; +} + +CORBA::TypeCode_ptr +TAO::TypeCode::Enum<char const *, + char const * const *, + TAO::Null_RefCount_Policy>::get_compact_typecode_i ( + ACE_ENV_SINGLE_ARG_DECL) const +{ + ACE_Array_Base<CORBA::String_var> tc_enumerators (this->nenumerators_); + + // Dynamically construct a new array of enumerators stripped of + // member names. + + static char const empty_name[] = ""; + + for (CORBA::ULong i = 0; i < this->nenumerators_; ++i) + { + // Member names will be stripped, i.e. not embedded within + // the compact TypeCode. + + tc_enumerators[i] = empty_name; + } + + 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 ()); + } + + return + adapter->create_enum_tc (this->base_attributes_.id (), + "" /* empty name */, + tc_enumerators, + this->nenumerators_ + ACE_ENV_ARG_PARAMETER); +} + +char const * +TAO::TypeCode::Enum<char const *, + char const * const *, + TAO::Null_RefCount_Policy>::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 (); +} + +char const * +TAO::TypeCode::Enum<char const *, + char const * const *, + TAO::Null_RefCount_Policy>::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 (); +} + +CORBA::ULong +TAO::TypeCode::Enum<char const *, + char const * const *, + TAO::Null_RefCount_Policy>::member_count_i ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const +{ + return this->nenumerators_; +} + +char const * +TAO::TypeCode::Enum<char const *, + char const * const *, + TAO::Null_RefCount_Policy>::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->nenumerators_) + ACE_THROW_RETURN (CORBA::TypeCode::Bounds (), 0); + + return Traits<char const *>::get_string (this->enumerators_[index]); +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/Enum_TypeCode_Static.h b/TAO/tao/AnyTypeCode/Enum_TypeCode_Static.h new file mode 100644 index 00000000000..d9f22d44271 --- /dev/null +++ b/TAO/tao/AnyTypeCode/Enum_TypeCode_Static.h @@ -0,0 +1,139 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Enum_TypeCode_Static.h + * + * $Id$ + * + * Header file for a static @c tk_enum CORBA::TypeCode. + * + * @author Ossama Othman <ossama@dre.vanderbilt.edu> + */ +//============================================================================= + +#ifndef TAO_ENUM_TYPECODE_STATIC_H +#define TAO_ENUM_TYPECODE_STATIC_H + +#include /**/ "ace/pre.h" + +#include "tao/AnyTypeCode/TypeCode.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/AnyTypeCode/TypeCode_Base_Attributes.h" +#include "tao/AnyTypeCode/Null_RefCount_Policy.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + namespace TypeCode + { + template <typename StringType, + class EnumeratorArrayType, + class RefCountPolicy> class Enum; + + /** + * @class Enum + * + * @brief @c CORBA::TypeCode implementation for an OMG IDL + * @c enum. + * + * This class implements a @c CORBA::TypeCode for an OMG IDL + * @c enum. + */ + template<> + class TAO_AnyTypeCode_Export Enum<char const *, + char const * const *, + TAO::Null_RefCount_Policy> + : public CORBA::TypeCode, + private TAO::Null_RefCount_Policy + { + public: + + /// Constructor. + Enum (char const * id, + char const * name, + char const * const * enumerators, + CORBA::ULong nenumerators); + + /** + * @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, + CORBA::ULong offset) const; + virtual void tao_duplicate (void); + virtual void tao_release (void); + //@} + + protected: + + /** + * @name @c TAO CORBA::TypeCode Template Methods + * + * @c tk_enum @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::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; + //@} + + private: + + /** + * @c Enum Attributes + * + * Attributes representing the structure of an OMG IDL + * @c enum. + * + * @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 + /// structure type. + Base_Attributes<char const *> base_attributes_; + + /// The number of enumerators in the OMG IDL enumeration. + CORBA::ULong const nenumerators_; + + /// Array of @c TAO::TypeCode enumerators representing + /// enumerators in the OMG IDL defined @c enum. + char const * const * const enumerators_; + + }; + + } // End namespace TypeCode +} // End namespace TAO + +TAO_END_VERSIONED_NAMESPACE_DECL + +#ifdef __ACE_INLINE__ +# include "tao/AnyTypeCode/Enum_TypeCode_Static.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" + +#endif /* TAO_ENUM_TYPECODE_STATIC_H */ diff --git a/TAO/tao/AnyTypeCode/Enum_TypeCode_Static.inl b/TAO/tao/AnyTypeCode/Enum_TypeCode_Static.inl new file mode 100644 index 00000000000..8d2f31eba9c --- /dev/null +++ b/TAO/tao/AnyTypeCode/Enum_TypeCode_Static.inl @@ -0,0 +1,24 @@ +// -*- C++ -*- +// +// $Id$ + + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE +TAO::TypeCode::Enum<char const *, + char const * const *, + TAO::Null_RefCount_Policy>::Enum ( + char const * id, + char const * name, + char const * const * enumerators, + CORBA::ULong nenumerators) + : ::CORBA::TypeCode (CORBA::tk_enum) + , ::TAO::Null_RefCount_Policy () + , base_attributes_ (id, name) + , nenumerators_ (nenumerators) + , enumerators_ (enumerators) +{ +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/ExceptionA.cpp b/TAO/tao/AnyTypeCode/ExceptionA.cpp new file mode 100644 index 00000000000..a38566ee6b7 --- /dev/null +++ b/TAO/tao/AnyTypeCode/ExceptionA.cpp @@ -0,0 +1,122 @@ +// $Id$ + +#include "tao/AnyTypeCode/ExceptionA.h" +#include "tao/AnyTypeCode/Any_Dual_Impl_T.h" +#include "tao/SystemException.h" +#include "tao/Environment.h" +#include "tao/ORB_Constants.h" +#include "tao/CORBA_String.h" +#include "tao/CDR.h" +#include "tao/debug.h" + +#include "ace/Malloc.h" +#include "ace/SString.h" +#include "ace/OS_NS_string.h" + +#include "ace/OS_NS_stdio.h" + +ACE_RCSID (AnyTypeCode, + Exception, + "$Id$") + + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +// Specializations for CORBA::Exception Any operators. +namespace TAO +{ + template<> + void + Any_Dual_Impl_T<CORBA::Exception>::value ( + const CORBA::Exception & val + ) + { + this->value_ = val._tao_duplicate (); + } + + template<> + CORBA::Boolean + Any_Dual_Impl_T<CORBA::Exception>::marshal_value (TAO_OutputCDR &cdr) + { + ACE_TRY_NEW_ENV + { + this->value_->_tao_encode (cdr + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + return true; + } + ACE_CATCHANY + { + } + ACE_ENDTRY; + + return false; + } + + template<> + CORBA::Boolean + Any_Dual_Impl_T<CORBA::Exception>::demarshal_value (TAO_InputCDR &cdr) + { + ACE_TRY_NEW_ENV + { + this->value_->_tao_decode (cdr + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + return true; + } + ACE_CATCHANY + { + } + ACE_ENDTRY; + + return false; + } + + // This should never get called since we don't have extraction operators + // for CORBA::Exception, but it is here to sidestep the constructor call + // in the unspecialized version that causes a problem with compilers that + // require explicit instantiation + template<> + CORBA::Boolean + Any_Dual_Impl_T<CORBA::Exception>::extract ( + const CORBA::Any &, + _tao_destructor, + CORBA::TypeCode_ptr, + const CORBA::Exception *& + ) + { + return false; + } +} + +// ======================================================================= + + +// Insertion of CORBA::Exception - copying. +void +operator<<= (CORBA::Any &any, const CORBA::Exception &exception) +{ + TAO::Any_Dual_Impl_T<CORBA::Exception>::insert_copy ( + any, + CORBA::Exception::_tao_any_destructor, + exception._tao_type (), + exception + ); +} + +// Insertion of CORBA::Exception - non-copying. +void +operator<<= (CORBA::Any &any, CORBA::Exception *exception) +{ + TAO::Any_Dual_Impl_T<CORBA::Exception>::insert ( + any, + CORBA::Exception::_tao_any_destructor, + exception->_tao_type (), + exception + ); +} + + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/ExceptionA.h b/TAO/tao/AnyTypeCode/ExceptionA.h new file mode 100644 index 00000000000..44f6cd6834c --- /dev/null +++ b/TAO/tao/AnyTypeCode/ExceptionA.h @@ -0,0 +1,53 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file ExceptionA.h + * + * $Id$ + * + * This file defines way in which CORBA exceptions are reported. + * + * @author DOC Group at Vanderbilt U., Wash U, and UCI + */ +//============================================================================= + +#ifndef TAO_EXCEPTIONA_H +#define TAO_EXCEPTIONA_H + +#include /**/ "ace/pre.h" + +// Do not try removing this. If you remove this for subsetting lots of +// things go wrong in TAO. +#include "tao/orbconf.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +// This is used in the implementation of the _raise methods +#if defined (TAO_HAS_EXCEPTIONS) +#define TAO_RAISE(EXCEPTION) throw EXCEPTION +#else +#define TAO_RAISE(EXCEPTION) +#endif /* ACE_HAS_EXCEPTIONS */ + +#include "tao/AnyTypeCode/TAO_AnyTypeCode_Export.h" +#include "tao/Exception.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace CORBA +{ + class Any; + typedef Any *Any_ptr; +} + +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, const CORBA::Exception &); +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, CORBA::Exception *); + +TAO_END_VERSIONED_NAMESPACE_DECL + +#include /**/"ace/post.h" + +#endif /* TAO_EXCEPTIONA_H */ diff --git a/TAO/tao/AnyTypeCode/Fixed_TypeCode.cpp b/TAO/tao/AnyTypeCode/Fixed_TypeCode.cpp new file mode 100644 index 00000000000..0fae62d507c --- /dev/null +++ b/TAO/tao/AnyTypeCode/Fixed_TypeCode.cpp @@ -0,0 +1,113 @@ +// $Id$ + +#ifndef TAO_FIXED_TYPECODE_CPP +#define TAO_FIXED_TYPECODE_CPP + +#include "tao/AnyTypeCode/Fixed_TypeCode.h" +#include "tao/CDR.h" + +#ifndef __ACE_INLINE__ +# include "tao/AnyTypeCode/Fixed_TypeCode.inl" +#endif /* !__ACE_INLINE__ */ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +template <class RefCountPolicy> +bool +TAO::TypeCode::Fixed<RefCountPolicy>::tao_marshal (TAO_OutputCDR & cdr, + CORBA::ULong) const +{ + // A tk_fixed TypeCode has a "simple" parameter list type (see + // Table 15-2 in Section 15.3.5.1 "TypeCode" in the CDR section of + // the CORBA specification), meaning that its parameter(s) must be + // marshaled immediately following the TCKind. No CDR encapsulation + // is to be created. + + return (cdr << this->digits_) && (cdr << this->scale_); +} + +template <class RefCountPolicy> +void +TAO::TypeCode::Fixed<RefCountPolicy>::tao_duplicate (void) +{ + this->RefCountPolicy::add_ref (); +} + +template <class RefCountPolicy> +void +TAO::TypeCode::Fixed<RefCountPolicy>::tao_release (void) +{ + this->RefCountPolicy::remove_ref (); +} + +template <class RefCountPolicy> +CORBA::Boolean +TAO::TypeCode::Fixed<RefCountPolicy>::equal_i (CORBA::TypeCode_ptr tc + ACE_ENV_ARG_DECL) const +{ + // The following call won't throw since CORBA::TypeCode::equal() has + // already established the kind of tc is the same as our kind. + CORBA::UShort const tc_digits = + tc->fixed_digits (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + CORBA::UShort const tc_scale = + tc->fixed_scale (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + return (this->digits_ == tc_digits + && this->scale_ == tc_scale); +} + +template <class RefCountPolicy> +CORBA::Boolean +TAO::TypeCode::Fixed<RefCountPolicy>::equivalent_i (CORBA::TypeCode_ptr tc + ACE_ENV_ARG_DECL) const +{ + // Since TCKind comparisons must be performed before equal_i() is + // called, we can also call it to determine equivalence of + // tk_fixed TypeCodes. + return this->equal_i (tc + ACE_ENV_ARG_PARAMETER); +} + +template <class RefCountPolicy> +CORBA::TypeCode_ptr +TAO::TypeCode::Fixed<RefCountPolicy>::get_compact_typecode_i ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const +{ + // Already compact since tk_fixed TypeCodes have no name or member + // names, meaning that we can simply call _duplicate() on this + // TypeCode. + + + // @@ There is a potential problem here if this TypeCode is a static + // and const since it may have been placed in read-only memory by + // the compiler. A const_cast<> can return undefined results in + // that case. + + CORBA::TypeCode_ptr mutable_tc = + const_cast<TAO::TypeCode::Fixed<RefCountPolicy> *> (this); + + return CORBA::TypeCode::_duplicate (mutable_tc); +} + +template <class RefCountPolicy> +CORBA::UShort +TAO::TypeCode::Fixed<RefCountPolicy>::fixed_digits_i ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const +{ + return this->digits_; +} + +template <class RefCountPolicy> +CORBA::UShort +TAO::TypeCode::Fixed<RefCountPolicy>::fixed_scale_i ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const +{ + return this->scale_; +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +#endif /* TAO_FIXED_TYPECODE_CPP */ diff --git a/TAO/tao/AnyTypeCode/Fixed_TypeCode.h b/TAO/tao/AnyTypeCode/Fixed_TypeCode.h new file mode 100644 index 00000000000..3e300cb3658 --- /dev/null +++ b/TAO/tao/AnyTypeCode/Fixed_TypeCode.h @@ -0,0 +1,118 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Fixed_TypeCode.h + * + * $Id$ + * + * Header file for @c CORBA::tk_fixed @c CORBA::TypeCodes. + * + * @author Ossama Othman <ossama@dre.vanderbilt.edu> + */ +//============================================================================= + +#ifndef TAO_FIXED_TYPECODE_H +#define TAO_FIXED_TYPECODE_H + +#include /**/ "ace/pre.h" + +#include "tao/AnyTypeCode/TypeCode.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + namespace TypeCode + { + + /** + * @class Fixed + * + * @brief @c CORBA::TypeCode implementation for the OMG IDL @fixed + * types. + * + * This class implements a @c CORBA::TypeCode for the OMG IDL @c + * fixed types. + */ + template <class RefCountPolicy> + class Fixed + : public CORBA::TypeCode + , private RefCountPolicy + { + public: + + /// Constructor. + Fixed (CORBA::UShort digits, CORBA::UShort scale); + + /** + * @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, + CORBA::ULong offset) const; + virtual void tao_duplicate (void); + virtual void tao_release (void); + //@} + + protected: + + /** + * @name @c TAO CORBA::TypeCode Template Methods + * + * @c CORBA::TypeCode template methods specific to @c tk_fixed + * @c TypeCodes. + * + * @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::TypeCode_ptr get_compact_typecode_i ( + ACE_ENV_SINGLE_ARG_DECL) const; + virtual CORBA::UShort fixed_digits_i (ACE_ENV_SINGLE_ARG_DECL) const; + virtual CORBA::UShort fixed_scale_i (ACE_ENV_SINGLE_ARG_DECL) const; + + private: + + /// The number of significant digits. + CORBA::UShort const digits_; + + /// The scale factor. + CORBA::UShort const scale_; + + }; + + } // End namespace TypeCode +} // End namespace TAO + +TAO_END_VERSIONED_NAMESPACE_DECL + + +#ifdef __ACE_INLINE__ +# include "tao/AnyTypeCode/Fixed_TypeCode.inl" +#endif /* __ACE_INLINE__ */ + +#ifdef ACE_TEMPLATES_REQUIRE_SOURCE +# include "tao/AnyTypeCode/Fixed_TypeCode.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#ifdef ACE_TEMPLATES_REQUIRE_PRAGMA +# pragma implementation ("Fixed_TypeCode.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + + +#include /**/ "ace/post.h" + +#endif /* TAO_FIXED_TYPECODE_H */ diff --git a/TAO/tao/AnyTypeCode/Fixed_TypeCode.inl b/TAO/tao/AnyTypeCode/Fixed_TypeCode.inl new file mode 100644 index 00000000000..62f3e63aac5 --- /dev/null +++ b/TAO/tao/AnyTypeCode/Fixed_TypeCode.inl @@ -0,0 +1,18 @@ +// -*- C++ -*- +// +// $Id$ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +template <class RefCountPolicy> +ACE_INLINE +TAO::TypeCode::Fixed<RefCountPolicy>::Fixed (CORBA::UShort digits, + CORBA::UShort scale) + : ::CORBA::TypeCode (CORBA::tk_fixed) + , RefCountPolicy () + , digits_ (digits) + , scale_ (scale) +{ +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/Marshal.cpp b/TAO/tao/AnyTypeCode/Marshal.cpp new file mode 100644 index 00000000000..0172cf90d26 --- /dev/null +++ b/TAO/tao/AnyTypeCode/Marshal.cpp @@ -0,0 +1,253 @@ + +//============================================================================= +/** + * @file Marshal.cpp + * + * $Id$ + * + * Implements the Marshal_Object class and the factory + * The original encoder and decoder code now appears in files encode.cpp and + * decode.cpp + * + * @author Aniruddha S. Gokhale + * @author Copyright 1994-1995 by Sun Microsystems Inc. + */ +//============================================================================= + +#include "tao/AnyTypeCode/Marshal.h" +#include "tao/AnyTypeCode/TypeCode.h" + +#if !defined (__ACE_INLINE__) +# include "tao/AnyTypeCode/Marshal.inl" +#endif /* ! __ACE_INLINE__ */ + +ACE_RCSID (AnyTypeCode, + Marshal, + "$Id$") + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +TAO_Marshal_Object::~TAO_Marshal_Object (void) +{ +} + +TAO::traverse_status +TAO_Marshal_Object::perform_skip (CORBA::TypeCode_ptr tc, + TAO_InputCDR *stream + ACE_ENV_ARG_DECL) +{ + CORBA::ULong const kind = tc->kind (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + + switch (kind) + { + default: + case CORBA::tk_fixed: + case CORBA::tk_native: + case CORBA::tk_abstract_interface: + case CORBA::tk_component: + case CORBA::tk_home: + // @@ We don't know how to handle any of them yet. + return TAO::TRAVERSE_STOP; + + case CORBA::tk_null: + case CORBA::tk_void: + case CORBA::tk_short: + case CORBA::tk_long: + case CORBA::tk_ushort: + case CORBA::tk_ulong: + case CORBA::tk_float: + case CORBA::tk_double: + case CORBA::tk_boolean: + case CORBA::tk_char: + case CORBA::tk_octet: + case CORBA::tk_longlong: + case CORBA::tk_ulonglong: + case CORBA::tk_longdouble: + case CORBA::tk_wchar: + case CORBA::tk_enum: + { + TAO_Marshal_Primitive marshal; + return marshal.skip (tc, stream ACE_ENV_ARG_PARAMETER); + } + + case CORBA::tk_any: + { + TAO_Marshal_Any marshal; + return marshal.skip (tc, stream ACE_ENV_ARG_PARAMETER); + } + case CORBA::tk_TypeCode: + { + TAO_Marshal_TypeCode marshal; + return marshal.skip (tc, stream ACE_ENV_ARG_PARAMETER); + } + case CORBA::tk_Principal: + { + TAO_Marshal_Principal marshal; + return marshal.skip (tc, stream ACE_ENV_ARG_PARAMETER); + } + case CORBA::tk_objref: + { + TAO_Marshal_ObjRef marshal; + return marshal.skip (tc, stream ACE_ENV_ARG_PARAMETER); + } + case CORBA::tk_struct: + { + TAO_Marshal_Struct marshal; + return marshal.skip (tc, stream ACE_ENV_ARG_PARAMETER); + } + case CORBA::tk_union: + { + TAO_Marshal_Union marshal; + return marshal.skip (tc, stream ACE_ENV_ARG_PARAMETER); + } + case CORBA::tk_string: + { + TAO_Marshal_String marshal; + return marshal.skip (tc, stream ACE_ENV_ARG_PARAMETER); + } + case CORBA::tk_sequence: + { + TAO_Marshal_Sequence marshal; + return marshal.skip (tc, stream ACE_ENV_ARG_PARAMETER); + } + case CORBA::tk_array: + { + TAO_Marshal_Array marshal; + return marshal.skip (tc, stream ACE_ENV_ARG_PARAMETER); + } + case CORBA::tk_alias: + { + TAO_Marshal_Alias marshal; + return marshal.skip (tc, stream ACE_ENV_ARG_PARAMETER); + } + case CORBA::tk_except: + { + TAO_Marshal_Except marshal; + return marshal.skip (tc, stream ACE_ENV_ARG_PARAMETER); + } + case CORBA::tk_wstring: + { + TAO_Marshal_WString marshal; + return marshal.skip (tc, stream ACE_ENV_ARG_PARAMETER); + } + case CORBA::tk_value_box: + case CORBA::tk_value: + { + TAO_Marshal_Value marshal; + return marshal.skip (tc, stream ACE_ENV_ARG_PARAMETER); + } + } +} + +TAO::traverse_status +TAO_Marshal_Object::perform_append (CORBA::TypeCode_ptr tc, + TAO_InputCDR *src, + TAO_OutputCDR *dest + ACE_ENV_ARG_DECL) +{ + CORBA::ULong kind = tc->kind (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + + switch (kind) + { + default: + case CORBA::tk_fixed: + case CORBA::tk_native: + case CORBA::tk_abstract_interface: + case CORBA::tk_component: + case CORBA::tk_home: + // @@ We don't know how to handle any of them yet. + return TAO::TRAVERSE_STOP; + + case CORBA::tk_null: + case CORBA::tk_void: + case CORBA::tk_short: + case CORBA::tk_long: + case CORBA::tk_ushort: + case CORBA::tk_ulong: + case CORBA::tk_float: + case CORBA::tk_double: + case CORBA::tk_boolean: + case CORBA::tk_char: + case CORBA::tk_octet: + case CORBA::tk_longlong: + case CORBA::tk_ulonglong: + case CORBA::tk_longdouble: + case CORBA::tk_wchar: + case CORBA::tk_enum: + { + TAO_Marshal_Primitive marshal; + return marshal.append (tc, src, dest ACE_ENV_ARG_PARAMETER); + } + + case CORBA::tk_any: + { + TAO_Marshal_Any marshal; + return marshal.append (tc, src, dest ACE_ENV_ARG_PARAMETER); + } + case CORBA::tk_TypeCode: + { + TAO_Marshal_TypeCode marshal; + return marshal.append (tc, src, dest ACE_ENV_ARG_PARAMETER); + } + case CORBA::tk_Principal: + { + TAO_Marshal_Principal marshal; + return marshal.append (tc, src, dest ACE_ENV_ARG_PARAMETER); + } + case CORBA::tk_objref: + { + TAO_Marshal_ObjRef marshal; + return marshal.append (tc, src, dest ACE_ENV_ARG_PARAMETER); + } + case CORBA::tk_struct: + { + TAO_Marshal_Struct marshal; + return marshal.append (tc, src, dest ACE_ENV_ARG_PARAMETER); + } + case CORBA::tk_union: + { + TAO_Marshal_Union marshal; + return marshal.append (tc, src, dest ACE_ENV_ARG_PARAMETER); + } + case CORBA::tk_string: + { + TAO_Marshal_String marshal; + return marshal.append (tc, src, dest ACE_ENV_ARG_PARAMETER); + } + case CORBA::tk_sequence: + { + TAO_Marshal_Sequence marshal; + return marshal.append (tc, src, dest ACE_ENV_ARG_PARAMETER); + } + case CORBA::tk_array: + { + TAO_Marshal_Array marshal; + return marshal.append (tc, src, dest ACE_ENV_ARG_PARAMETER); + } + case CORBA::tk_alias: + { + TAO_Marshal_Alias marshal; + return marshal.append (tc, src, dest ACE_ENV_ARG_PARAMETER); + } + case CORBA::tk_except: + { + TAO_Marshal_Except marshal; + return marshal.append (tc, src, dest ACE_ENV_ARG_PARAMETER); + } + case CORBA::tk_wstring: + { + TAO_Marshal_WString marshal; + return marshal.append (tc, src, dest ACE_ENV_ARG_PARAMETER); + } + case CORBA::tk_value_box: + case CORBA::tk_value: + { + TAO_Marshal_Value marshal; + return marshal.append (tc, src, dest ACE_ENV_ARG_PARAMETER); + } + } +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/Marshal.h b/TAO/tao/AnyTypeCode/Marshal.h new file mode 100644 index 00000000000..6232bc5f87d --- /dev/null +++ b/TAO/tao/AnyTypeCode/Marshal.h @@ -0,0 +1,459 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Marshal.h + * + * $Id$ + * + * Classes that marshal various IDL data types. + * + * + * @author Aniruddha S. Gokhale + */ +//============================================================================= + + +#ifndef TAO_MARSHAL_H +#define TAO_MARSHAL_H + +#include /**/ "ace/pre.h" +#include "ace/CORBA_macros.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/AnyTypeCode/TAO_AnyTypeCode_Export.h" +#include "tao/Basic_Types.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace CORBA +{ + class TypeCode; + typedef TypeCode *TypeCode_ptr; + + class Environment; +} + +class TAO_OutputCDR; +class TAO_InputCDR; + +// = Forward declarations. +class TAO_Marshal_Object; +class TAO_Marshal_Primitive; +class TAO_Marshal_Any; +class TAO_Marshal_TypeCode; +class TAO_Marshal_Principal; +class TAO_Marshal_ObjRef; +class TAO_Marshal_Struct; +class TAO_Marshal_Union; +class TAO_Marshal_String; +class TAO_Marshal_Sequence; +class TAO_Marshal_Array; +class TAO_Marshal_Alias; +class TAO_Marshal_Except; +class TAO_Marshal_WString; +class TAO_Marshal_Value; + +namespace TAO +{ + enum traverse_status + { + TRAVERSE_STOP, + TRAVERSE_CONTINUE + }; +} + +/** + * @class TAO_Marshal_Object + * + * @brief TAO_Marshal_Object + * + * The Marshaling object that provides a common interface to the + * CDR object for marshaling different IDL data types + * Provides a set of virtual methods for appending and skipping + * data over a CDR stream. + */ +class TAO_AnyTypeCode_Export TAO_Marshal_Object +{ +public: + /// constructor + TAO_Marshal_Object (void); + + /// destructor + virtual ~TAO_Marshal_Object (void); + + /// skip entry point, it allocates the right kind of Marshal_Object + /// and invokes skip on it. + static TAO::traverse_status perform_skip (CORBA::TypeCode_ptr tc, + TAO_InputCDR *context + ACE_ENV_ARG_DECL); + + /// skip operation + virtual TAO::traverse_status skip (CORBA::TypeCode_ptr tc, + TAO_InputCDR *context + ACE_ENV_ARG_DECL) = 0; + + /// append entry point, it allocates the right kind of Marshal_Object + /// and invokes skip on it. + static TAO::traverse_status perform_append (CORBA::TypeCode_ptr tc, + TAO_InputCDR *src, + TAO_OutputCDR *dest + ACE_ENV_ARG_DECL); + + /// append operation + virtual TAO::traverse_status append (CORBA::TypeCode_ptr tc, + TAO_InputCDR *src, + TAO_OutputCDR *dest + ACE_ENV_ARG_DECL) = 0; +}; + +/** + * @class TAO_Marshal_Primitive: + * + * @brief TAO_Marshal_Primitive + * + * marshaling primitives + */ +class TAO_AnyTypeCode_Export TAO_Marshal_Primitive: public TAO_Marshal_Object +{ +public: + TAO_Marshal_Primitive (void); + + /// skip operation + virtual TAO::traverse_status skip (CORBA::TypeCode_ptr tc, + TAO_InputCDR *context + ACE_ENV_ARG_DECL); + + /// append operation + virtual TAO::traverse_status append (CORBA::TypeCode_ptr tc, + TAO_InputCDR *src, + TAO_OutputCDR *dest + ACE_ENV_ARG_DECL); +}; + +/** + * @class TAO_Marshal_Any: + * + * @brief TAO_Marshal_Any + * + * Marshal an Any + */ +class TAO_AnyTypeCode_Export TAO_Marshal_Any: public TAO_Marshal_Object +{ +public: + TAO_Marshal_Any (void); + + /// skip operation + virtual TAO::traverse_status skip (CORBA::TypeCode_ptr tc, + TAO_InputCDR *context + ACE_ENV_ARG_DECL); + + /// append operation + virtual TAO::traverse_status append (CORBA::TypeCode_ptr tc, + TAO_InputCDR *src, + TAO_OutputCDR *dest + ACE_ENV_ARG_DECL); +}; + +/** + * @class TAO_Marshal_TypeCode: + * + * @brief TAO_Marshal_TypeCode + * + * marshal a typecode + */ +class TAO_AnyTypeCode_Export TAO_Marshal_TypeCode: public TAO_Marshal_Object +{ +public: + TAO_Marshal_TypeCode (void); + + /// skip operation + virtual TAO::traverse_status skip (CORBA::TypeCode_ptr tc, + TAO_InputCDR *context + ACE_ENV_ARG_DECL); + + /// append operation + virtual TAO::traverse_status append (CORBA::TypeCode_ptr tc, + TAO_InputCDR *src, + TAO_OutputCDR *dest + ACE_ENV_ARG_DECL); +}; + +/** + * @class TAO_Marshal_Principal: + * + * @brief TAO_Marshal_Principal + * + * marshal a principal + */ +class TAO_AnyTypeCode_Export TAO_Marshal_Principal: public TAO_Marshal_Object +{ +public: + TAO_Marshal_Principal (void); + + /// skip operation + virtual TAO::traverse_status skip (CORBA::TypeCode_ptr tc, + TAO_InputCDR *context + ACE_ENV_ARG_DECL); + + /// append operation + virtual TAO::traverse_status append (CORBA::TypeCode_ptr tc, + TAO_InputCDR *src, + TAO_OutputCDR *dest + ACE_ENV_ARG_DECL); +}; + +/** + * @class TAO_Marshal_ObjRef: + * + * @brief TAO_Marshal_ObjRef + * + * marshal an object reference + */ +class TAO_AnyTypeCode_Export TAO_Marshal_ObjRef: public TAO_Marshal_Object +{ +public: + TAO_Marshal_ObjRef (void); + + /// skip operation + virtual TAO::traverse_status skip (CORBA::TypeCode_ptr tc, + TAO_InputCDR *context + ACE_ENV_ARG_DECL); + + /// append operation + virtual TAO::traverse_status append (CORBA::TypeCode_ptr tc, + TAO_InputCDR *src, + TAO_OutputCDR *dest + ACE_ENV_ARG_DECL); +}; + +/** + * @class TAO_Marshal_Struct: + * + * @brief TAO_Marshal_Struct + * + * marshal a struct + */ +class TAO_AnyTypeCode_Export TAO_Marshal_Struct: public TAO_Marshal_Object +{ +public: + TAO_Marshal_Struct (void); + + /// skip operation + virtual TAO::traverse_status skip (CORBA::TypeCode_ptr tc, + TAO_InputCDR *context + ACE_ENV_ARG_DECL); + + /// append operation + virtual TAO::traverse_status append (CORBA::TypeCode_ptr tc, + TAO_InputCDR *src, + TAO_OutputCDR *dest + ACE_ENV_ARG_DECL); +}; + +/** + * @class TAO_Marshal_Union: + * + * @brief TAO_Marshal_Union + * + * marshal a union + */ +class TAO_AnyTypeCode_Export TAO_Marshal_Union: public TAO_Marshal_Object +{ +public: + TAO_Marshal_Union (void); + + /// skip operation + virtual TAO::traverse_status skip (CORBA::TypeCode_ptr tc, + TAO_InputCDR *context + ACE_ENV_ARG_DECL); + + /// append operation + virtual TAO::traverse_status append (CORBA::TypeCode_ptr tc, + TAO_InputCDR *src, + TAO_OutputCDR *dest + ACE_ENV_ARG_DECL); +}; + +/** + * @class TAO_Marshal_String: + * + * @brief TAO_Marshal_String + * + * marshal a string + */ +class TAO_AnyTypeCode_Export TAO_Marshal_String: public TAO_Marshal_Object +{ +public: + TAO_Marshal_String (void); + + /// skip operation + virtual TAO::traverse_status skip (CORBA::TypeCode_ptr tc, + TAO_InputCDR *context + ACE_ENV_ARG_DECL); + + /// append operation + virtual TAO::traverse_status append (CORBA::TypeCode_ptr tc, + TAO_InputCDR *src, + TAO_OutputCDR *dest + ACE_ENV_ARG_DECL); +}; + +/** + * @class TAO_Marshal_Sequence: + * + * @brief TAO_Marshal_Sequence + * + * marshal a sequence + */ +class TAO_AnyTypeCode_Export TAO_Marshal_Sequence: public TAO_Marshal_Object +{ +public: + TAO_Marshal_Sequence (void); + + /// skip operation + virtual TAO::traverse_status skip (CORBA::TypeCode_ptr tc, + TAO_InputCDR *context + ACE_ENV_ARG_DECL); + + /// append operation + virtual TAO::traverse_status append (CORBA::TypeCode_ptr tc, + TAO_InputCDR *src, + TAO_OutputCDR *dest + ACE_ENV_ARG_DECL); +}; + +/** + * @class TAO_Marshal_Array: + * + * @brief TAO_Marshal_Array + * + * marshal an array + */ +class TAO_AnyTypeCode_Export TAO_Marshal_Array: public TAO_Marshal_Object +{ +public: + TAO_Marshal_Array (void); + + /// skip operation + virtual TAO::traverse_status skip (CORBA::TypeCode_ptr tc, + TAO_InputCDR *context + ACE_ENV_ARG_DECL); + + /// append operation + virtual TAO::traverse_status append (CORBA::TypeCode_ptr tc, + TAO_InputCDR *src, + TAO_OutputCDR *dest + ACE_ENV_ARG_DECL); +}; + +/** + * @class TAO_Marshal_Alias: + * + * @brief TAO_Marshal_Alias + * + * marshal an alias + */ +class TAO_AnyTypeCode_Export TAO_Marshal_Alias: public TAO_Marshal_Object +{ +public: + TAO_Marshal_Alias (void); + + /// skip operation + virtual TAO::traverse_status skip (CORBA::TypeCode_ptr tc, + TAO_InputCDR *context + ACE_ENV_ARG_DECL); + + /// append operation + virtual TAO::traverse_status append (CORBA::TypeCode_ptr tc, + TAO_InputCDR *src, + TAO_OutputCDR *dest + ACE_ENV_ARG_DECL); +}; + +/** + * @class TAO_Marshal_Except: + * + * @brief TAO_Marshal_Except + * + * marshal an exception + */ +class TAO_AnyTypeCode_Export TAO_Marshal_Except: public TAO_Marshal_Object +{ +public: + TAO_Marshal_Except (void); + + /// skip operation + virtual TAO::traverse_status skip (CORBA::TypeCode_ptr tc, + TAO_InputCDR *context + ACE_ENV_ARG_DECL); + + /// append operation + virtual TAO::traverse_status append (CORBA::TypeCode_ptr tc, + TAO_InputCDR *src, + TAO_OutputCDR *dest + ACE_ENV_ARG_DECL); +}; + +/** + * @class TAO_Marshal_WString + * + * @brief TAO_Marshal_WString + * + * marshal a wide string + */ +class TAO_AnyTypeCode_Export TAO_Marshal_WString : public TAO_Marshal_Object +{ +public: + TAO_Marshal_WString (void); + + /// skip operation + virtual TAO::traverse_status skip (CORBA::TypeCode_ptr tc, + TAO_InputCDR *context + ACE_ENV_ARG_DECL); + + /// append operation + virtual TAO::traverse_status append (CORBA::TypeCode_ptr tc, + TAO_InputCDR *src, + TAO_OutputCDR *dest + ACE_ENV_ARG_DECL); +}; + +/** + * @class TAO_Marshal_Value: + * + * @brief TAO_Marshal_Value + * + * marshal a valuetype + */ +class TAO_AnyTypeCode_Export TAO_Marshal_Value: public TAO_Marshal_Object +{ +public: + TAO_Marshal_Value (void); + + /// skip operation + virtual TAO::traverse_status skip (CORBA::TypeCode_ptr tc, + TAO_InputCDR *context + ACE_ENV_ARG_DECL); + + /// append operation + virtual TAO::traverse_status append (CORBA::TypeCode_ptr tc, + TAO_InputCDR *src, + TAO_OutputCDR *dest + ACE_ENV_ARG_DECL); + +private: + CORBA::Boolean nested_processing_; +}; + +TAO_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +# include "tao/AnyTypeCode/Marshal.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" +#endif /* TAO_MARSHAL_H */ diff --git a/TAO/tao/AnyTypeCode/Marshal.inl b/TAO/tao/AnyTypeCode/Marshal.inl new file mode 100644 index 00000000000..cb1fb80d2c4 --- /dev/null +++ b/TAO/tao/AnyTypeCode/Marshal.inl @@ -0,0 +1,83 @@ +// -*- C++ -*- +// +//$Id$ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE +TAO_Marshal_Object::TAO_Marshal_Object (void) +{ +} + +ACE_INLINE +TAO_Marshal_Primitive::TAO_Marshal_Primitive (void) +{ +} + +ACE_INLINE +TAO_Marshal_Any::TAO_Marshal_Any (void) +{ +} + +ACE_INLINE +TAO_Marshal_Principal::TAO_Marshal_Principal (void) +{ +} + +ACE_INLINE +TAO_Marshal_TypeCode::TAO_Marshal_TypeCode (void) +{ +} + +ACE_INLINE +TAO_Marshal_ObjRef::TAO_Marshal_ObjRef (void) +{ +} + +ACE_INLINE +TAO_Marshal_Struct::TAO_Marshal_Struct (void) +{ +} + +ACE_INLINE +TAO_Marshal_Union::TAO_Marshal_Union (void) +{ +} + +ACE_INLINE +TAO_Marshal_String::TAO_Marshal_String (void) +{ +} + +ACE_INLINE +TAO_Marshal_Sequence::TAO_Marshal_Sequence (void) +{ +} + +ACE_INLINE +TAO_Marshal_Array::TAO_Marshal_Array (void) +{ +} + +ACE_INLINE +TAO_Marshal_Alias::TAO_Marshal_Alias (void) +{ +} + +ACE_INLINE +TAO_Marshal_Except::TAO_Marshal_Except (void) +{ +} + +ACE_INLINE +TAO_Marshal_WString::TAO_Marshal_WString (void) +{ +} + +ACE_INLINE +TAO_Marshal_Value::TAO_Marshal_Value (void) + : nested_processing_ (false) +{ +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/NVList.cpp b/TAO/tao/AnyTypeCode/NVList.cpp new file mode 100644 index 00000000000..0a0b9ef54ee --- /dev/null +++ b/TAO/tao/AnyTypeCode/NVList.cpp @@ -0,0 +1,501 @@ +// $Id$ + + +// Implementation of Named Value List and NamedValue classes + +#include "tao/AnyTypeCode/NVList.h" +#include "tao/AnyTypeCode/BoundsC.h" +#include "tao/AnyTypeCode/TypeCode.h" +#include "tao/AnyTypeCode/Marshal.h" +#include "tao/AnyTypeCode/Any_Impl.h" + +#include "tao/SystemException.h" +#include "tao/CORBA_String.h" +#include "tao/CDR.h" +#include "tao/debug.h" + +#include "ace/Auto_Ptr.h" +#include "ace/Log_Msg.h" + +#if !defined (__ACE_INLINE__) +# include "tao/AnyTypeCode/NVList.inl" +#endif /* ! __ACE_INLINE__ */ + +ACE_RCSID (AnyTypeCode, + NVList, + "$Id$") + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +// Reference counting for DII Request object + +CORBA::ULong +CORBA::NamedValue::_incr_refcnt (void) +{ + return ++this->refcount_; +} + +CORBA::ULong +CORBA::NamedValue::_decr_refcnt (void) +{ + const CORBA::ULong new_count = --this->refcount_; + + if (new_count == 0) + delete this; + + return new_count; +} + +CORBA::NamedValue::~NamedValue (void) +{ + if (this->name_) + { + CORBA::string_free (this->name_); + this->name_ = 0; + } + // the any will be destroyed by itself +} + +// **************************************************************** + +CORBA::ULong +CORBA::NVList::_incr_refcnt (void) +{ + return ++this->refcount_; +} + +CORBA::ULong +CORBA::NVList::_decr_refcnt (void) +{ + const CORBA::ULong new_count = --this->refcount_; + + if (new_count == 0) + delete this; + + return new_count; +} + +CORBA::NVList::~NVList (void) +{ + // initialize an iterator and delete each NamedValue + ACE_Unbounded_Queue_Iterator<CORBA::NamedValue_ptr> iter (this->values_); + + for (iter.first (); !iter.done (); iter.advance ()) + { + CORBA::NamedValue_ptr *nv = 0; + (void) iter.next (nv); + delete *nv; + } + + this->max_ = 0; + + // Remove the CDR stream if it is present. + delete this->incoming_; +} + +// add an element and just initialize its flags +CORBA::NamedValue_ptr +CORBA::NVList::add (CORBA::Flags flags + ACE_ENV_ARG_DECL) +{ + // call the helper to allocate a NamedValue element (if necessary) + return this->add_element (flags + ACE_ENV_ARG_PARAMETER); +} + +// add an element and just initialize its flags and name +CORBA::NamedValue_ptr +CORBA::NVList::add_item (const char *name, + CORBA::Flags flags + ACE_ENV_ARG_DECL) +{ + // call the helper to allocate a NamedValue element + CORBA::NamedValue_ptr nv = this->add_element (flags + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + if (nv) + { + // now initialize the fields + nv->name_ = CORBA::string_dup (name); + return nv; + } + else + { + return 0; + } +} + +// add a value. If necessary, increment the list +CORBA::NamedValue_ptr +CORBA::NVList::add_value (const char *name, + const CORBA::Any &value, + CORBA::Flags flags + ACE_ENV_ARG_DECL) +{ + // Call the helper to allocate a NamedValue element. + CORBA::NamedValue_ptr nv = this->add_element (flags + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + if (nv) + { + nv->name_ = CORBA::string_dup (name); + + // With the original Any implementation, we had alternate + // paths for the assignment based on the IN_COPY_VALUE flag. + // Now that the Any's contained Any_Impl is refcounted, the + // distinction between the ORB "copying" or "borrowing" the + // memory is irrelevant. The IN_COPY_VALUE flag was not + // checked anywhere else in the ORB anyway. + nv->any_ = value; + return nv; + } + else + { + return 0; + } +} + +// add an element and just initialize its flags and name +CORBA::NamedValue_ptr +CORBA::NVList::add_item_consume (char *name, + CORBA::Flags flags + ACE_ENV_ARG_DECL) +{ + + // call the helper to allocate a NamedValue element + CORBA::NamedValue_ptr nv = this->add_element (flags + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + if (nv) + { + // now initialize the fields + + // consume the name + nv->name_ = name; + return nv; + } + else + { + return 0; + } +} + +// add a value. If necessary, increment the list +CORBA::NamedValue_ptr +CORBA::NVList::add_value_consume (char * name, + CORBA::Any * value, + CORBA::Flags flags + ACE_ENV_ARG_DECL) +{ + // call the helper to allocate a NamedValue element + CORBA::NamedValue_ptr nv = this->add_element (flags + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + if (nv) + { + // now initialize the fields + + // consume name + nv->name_ = name; + + // consume the value @@ (ASG) have we? we may need to destroy + // the in parameter + nv->any_ = *value; + return nv; + } + else + { + return 0; + } +} + +//CORBA::Status +void +CORBA::NVList::remove (CORBA::ULong /* n */ + ACE_ENV_ARG_DECL_NOT_USED) +{ + // not implemented + // @@ (ASG) - TODO +} + +// Helper method +CORBA::NamedValue_ptr +CORBA::NVList::add_element (CORBA::Flags flags + ACE_ENV_ARG_DECL) +{ + this->evaluate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (CORBA::NamedValue::_nil ()); + + if (ACE_BIT_DISABLED (flags, + CORBA::ARG_IN | CORBA::ARG_OUT | CORBA::ARG_INOUT)) + { + ACE_THROW_RETURN (CORBA::BAD_PARAM (), + CORBA::NamedValue::_nil ()); + } + + CORBA::NamedValue_ptr nv; + + // allocate a new NamedValue + ACE_NEW_THROW_EX (nv, + CORBA::NamedValue, + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (CORBA::NamedValue::_nil ()); + + // set the flags and enqueue in the queue + nv->flags_ = flags; + + if (this->values_.enqueue_tail (nv) == -1) + { + delete nv; + return 0; + } + + this->max_++; + return nv; // success +} + +// return the item at location n +CORBA::NamedValue_ptr +CORBA::NVList::item (CORBA::ULong n + ACE_ENV_ARG_DECL) +{ + this->evaluate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (CORBA::NamedValue::_nil ()); + + if (n >= this->max_) + { + ACE_THROW_RETURN (CORBA::Bounds (), + CORBA::NamedValue::_nil ()); + } + + CORBA::NamedValue_ptr *nv = 0; + + this->values_.get (nv, n); + return *nv; +} + +void +CORBA::NVList::_tao_incoming_cdr (TAO_InputCDR &cdr, + int flag, + bool &lazy_evaluation + ACE_ENV_ARG_DECL) +{ + // If the list is empty then using lazy evaluation is the only + // choice. + // @@ There are other cases where we can use lazy evaluation, for + // example if the list is not empty but the anys own all their + // objects. + if (lazy_evaluation == false && this->max_ == 0) + { + lazy_evaluation = true; + } + + if (lazy_evaluation == false) + { + this->_tao_decode (cdr, + flag + ACE_ENV_ARG_PARAMETER); + return; + } + + ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->lock_); + + if (this->incoming_ != 0) + { + delete this->incoming_; + this->incoming_ = 0; + } + + ACE_NEW (this->incoming_, TAO_InputCDR (cdr)); + this->incoming_flag_ = flag; +} + +void +CORBA::NVList::_tao_encode (TAO_OutputCDR &cdr, + int flag + ACE_ENV_ARG_DECL) +{ + ACE_GUARD (TAO_SYNCH_MUTEX, + ace_mon, + this->lock_); + + if (this->incoming_ != 0) + { + if (this->max_ == 0) + { + // The list is empty aggresively reduce copies and just send + // the CDR stream, we assume that + // TAO_Server_Request::init_reply + // has inserted appropiated padding already to make this + // operation correct + cdr.write_octet_array_mb (this->incoming_->start ()); + return; + } + + // Then unmarshal each "in" and "inout" parameter. + ACE_Unbounded_Queue_Iterator<CORBA::NamedValue_ptr> i (this->values_); + + for (i.first (); !i.done (); i.advance ()) + { + CORBA::NamedValue_ptr *item = 0; + (void) i.next (item); + + CORBA::NamedValue_ptr nv = *item; + + if (ACE_BIT_DISABLED (nv->flags (), flag)) + { + continue; + } + + if (TAO_debug_level > 3) + { + const char* arg = nv->name (); + + if (arg == 0) + { + arg = "(nil)"; + } + + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("NVList::_tao_encode - parameter <%s>\n"), + ACE_TEXT_CHAR_TO_TCHAR (arg))); + } + CORBA::TypeCode_ptr tc = nv->value ()->_tao_get_typecode (); + (void) TAO_Marshal_Object::perform_append (tc, + this->incoming_, + &cdr + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } + + delete this->incoming_; + this->incoming_ = 0; + return; + } + + // The list is already evaluated, we cannot optimize the copies, go + // ahead with the slow way to do things. + + // Then marshal each "in" and "inout" parameter. + ACE_Unbounded_Queue_Iterator<CORBA::NamedValue_ptr> i (this->values_); + + for (i.first (); !i.done (); i.advance ()) + { + CORBA::NamedValue_ptr *item = 0; + (void) i.next (item); + + CORBA::NamedValue_ptr nv = *item; + + if (ACE_BIT_DISABLED (nv->flags (), flag)) + { + continue; + } + + nv->value ()->impl ()->marshal_value (cdr); + } +} + +void +CORBA::NVList::_tao_decode (TAO_InputCDR &incoming, + int flag + ACE_ENV_ARG_DECL) +{ + if (TAO_debug_level > 3) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("TAO (%P|%t) : NVList::_tao_decode\n"))); + } + + // Then unmarshal each "in" and "inout" parameter. + ACE_Unbounded_Queue_Iterator<CORBA::NamedValue_ptr> i (this->values_); + + for (i.first (); !i.done (); i.advance ()) + { + CORBA::NamedValue_ptr *item = 0; + (void) i.next (item); + + CORBA::NamedValue_ptr nv = *item; + + // check if it is an in or inout parameter + // @@ this is where we assume that the NVList is coming from + // a Server-side request, we could probably handle both + // cases with a flag, but there is no clear need for that. + if (ACE_BIT_DISABLED (nv->flags (), flag)) + { + continue; + } + + if (TAO_debug_level > 3) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("TAO (%P|%t) : NVList::_tao_decode - %s\n"), + ACE_TEXT_CHAR_TO_TCHAR (nv->name ()? nv->name () : "(no name given)" ))); + } + + CORBA::Any_ptr any = nv->value (); + any->impl ()->_tao_decode (incoming + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } +} + +ptrdiff_t +CORBA::NVList::_tao_target_alignment (void) +{ + ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, + ace_mon, + this->lock_, + ACE_CDR::MAX_ALIGNMENT); + + if (this->incoming_ == 0) + { + return ACE_CDR::MAX_ALIGNMENT; + } + + const char* rd = this->incoming_->start ()->rd_ptr (); + ptrdiff_t t = ptrdiff_t (rd) % ACE_CDR::MAX_ALIGNMENT; + + if (t < 0) + { + t += ACE_CDR::MAX_ALIGNMENT; + } + + return t; +} + +void +CORBA::NVList::evaluate (ACE_ENV_SINGLE_ARG_DECL) +{ + ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->lock_); + + if (this->incoming_ == 0) + { + return; + } + + auto_ptr<TAO_InputCDR> incoming (this->incoming_); + this->incoming_ = 0; + + this->_tao_decode (*(incoming.get ()), + this->incoming_flag_ + ACE_ENV_ARG_PARAMETER); +} + +CORBA::Boolean +CORBA::NVList::_lazy_has_arguments (void) const +{ + if (this->incoming_ != 0) + { + return this->incoming_->length () == 0 ? 0 : 1; + } + else + { + return this->count () == 0 ? 0 : 1; + } +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/NVList.h b/TAO/tao/AnyTypeCode/NVList.h new file mode 100644 index 00000000000..d78a228726a --- /dev/null +++ b/TAO/tao/AnyTypeCode/NVList.h @@ -0,0 +1,314 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file NVList.h + * + * $Id$ + * + * @author Copyright 1994-1995 by Sun Microsystems Inc. + * @author Aniruddha Gokhale <gokhale@cs.wustl.edu> + */ +//============================================================================= + + +#ifndef TAO_NVLIST_H +#define TAO_NVLIST_H + +#include /**/ "ace/pre.h" +#include "ace/CORBA_macros.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/AnyTypeCode/AnyTypeCode_methods.h" +#include "tao/AnyTypeCode/Any.h" +#include "tao/AnyTypeCode/NVList_Adapter_Impl.h" + +#include "tao/Environment.h" + +#include "ace/Unbounded_Queue.h" +#include "ace/Thread_Mutex.h" +#include "ace/Atomic_Op.h" + + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +class TAO_InputCDR; + +namespace CORBA +{ + enum + { + // = Flags for NVList add methods + ARG_IN = 0x01, + ARG_OUT = 0x02, + ARG_INOUT = 0x04, + IN_COPY_VALUE = 0x08, + OUT_LIST_MEMORY = 0x10, + DEPENDENT_LIST = 0x20, + + // = (Unused) flags for Context methods + CTX_RESTRICT_SCOPE = 0x40, + CTX_DELETE_DESCENDENTS = 0x80, + + // = Flags for deferred synchronous methods + INV_NO_RESPONSE = 0x100, + INV_TERM_ON_ERR = 0x200, + RESP_NO_WAIT = 0x400 + }; + + typedef TAO_Pseudo_Var_T<NamedValue> NamedValue_var; + typedef TAO_Pseudo_Out_T<NamedValue> NamedValue_out; + + typedef ULong Flags; + + /** + * @class NamedValue + * + * @brief CORBA Name/value pair implementation. + * + * These occur only in "NVList" (named value list) data structures. + * The binary form of the data structure is frozen and visible to + * programs using it (e.g. from C). The C++ class supports some + * programming discipline, e.g. to avoid memory leaks. They just + * represent parameters to calls. The name is optional, and the + * value is packaged as an Any. The flags indicate parameter mode, + * and some ownership rules for "top level" memory. + */ + class TAO_AnyTypeCode_Export NamedValue + { + friend class ::TAO_NVList_Adapter_Impl; + friend class NVList; + friend class Request; + + public: + /// optional name + const char * name (void) const; + + /// return the value + Any_ptr value (void) const; + + /// return the parameter mode flag + Flags flags (void) const; + + // The pseudo object static methods.. + static NamedValue * _duplicate (NamedValue *); + static NamedValue * _nil (void); + + // = Reference counting. + ULong _incr_refcnt (void); + ULong _decr_refcnt (void); + + // Useful for template programming. + typedef NamedValue_ptr _ptr_type; + typedef NamedValue_var _var_type; + typedef NamedValue_out _out_type; + + protected: + + /// Destructor + /** + * Protected destructor to enforce proper memory management + * through the reference counting mechanism. + */ + ~NamedValue (void); + + private: + + /// private constructor. Cannot be directly instantiated other than + /// by its friends. + NamedValue (void); + + private: + + /// Reference counter. + ACE_Atomic_Op<TAO_SYNCH_MUTEX, unsigned long> refcount_; + + /// holds the value + Any any_; + + /// parameter mode flags + Flags flags_; + + /// optional IDL name of the parameter + char * name_; + }; + + // **************************************************************** + + typedef TAO_Pseudo_Var_T<NVList> NVList_var; + typedef TAO_Pseudo_Out_T<NVList> NVList_out; + + /** + * @class NVList + * + * @brief CORBA::NVList implementation. + + * This is used in the (client side) DII (Dynamic Invocation + * Interface) to hold parameters, except for the return + * parameter. It's used in the same role in the (server side) DSI + * (Dynamic Skeleton Interface). + * + * Each user (client, server) provides the typecode and memory for + * each parameter using an NVList, then talks to the ORB using a + * Request or ServerRequest pseudo-object. The ORB copies data + * to/from the IPC messages (e.g. IIOP::Request, IIOP::Response) + * as appropriate. + */ + class TAO_AnyTypeCode_Export NVList + { + friend class ::TAO_NVList_Adapter_Impl; + friend class Request; + + public: + + /// return the current number of elements in the list + ULong count (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) const; + + /// add an element and just initialize the flags + NamedValue_ptr add (Flags + ACE_ENV_ARG_DECL_WITH_DEFAULTS); + + /// add an element and initialize its name and flags + NamedValue_ptr add_item (const char *, + Flags + ACE_ENV_ARG_DECL_WITH_DEFAULTS); + + /// initializes a value, name, and flags + NamedValue_ptr add_value (const char *, + const Any &, + Flags + ACE_ENV_ARG_DECL_WITH_DEFAULTS); + + /// just like add_item. In addition, memory management of char * + /// name is taken over by the NVList + NamedValue_ptr add_item_consume (char *, + Flags + ACE_ENV_ARG_DECL_WITH_DEFAULTS); + + /// just like add_value. In addition, the NVList controls the + /// memory management of the char *name and Any *value parameter + NamedValue_ptr add_value_consume (char *, + Any_ptr, + Flags + ACE_ENV_ARG_DECL_WITH_DEFAULTS); + + /// retrieve the item at the nth location. Raises Bounds + NamedValue_ptr item (ULong n + ACE_ENV_ARG_DECL_WITH_DEFAULTS); + + // CORBA::Status + /// remove element at index n. Raises Bounds + void remove (ULong n + ACE_ENV_ARG_DECL_WITH_DEFAULTS); + + // The pseudo object static methods.. + static NVList * _duplicate (NVList *); + static NVList * _nil (void); + + // = Reference counting. + ULong _incr_refcnt (void); + ULong _decr_refcnt (void); + + // = TAO Extensions: + + /** + * Set the incoming CDR stream, this is used by TAO to perform lazy + * evaluation of the NVList in an incoming ServerRequest. + * The <flag> is used to check which parameters (IN, OUT and/or + * INOUT) are to be extracted + */ + void _tao_incoming_cdr (TAO_InputCDR & cdr, + int flag, + bool &lazy_evaluation + ACE_ENV_ARG_DECL); + + /// Encode the NVList into the CDR stream. <flag> masks the type of + /// arguments (IN, OUT or INOUT) that are to be marshaled. + void _tao_encode (TAO_OutputCDR & cdr, + int flag + ACE_ENV_ARG_DECL_WITH_DEFAULTS); + + /// Decode the NVList arguments from the <cdr> stream. + void _tao_decode (TAO_InputCDR & cdr, + int flag + ACE_ENV_ARG_DECL); + + /** + * Return the required alignment to marshal the NVList without any + * re-alignment. + * It returns ACE_CDR::MAX_ALIGNMENT to indicate errors. + */ + ptrdiff_t _tao_target_alignment (void); + + /** + * If this list is used by a DII request, this will tell us if + * our CDR stream contains any marshaled arguments (needed for + * GIOP 1.2). + */ + Boolean _lazy_has_arguments (void) const; + + // Useful for template programming. + typedef NVList_ptr _ptr_type; + typedef NVList_var _var_type; + typedef NVList_out _out_type; + + protected: + + /// Destructor + /** + * Protected destructor to enforce proper memory management + * through the reference counting mechanism. + */ + ~NVList (void); + + private: + /// constructor - cannot be instantiated directly other than + /// through the CORBA::ORB::create_list method + NVList (void); + + /// helper to increase the list size. This is used by all the add_ + /// methods of the NVList class + NamedValue_ptr add_element (Flags + ACE_ENV_ARG_DECL_WITH_DEFAULTS); + + /// Lazy evaluation routine to fill up the Anys in the NVList from + /// the CDR stream. + void evaluate (ACE_ENV_SINGLE_ARG_DECL); + + private: + /// internal list of parameters stored as NamedValues + ACE_Unbounded_Queue<NamedValue_ptr> values_; + + /// maximum length of list + ULong max_; + + /// Reference counter. + ACE_Atomic_Op<TAO_SYNCH_MUTEX, unsigned long> refcount_; + + /// Protects the incoming pointer. + TAO_SYNCH_MUTEX lock_; + + /** + * When the NVList is used as part of a Server Request we can simply + * store the CDR buffer and perform lazy evaluation to compute the + * Anys. + */ + TAO_InputCDR * incoming_; + + /// The flags used to check which parameters are actually extracted + /// from the <incoming_> buffer + int incoming_flag_; + }; +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +# include "tao/AnyTypeCode/NVList.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" +#endif /* TAO_NVLIST_H */ diff --git a/TAO/tao/AnyTypeCode/NVList.inl b/TAO/tao/AnyTypeCode/NVList.inl new file mode 100644 index 00000000000..e89db0e4dfb --- /dev/null +++ b/TAO/tao/AnyTypeCode/NVList.inl @@ -0,0 +1,130 @@ +// -*- C++ -*- +// +// $Id$ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE CORBA::Boolean +CORBA::is_nil (CORBA::NamedValue_ptr nv) +{ + return nv == 0; +} + +ACE_INLINE void +CORBA::release (CORBA::NamedValue_ptr nv) +{ + if (nv) + nv->_decr_refcnt (); +} + +// ************************************************************* + +ACE_INLINE +CORBA::NamedValue::NamedValue (void) + : refcount_ (1), + flags_ (0), + name_ (0) +{ +} + +ACE_INLINE +const char * +CORBA::NamedValue::name (void) const +{ + return this->name_; +} + +ACE_INLINE +CORBA::Any_ptr +CORBA::NamedValue::value (void) const +{ + return const_cast<CORBA::Any_ptr> (&this->any_); +} + +ACE_INLINE +CORBA::Flags +CORBA::NamedValue::flags (void) const +{ + return this->flags_; +} + +ACE_INLINE +CORBA::NamedValue * +CORBA::NamedValue::_duplicate (CORBA::NamedValue * x) +{ + if (x != 0) + { + x->_incr_refcnt (); + } + + return x; +} + +ACE_INLINE +CORBA::NamedValue* +CORBA::NamedValue::_nil (void) +{ + return 0; +} + +// ************************************************************* + +ACE_INLINE +CORBA::Boolean +CORBA::is_nil (CORBA::NVList_ptr nvl) +{ + return (CORBA::Boolean) (nvl == 0); +} + +ACE_INLINE +void +CORBA::release (CORBA::NVList_ptr nvl) +{ + if (nvl) + { + nvl->_decr_refcnt (); + } +} + +// **************************************************************** + +ACE_INLINE +CORBA::NVList::NVList (void) + : max_ (0), + refcount_ (1), + incoming_ (0), + incoming_flag_ (0) +{ +} + +ACE_INLINE +CORBA::ULong +CORBA::NVList::count (ACE_ENV_SINGLE_ARG_DECL) const +{ + (const_cast<CORBA::NVList *> (this))->evaluate ( + ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + return this->max_; +} + +ACE_INLINE +CORBA::NVList * +CORBA::NVList::_duplicate (CORBA::NVList * x) +{ + if (x != 0) + { + x->_incr_refcnt (); + } + + return x; +} + +ACE_INLINE +CORBA::NVList * +CORBA::NVList::_nil (void) +{ + return 0; +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/NVList_Adapter_Impl.cpp b/TAO/tao/AnyTypeCode/NVList_Adapter_Impl.cpp new file mode 100644 index 00000000000..7ed8cb3d983 --- /dev/null +++ b/TAO/tao/AnyTypeCode/NVList_Adapter_Impl.cpp @@ -0,0 +1,81 @@ +// @(#) $Id$ + +#include "tao/AnyTypeCode/NVList_Adapter_Impl.h" + +ACE_RCSID (AnyTypeCode, + NVList_Adapter_Impl, + "$Id$") + +#include "tao/AnyTypeCode/NVList.h" +#include "tao/SystemException.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +void +TAO_NVList_Adapter_Impl::create_list ( + CORBA::Long count, + CORBA::NVList_ptr &new_list + ACE_ENV_ARG_DECL) +{ + ACE_ASSERT (CORBA::ULong (count) <= UINT_MAX); + // Create an empty list + ACE_NEW_THROW_EX (new_list, + CORBA::NVList, + CORBA::NO_MEMORY ( + CORBA::SystemException::_tao_minor_code ( + 0, + ENOMEM), + CORBA::COMPLETED_NO)); + ACE_CHECK; + + // If count is greater than 0, create a list of NamedValues. + if (count != 0) + { + new_list->max_ = (CORBA::ULong) count; + + for (CORBA::Long i = 0; i < count; ++i) + { + CORBA::NamedValue_ptr nv = 0; + ACE_NEW_THROW_EX (nv, + CORBA::NamedValue, + CORBA::NO_MEMORY ( + CORBA::SystemException::_tao_minor_code ( + 0, + ENOMEM), + CORBA::COMPLETED_NO)); + ACE_CHECK; + + new_list->values_.enqueue_tail (nv); + } + } +} + +void +TAO_NVList_Adapter_Impl::create_named_value ( + CORBA::NamedValue_ptr &nv + ACE_ENV_ARG_DECL) +{ + ACE_NEW_THROW_EX (nv, + CORBA::NamedValue, + CORBA::NO_MEMORY ( + CORBA::SystemException::_tao_minor_code ( + 0, + ENOMEM), + CORBA::COMPLETED_NO)); +} + +int +TAO_NVList_Adapter_Impl::Initializer (void) +{ + return ACE_Service_Config::process_directive (ace_svc_desc_TAO_NVList_Adapter_Impl); +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +ACE_STATIC_SVC_DEFINE (TAO_NVList_Adapter_Impl, + ACE_TEXT ("TAO_NVList_Adapter"), + ACE_SVC_OBJ_T, + &ACE_SVC_NAME (TAO_NVList_Adapter_Impl), + ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ, + 0) +ACE_FACTORY_DEFINE (TAO_AnyTypeCode, TAO_NVList_Adapter_Impl) diff --git a/TAO/tao/AnyTypeCode/NVList_Adapter_Impl.h b/TAO/tao/AnyTypeCode/NVList_Adapter_Impl.h new file mode 100644 index 00000000000..e24ebd357c5 --- /dev/null +++ b/TAO/tao/AnyTypeCode/NVList_Adapter_Impl.h @@ -0,0 +1,59 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file NVList_Adapter_Impl.h + * + * $Id$ + * + * @author Johnny Willemsen <jwillemsen@remedy.nl> + */ +//============================================================================= + +#ifndef TAO_NVLIST_ADAPTER_IMPL_H +#define TAO_NVLIST_ADAPTER_IMPL_H + +#include /**/ "ace/pre.h" + +#include "tao/AnyTypeCode/TAO_AnyTypeCode_Export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/NVList_Adapter.h" +#include "ace/Service_Config.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class TAO_NVList_Adapter + */ +class TAO_AnyTypeCode_Export TAO_NVList_Adapter_Impl + : public TAO_NVList_Adapter +{ +public: + virtual void create_list ( + CORBA::Long count, + CORBA::NVList_ptr &new_list + ACE_ENV_ARG_DECL); + + virtual void create_named_value ( + CORBA::NamedValue_ptr &nv + ACE_ENV_ARG_DECL); + + /// Used to force the initialization of the NVList adapter + static int Initializer (void); +}; + +static int TAO_Requires_NVList_Adapter_Impl_Initializer = + TAO_NVList_Adapter_Impl::Initializer (); + +TAO_END_VERSIONED_NAMESPACE_DECL + +ACE_STATIC_SVC_DECLARE (TAO_NVList_Adapter_Impl) +ACE_FACTORY_DECLARE (TAO_AnyTypeCode, TAO_NVList_Adapter_Impl) + + +#include /**/ "ace/post.h" +#endif /* TAO_NVLIST_ADAPTER_IMPL_H */ diff --git a/TAO/tao/AnyTypeCode/Null_RefCount_Policy.h b/TAO/tao/AnyTypeCode/Null_RefCount_Policy.h new file mode 100644 index 00000000000..8a39b8e9c52 --- /dev/null +++ b/TAO/tao/AnyTypeCode/Null_RefCount_Policy.h @@ -0,0 +1,84 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Null_RefCount_Policy.h + * + * $Id$ + * + * Header file for TAO's reference count policy (unrelated to CORBA + * policies). + * + * @author Ossama Othman <ossama@dre.vanderbilt.edu> + */ +//============================================================================= + +#ifndef TAO_NULL_REFCOUNT_POLICY_H +#define TAO_NULL_REFCOUNT_POLICY_H + +#include /**/ "ace/pre.h" + +#include "tao/AnyTypeCode/TAO_AnyTypeCode_Export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/Versioned_Namespace.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + + /** + * @class Null_RefCount_Policy + * + * @brief No-op reference counting policy. + * + * This class is intended to be used as a "policy" argument to a + * host class template that implements no-op reference counting. + * That class would then inherit privately from it like so: + * + * @code + * template <class RefCountPolicy> + * class MyHostClass : private RefCountPolicy + * { + * public: + * void my_add_ref (void) { this->RefCountPolicy::add_ref (); } + * void my_remove_ref (void) { this->RefCountPolicy::remove_ref (); } + * }; + * @endcode + * + * and use it like so: + * + * @code + * typedef MyHostClass<TAO::Null_RefCount_Policy> MyNonRefCountedClass; + * MyNonRefCountedClass m; + * ... + * @endcode + * + * @note In order to incur no size overhead on the host class due to + * virtual tables, no base class defining an interface is + * defined. This allows C++ compilers to apply the Empty Base + * Class Optimization. + */ + class TAO_AnyTypeCode_Export Null_RefCount_Policy + { + public: + + /// No-op reference increment. + void add_ref (void) { } + + /// No-op reference decrement. + void remove_ref (void) { } + + }; + +} // End namespace TAO + +TAO_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" + +#endif /* TAO_NULL_REFCOUNT_POLICY_H */ diff --git a/TAO/tao/AnyTypeCode/Objref_TypeCode.cpp b/TAO/tao/AnyTypeCode/Objref_TypeCode.cpp new file mode 100644 index 00000000000..c897143e4dc --- /dev/null +++ b/TAO/tao/AnyTypeCode/Objref_TypeCode.cpp @@ -0,0 +1,157 @@ +// $Id$ + +#ifndef TAO_OBJREF_TYPECODE_CPP +#define TAO_OBJREF_TYPECODE_CPP + +#include "tao/AnyTypeCode/Objref_TypeCode.h" + +#ifndef __ACE_INLINE__ +# include "tao/AnyTypeCode/Objref_TypeCode.inl" +#endif /* !__ACE_INLINE__ */ + +#include "tao/CDR.h" +#include "tao/ORB_Core.h" + +#include "ace/OS_NS_string.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +template <typename StringType, class RefCountPolicy> +bool +TAO::TypeCode::Objref<StringType, RefCountPolicy>::tao_marshal ( + TAO_OutputCDR & cdr, + CORBA::ULong) const +{ + // A tk_objref 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. + TAO_OutputCDR enc; + + return + enc << TAO_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER) + && enc << TAO_OutputCDR::from_string (this->attributes_.id (), 0) + && enc << TAO_OutputCDR::from_string (this->attributes_.name (), 0) + && cdr << static_cast<CORBA::ULong> (enc.total_length ()) + && cdr.write_octet_array_mb (enc.begin ()); +} + +template <typename StringType, class RefCountPolicy> +void +TAO::TypeCode::Objref<StringType, RefCountPolicy>::tao_duplicate (void) +{ + this->RefCountPolicy::add_ref (); +} + +template <typename StringType, class RefCountPolicy> +void +TAO::TypeCode::Objref<StringType, RefCountPolicy>::tao_release (void) +{ + this->RefCountPolicy::remove_ref (); +} + +template <typename StringType, class RefCountPolicy> +CORBA::Boolean +TAO::TypeCode::Objref<StringType, RefCountPolicy>::equal_i ( + CORBA::TypeCode_ptr /* tc */ + ACE_ENV_ARG_DECL_NOT_USED) const +{ + // Equality has already been established in the + // CORBA::TypeCode base class. + + return true; +} + +template <typename StringType, class RefCountPolicy> +CORBA::Boolean +TAO::TypeCode::Objref<StringType, RefCountPolicy>::equivalent_i ( + CORBA::TypeCode_ptr + ACE_ENV_ARG_DECL_NOT_USED) const +{ + // Equivalence already verified in the base class + // CORBA::TypeCode::equivalent() method. + + return true; +} + +template <typename StringType, class RefCountPolicy> +CORBA::TypeCode_ptr +TAO::TypeCode::Objref<StringType, + RefCountPolicy>::get_compact_typecode_i ( + ACE_ENV_SINGLE_ARG_DECL) const +{ + TAO_TypeCodeFactory_Adapter * const 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 ()); + } + + if (this->kind_ == CORBA::tk_abstract_interface) + { + return adapter->create_abstract_interface_tc (this->attributes_.id (), + "" /* empty name */ + ACE_ENV_ARG_PARAMETER); + } + else if (this->kind_ == CORBA::tk_component) + { + return adapter->create_component_tc (this->attributes_.id (), + "" /* empty name */ + ACE_ENV_ARG_PARAMETER); + } + else if (this->kind_ == CORBA::tk_home) + { + return adapter->create_home_tc (this->attributes_.id (), + "" /* empty name */ + ACE_ENV_ARG_PARAMETER); + } + else if (this->kind_ == CORBA::tk_local_interface) + { + return adapter->create_local_interface_tc (this->attributes_.id (), + "" /* empty name */ + ACE_ENV_ARG_PARAMETER); + + } + else if (this->kind_ == CORBA::tk_native) + { + return adapter->create_native_tc (this->attributes_.id (), + "" /* empty name */ + ACE_ENV_ARG_PARAMETER); + } + else // CORBA::tk_objref + { + return adapter->create_interface_tc (this->attributes_.id (), + "" /* empty name */ + ACE_ENV_ARG_PARAMETER); + } +} + +template <typename StringType, class RefCountPolicy> +char const * +TAO::TypeCode::Objref<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::Objref<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 (); +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +#endif /* TAO_OBJREF_TYPECODE_CPP */ diff --git a/TAO/tao/AnyTypeCode/Objref_TypeCode.h b/TAO/tao/AnyTypeCode/Objref_TypeCode.h new file mode 100644 index 00000000000..8444669513a --- /dev/null +++ b/TAO/tao/AnyTypeCode/Objref_TypeCode.h @@ -0,0 +1,125 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Objref_TypeCode.h + * + * $Id$ + * + * Header file for + * @c tk_abstract_interface, + * @c tk_component, + * @c tk_home, + * @c tk_local_interface, + * @c tk_native and + * @c tk_objref + * @c CORBA::TypeCodes. + * + * @author Ossama Othman <ossama@dre.vanderbilt.edu> + */ +//============================================================================= + +#ifndef TAO_OBJREF_TYPECODE_H +#define TAO_OBJREF_TYPECODE_H + +#include /**/ "ace/pre.h" + +#include "tao/AnyTypeCode/TypeCode.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/AnyTypeCode/TypeCode_Base_Attributes.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + namespace TypeCode + { + /** + * @class Objref_Base + * + * @brief @c CORBA::TypeCode implementation for an OMG IDL + * @c object and object-like types. + * + * This class implements a @c CORBA::TypeCode for an OMG IDL + * @c object (interface) and object-like types (abstract + * interface, component, home, local interface and native). + */ + template <typename StringType, class RefCountPolicy> + class Objref + : public CORBA::TypeCode, + private RefCountPolicy + { + public: + + /// Constructor. + Objref (CORBA::TCKind kind, + char const * id, + char const * name); + + /** + * @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, + CORBA::ULong offset) const; + virtual void tao_duplicate (void); + virtual void tao_release (void); + //@} + + protected: + + /** + * @name @c TAO CORBA::TypeCode Template Methods + * + * @c tk_abstract_interface, @c tk_component, @c + * tk_local_interface, @c tk_native and @c tk_objref + * @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::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; + + protected: + + /// Base attributes (@c id and @c name). + Base_Attributes<StringType> attributes_; + + }; + + } // End namespace TypeCode +} // End namespace TAO + +TAO_END_VERSIONED_NAMESPACE_DECL + +#ifdef __ACE_INLINE__ +# include "tao/AnyTypeCode/Objref_TypeCode.inl" +#endif /* __ACE_INLINE__ */ + +#ifdef ACE_TEMPLATES_REQUIRE_SOURCE +# include "tao/AnyTypeCode/Objref_TypeCode.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#ifdef ACE_TEMPLATES_REQUIRE_PRAGMA +# pragma implementation ("Objref_TypeCode.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" + +#endif /* TAO_OBJREF_TYPECODE_H */ diff --git a/TAO/tao/AnyTypeCode/Objref_TypeCode.inl b/TAO/tao/AnyTypeCode/Objref_TypeCode.inl new file mode 100644 index 00000000000..de813439b87 --- /dev/null +++ b/TAO/tao/AnyTypeCode/Objref_TypeCode.inl @@ -0,0 +1,19 @@ +// -*- C++ -*- +// +// $Id$ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +template <typename StringType, class RefCountPolicy> +ACE_INLINE +TAO::TypeCode::Objref<StringType, RefCountPolicy>::Objref ( + CORBA::TCKind kind, + char const * id, + char const * name) + : ::CORBA::TypeCode (kind) + , RefCountPolicy () + , attributes_ (id, name) +{ +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/Objref_TypeCode_Static.cpp b/TAO/tao/AnyTypeCode/Objref_TypeCode_Static.cpp new file mode 100644 index 00000000000..883b13ab3ed --- /dev/null +++ b/TAO/tao/AnyTypeCode/Objref_TypeCode_Static.cpp @@ -0,0 +1,151 @@ +// $Id$ + +#include "tao/AnyTypeCode/Objref_TypeCode_Static.h" + +#ifndef __ACE_INLINE__ +# include "tao/AnyTypeCode/Objref_TypeCode_Static.inl" +#endif /* !__ACE_INLINE__ */ + +#include "tao/CDR.h" +#include "tao/TypeCodeFactory_Adapter.h" +#include "tao/ORB_Core.h" + +#include "ace/Dynamic_Service.h" +#include "ace/OS_NS_string.h" + + +ACE_RCSID (AnyTypeCode, + Objref_TypeCode_Static, + "$Id$") + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +bool +TAO::TypeCode::Objref<char const *, TAO::Null_RefCount_Policy>::tao_marshal ( + TAO_OutputCDR & cdr, + CORBA::ULong) const +{ + // A tk_objref 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. + TAO_OutputCDR enc; + + return + enc << TAO_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER) + && enc << TAO_OutputCDR::from_string (this->attributes_.id (), 0) + && enc << TAO_OutputCDR::from_string (this->attributes_.name (), 0) + && cdr << static_cast<CORBA::ULong> (enc.total_length ()) + && cdr.write_octet_array_mb (enc.begin ()); +} + +void +TAO::TypeCode::Objref<char const *, + TAO::Null_RefCount_Policy>::tao_duplicate (void) +{ +} + +void +TAO::TypeCode::Objref<char const *, + TAO::Null_RefCount_Policy>::tao_release (void) +{ +} + +CORBA::Boolean +TAO::TypeCode::Objref<char const *, TAO::Null_RefCount_Policy>::equal_i ( + CORBA::TypeCode_ptr /* tc */ + ACE_ENV_ARG_DECL_NOT_USED) const +{ + // Equality has already been established in the + // CORBA::TypeCode base class. + + return true; +} + +CORBA::Boolean +TAO::TypeCode::Objref<char const *, TAO::Null_RefCount_Policy>::equivalent_i ( + CORBA::TypeCode_ptr + ACE_ENV_ARG_DECL_NOT_USED) const +{ + // Equivalence already verified in the base class + // CORBA::TypeCode::equivalent() method. + + return true; +} + +CORBA::TypeCode_ptr +TAO::TypeCode::Objref<char const *, + TAO::Null_RefCount_Policy>::get_compact_typecode_i ( + ACE_ENV_SINGLE_ARG_DECL) const +{ + TAO_TypeCodeFactory_Adapter * const 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 ()); + } + + if (this->kind_ == CORBA::tk_abstract_interface) + { + return adapter->create_abstract_interface_tc (this->attributes_.id (), + "" /* empty name */ + ACE_ENV_ARG_PARAMETER); + } + else if (this->kind_ == CORBA::tk_component) + { + return adapter->create_component_tc (this->attributes_.id (), + "" /* empty name */ + ACE_ENV_ARG_PARAMETER); + } + else if (this->kind_ == CORBA::tk_home) + { + return adapter->create_home_tc (this->attributes_.id (), + "" /* empty name */ + ACE_ENV_ARG_PARAMETER); + } + else if (this->kind_ == CORBA::tk_local_interface) + { + return adapter->create_local_interface_tc (this->attributes_.id (), + "" /* empty name */ + ACE_ENV_ARG_PARAMETER); + + } + else if (this->kind_ == CORBA::tk_native) + { + return adapter->create_native_tc (this->attributes_.id (), + "" /* empty name */ + ACE_ENV_ARG_PARAMETER); + } + else // CORBA::tk_objref + { + return adapter->create_interface_tc (this->attributes_.id (), + "" /* empty name */ + ACE_ENV_ARG_PARAMETER); + } +} + +char const * +TAO::TypeCode::Objref<char const *, TAO::Null_RefCount_Policy>::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 (); +} + +char const * +TAO::TypeCode::Objref<char const *, TAO::Null_RefCount_Policy>::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 (); +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/Objref_TypeCode_Static.h b/TAO/tao/AnyTypeCode/Objref_TypeCode_Static.h new file mode 100644 index 00000000000..f67bb980e66 --- /dev/null +++ b/TAO/tao/AnyTypeCode/Objref_TypeCode_Static.h @@ -0,0 +1,121 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Objref_TypeCode_Static.h + * + * $Id$ + * + * Header file for static + * @c tk_abstract_interface, + * @c tk_component, + * @c tk_home, + * @c tk_local_interface, + * @c tk_native and + * @c tk_objref + * @c CORBA::TypeCodes. + * + * @author Ossama Othman <ossama@dre.vanderbilt.edu> + */ +//============================================================================= + +#ifndef TAO_OBJREF_TYPECODE_STATIC_H +#define TAO_OBJREF_TYPECODE_STATIC_H + +#include /**/ "ace/pre.h" + +#include "tao/AnyTypeCode/TypeCode.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/AnyTypeCode/TypeCode_Base_Attributes.h" +#include "tao/AnyTypeCode/Null_RefCount_Policy.h" + + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + namespace TypeCode + { + template <typename StringType, class RefCountPolicy> class Objref; + + /** + * @class Objref + * + * @brief @c CORBA::TypeCode implementation for an OMG IDL + * @c object and object-like types. + * + * This class implements a @c CORBA::TypeCode for an OMG IDL + * @c object (interface) and object-like types (abstract + * interface, component, home, local interface and native). + */ + template<> + class TAO_AnyTypeCode_Export Objref<char const *, TAO::Null_RefCount_Policy> + : public CORBA::TypeCode, + private TAO::Null_RefCount_Policy + { + public: + + /// Constructor. + Objref (CORBA::TCKind kind, + char const * id, + char const * name); + + /** + * @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, + CORBA::ULong offset) const; + virtual void tao_duplicate (void); + virtual void tao_release (void); + //@} + + protected: + + /** + * @name @c TAO CORBA::TypeCode Template Methods + * + * @c tk_abstract_interface, @c tk_component, @c + * tk_local_interface, @c tk_native and @c tk_objref + * @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::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; + + protected: + + /// Base attributes (@c id and @c name). + Base_Attributes<char const *> attributes_; + + }; + + } // End namespace TypeCode +} // End namespace TAO + +TAO_END_VERSIONED_NAMESPACE_DECL + +#ifdef __ACE_INLINE__ +# include "tao/AnyTypeCode/Objref_TypeCode_Static.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" + +#endif /* TAO_OBJREF_TYPECODE_STATIC_H */ diff --git a/TAO/tao/AnyTypeCode/Objref_TypeCode_Static.inl b/TAO/tao/AnyTypeCode/Objref_TypeCode_Static.inl new file mode 100644 index 00000000000..b9492be9bf2 --- /dev/null +++ b/TAO/tao/AnyTypeCode/Objref_TypeCode_Static.inl @@ -0,0 +1,18 @@ +// -*- C++ -*- +// +// $Id$ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE +TAO::TypeCode::Objref<char const *, TAO::Null_RefCount_Policy>::Objref ( + CORBA::TCKind kind, + char const * id, + char const * name) + : ::CORBA::TypeCode (kind) + , ::TAO::Null_RefCount_Policy () + , attributes_ (id, name) +{ +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/OctetSeqA.cpp b/TAO/tao/AnyTypeCode/OctetSeqA.cpp new file mode 100644 index 00000000000..dd6b7864968 --- /dev/null +++ b/TAO/tao/AnyTypeCode/OctetSeqA.cpp @@ -0,0 +1,146 @@ +// -*- C++ -*- +// +// $Id$ + +// **** Code generated by the The ACE ORB (TAO) IDL Compiler **** +// TAO and the TAO IDL Compiler have been developed by: +// Center for Distributed Object Computing +// Washington University +// St. Louis, MO +// USA +// http://www.cs.wustl.edu/~schmidt/doc-center.html +// and +// Distributed Object Computing Laboratory +// University of California at Irvine +// Irvine, CA +// USA +// http://doc.ece.uci.edu/ +// and +// Institute for Software Integrated Systems +// Vanderbilt University +// Nashville, TN +// USA +// http://www.isis.vanderbilt.edu/ +// +// Information about TAO is available at: +// http://www.cs.wustl.edu/~schmidt/TAO.html + +#include "tao/AnyTypeCode/OctetSeqA.h" +#include "tao/AnyTypeCode/Null_RefCount_Policy.h" +#include "tao/AnyTypeCode/TypeCode_Constants.h" +#include "tao/AnyTypeCode/Alias_TypeCode_Static.h" +#include "tao/AnyTypeCode/Sequence_TypeCode_Static.h" +#include "tao/CDR.h" +#include "tao/AnyTypeCode/Any.h" +#include "tao/AnyTypeCode/Any_Dual_Impl_T.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +// TAO_IDL - Generated from +// be\be_visitor_typecode/alias_typecode.cpp:50 + + + +// TAO_IDL - Generated from +// be\be_visitor_typecode/typecode_defn.cpp:937 + + +#ifndef _TAO_TYPECODE_CORBA_OctetSeq_GUARD +#define _TAO_TYPECODE_CORBA_OctetSeq_GUARD +namespace TAO +{ + namespace TypeCode + { + TAO::TypeCode::Sequence< ::CORBA::TypeCode_ptr const *, + TAO::Null_RefCount_Policy> + CORBA_OctetSeq_0 ( + CORBA::tk_sequence, + &CORBA::_tc_octet, + 0U); + + ::CORBA::TypeCode_ptr const tc_CORBA_OctetSeq_0 = + &CORBA_OctetSeq_0; + + } +} + + +#endif /* _TAO_TYPECODE_CORBA_OctetSeq_GUARD */ + +static TAO::TypeCode::Alias<char const *, + CORBA::TypeCode_ptr const *, + TAO::Null_RefCount_Policy> + _tao_tc_CORBA_OctetSeq ( + CORBA::tk_alias, + "IDL:omg.org/CORBA/OctetSeq:1.0", + "OctetSeq", + &TAO::TypeCode::tc_CORBA_OctetSeq_0); + +namespace CORBA +{ + ::CORBA::TypeCode_ptr const _tc_OctetSeq = + &_tao_tc_CORBA_OctetSeq; +} + + + +// TAO_IDL - Generated from +// be\be_visitor_sequence/any_op_cs.cpp:54 + + +// Copying insertion. +void operator<<= ( + CORBA::Any &_tao_any, + const CORBA::OctetSeq &_tao_elem + ) +{ + TAO::Any_Dual_Impl_T<CORBA::OctetSeq>::insert_copy ( + _tao_any, + CORBA::OctetSeq::_tao_any_destructor, + TAO::TypeCode::tc_CORBA_OctetSeq_0, + _tao_elem + ); +} + +// Non-copying insertion. +void operator<<= ( + CORBA::Any &_tao_any, + CORBA::OctetSeq *_tao_elem + ) +{ + TAO::Any_Dual_Impl_T<CORBA::OctetSeq>::insert ( + _tao_any, + CORBA::OctetSeq::_tao_any_destructor, + TAO::TypeCode::tc_CORBA_OctetSeq_0, + _tao_elem + ); +} + +// Extraction to non-const pointer (deprecated). +CORBA::Boolean operator>>= ( + const CORBA::Any &_tao_any, + CORBA::OctetSeq *&_tao_elem + ) +{ + return _tao_any >>= const_cast< + const CORBA::OctetSeq *&> ( + _tao_elem + ); +} + +// Extraction to const pointer. +CORBA::Boolean operator>>= ( + const CORBA::Any &_tao_any, + const CORBA::OctetSeq *&_tao_elem + ) +{ + return + TAO::Any_Dual_Impl_T<CORBA::OctetSeq>::extract ( + _tao_any, + CORBA::OctetSeq::_tao_any_destructor, + TAO::TypeCode::tc_CORBA_OctetSeq_0, + _tao_elem + ); +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/OctetSeqA.h b/TAO/tao/AnyTypeCode/OctetSeqA.h new file mode 100644 index 00000000000..8b94976cb20 --- /dev/null +++ b/TAO/tao/AnyTypeCode/OctetSeqA.h @@ -0,0 +1,71 @@ +// -*- C++ -*- +// +// $Id$ + +// **** Code generated by the The ACE ORB (TAO) IDL Compiler **** +// TAO and the TAO IDL Compiler have been developed by: +// Center for Distributed Object Computing +// Washington University +// St. Louis, MO +// USA +// http://www.cs.wustl.edu/~schmidt/doc-center.html +// and +// Distributed Object Computing Laboratory +// University of California at Irvine +// Irvine, CA +// USA +// http://doc.ece.uci.edu/ +// and +// Institute for Software Integrated Systems +// Vanderbilt University +// Nashville, TN +// USA +// http://www.isis.vanderbilt.edu/ +// +// Information about TAO is available at: +// http://www.cs.wustl.edu/~schmidt/TAO.html + +// TAO_IDL - Generated from +// be\be_codegen.cpp:788 + +#ifndef _TAO_IDL_ANYTYPECODE_OCTETSEQA_H_ +#define _TAO_IDL_ANYTYPECODE_OCTETSEQA_H_ + +#include /**/ "ace/pre.h" + +#include "tao/AnyTypeCode/TAO_AnyTypeCode_Export.h" +#include "tao/AnyTypeCode/AnyTypeCode_methods.h" +#include "tao/OctetSeqC.h" + + +// TAO_IDL - Generated from +// be\be_visitor_module/module_ch.cpp:59 + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace CORBA +{ + + // TAO_IDL - Generated from + // be\be_visitor_typecode/typecode_decl.cpp:49 + + extern TAO_AnyTypeCode_Export ::CORBA::TypeCode_ptr const _tc_OctetSeq; + +// TAO_IDL - Generated from +// be\be_visitor_module/module_ch.cpp:86 + +} // module CORBA + +// TAO_IDL - Generated from +// be\be_visitor_sequence/any_op_ch.cpp:53 + +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, const CORBA::OctetSeq &); // copying version +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, CORBA::OctetSeq*); // noncopying version +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any &, CORBA::OctetSeq *&); // deprecated +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any &, const CORBA::OctetSeq *&); + +TAO_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" + +#endif /* ifndef */ diff --git a/TAO/tao/AnyTypeCode/PolicyA.cpp b/TAO/tao/AnyTypeCode/PolicyA.cpp new file mode 100644 index 00000000000..9d49724bc2f --- /dev/null +++ b/TAO/tao/AnyTypeCode/PolicyA.cpp @@ -0,0 +1,561 @@ +// -*- C++ -*- +// +// $Id$ + +// **** Code generated by the The ACE ORB (TAO) IDL Compiler **** +// TAO and the TAO IDL Compiler have been developed by: +// Center for Distributed Object Computing +// Washington University +// St. Louis, MO +// USA +// http://www.cs.wustl.edu/~schmidt/doc-center.html +// and +// Distributed Object Computing Laboratory +// University of California at Irvine +// Irvine, CA +// USA +// http://doc.ece.uci.edu/ +// and +// Institute for Software Integrated Systems +// Vanderbilt University +// Nashville, TN +// USA +// http://www.isis.vanderbilt.edu/ +// +// Information about TAO is available at: +// http://www.cs.wustl.edu/~schmidt/TAO.html + +#include "tao/AnyTypeCode/PolicyA.h" +#include "tao/AnyTypeCode/Null_RefCount_Policy.h" +#include "tao/AnyTypeCode/TypeCode_Constants.h" +#include "tao/AnyTypeCode/Alias_TypeCode_Static.h" +#include "tao/AnyTypeCode/Objref_TypeCode_Static.h" +#include "tao/AnyTypeCode/Struct_TypeCode_Static.h" +#include "tao/AnyTypeCode/TypeCode_Struct_Field.h" +#include "tao/CDR.h" +#include "tao/AnyTypeCode/Any.h" +#include "tao/AnyTypeCode/Any_Impl_T.h" +#include "tao/AnyTypeCode/Any_Dual_Impl_T.h" + +#include "tao/AnyTypeCode/UShortSeqA.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +// TAO_IDL - Generated from +// be\be_visitor_typecode/alias_typecode.cpp:50 + +static TAO::TypeCode::Alias<char const *, + CORBA::TypeCode_ptr const *, + TAO::Null_RefCount_Policy> + _tao_tc_CORBA_PolicyErrorCode ( + CORBA::tk_alias, + "IDL:omg.org/CORBA/PolicyErrorCode:1.0", + "PolicyErrorCode", + &CORBA::_tc_short); + +namespace CORBA +{ + ::CORBA::TypeCode_ptr const _tc_PolicyErrorCode = + &_tao_tc_CORBA_PolicyErrorCode; +} + + + +// TAO_IDL - Generated from +// be\be_visitor_typecode/struct_typecode.cpp:87 + +static TAO::TypeCode::Struct_Field<char const *, CORBA::TypeCode_ptr const *> const _tao_fields_CORBA_PolicyError[] = + { + { "reason", &CORBA::_tc_PolicyErrorCode } + + }; +static TAO::TypeCode::Struct<char const *, + CORBA::TypeCode_ptr const *, + TAO::TypeCode::Struct_Field<char const *, CORBA::TypeCode_ptr const *> const *, + TAO::Null_RefCount_Policy> + _tao_tc_CORBA_PolicyError ( + CORBA::tk_except, + "IDL:omg.org/CORBA/PolicyError:1.0", + "PolicyError", + _tao_fields_CORBA_PolicyError, + 1); + +namespace CORBA +{ + ::CORBA::TypeCode_ptr const _tc_PolicyError = + &_tao_tc_CORBA_PolicyError; +} + + + +// TAO_IDL - Generated from +// be\be_visitor_typecode/struct_typecode.cpp:87 + + + +// TAO_IDL - Generated from +// be\be_visitor_typecode/typecode_defn.cpp:937 + +static TAO::TypeCode::Struct_Field<char const *, CORBA::TypeCode_ptr const *> const _tao_fields_CORBA_InvalidPolicies[] = + { + { "indices", &CORBA::_tc_UShortSeq } + + }; +static TAO::TypeCode::Struct<char const *, + CORBA::TypeCode_ptr const *, + TAO::TypeCode::Struct_Field<char const *, CORBA::TypeCode_ptr const *> const *, + TAO::Null_RefCount_Policy> + _tao_tc_CORBA_InvalidPolicies ( + CORBA::tk_except, + "IDL:omg.org/CORBA/InvalidPolicies:1.0", + "InvalidPolicies", + _tao_fields_CORBA_InvalidPolicies, + 1); + +namespace CORBA +{ + ::CORBA::TypeCode_ptr const _tc_InvalidPolicies = + &_tao_tc_CORBA_InvalidPolicies; +} + + + +// TAO_IDL - Generated from +// be\be_visitor_typecode/objref_typecode.cpp:76 + +static TAO::TypeCode::Objref<char const *, + TAO::Null_RefCount_Policy> + _tao_tc_CORBA_Policy ( + CORBA::tk_objref, + "IDL:omg.org/CORBA/Policy:1.0", + "Policy"); + +namespace CORBA +{ + ::CORBA::TypeCode_ptr const _tc_Policy = + &_tao_tc_CORBA_Policy; +} + + + +// TAO_IDL - Generated from +// be\be_visitor_typecode/objref_typecode.cpp:76 + +static TAO::TypeCode::Objref<char const *, + TAO::Null_RefCount_Policy> + _tao_tc_CORBA_PolicyManager ( + CORBA::tk_local_interface, + "IDL:omg.org/CORBA/PolicyManager:1.0", + "PolicyManager"); + +namespace CORBA +{ + ::CORBA::TypeCode_ptr const _tc_PolicyManager = + &_tao_tc_CORBA_PolicyManager; +} + + + +// TAO_IDL - Generated from +// be\be_visitor_typecode/objref_typecode.cpp:76 + +static TAO::TypeCode::Objref<char const *, + TAO::Null_RefCount_Policy> + _tao_tc_CORBA_PolicyCurrent ( + CORBA::tk_local_interface, + "IDL:omg.org/CORBA/PolicyCurrent:1.0", + "PolicyCurrent"); + +namespace CORBA +{ + ::CORBA::TypeCode_ptr const _tc_PolicyCurrent = + &_tao_tc_CORBA_PolicyCurrent; +} + + + +// TAO_IDL - Generated from +// be\be_visitor_exception/any_op_cs.cpp:50 + +namespace TAO +{ + template<> + CORBA::Boolean + Any_Dual_Impl_T<CORBA::PolicyError>::demarshal_value ( + TAO_InputCDR & cdr + ) + { + CORBA::String_var id; + + if (!(cdr >> id.out ())) + { + return false; + } + + ACE_TRY_NEW_ENV + { + this->value_->_tao_decode (cdr ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + return false; + } + ACE_ENDTRY; + + return true; + } +} + +// Copying insertion. +void operator<<= ( + CORBA::Any &_tao_any, + const CORBA::PolicyError &_tao_elem + ) +{ + TAO::Any_Dual_Impl_T<CORBA::PolicyError>::insert_copy ( + _tao_any, + CORBA::PolicyError::_tao_any_destructor, + CORBA::_tc_PolicyError, + _tao_elem + ); +} + +// Non-copying insertion. +void operator<<= ( + CORBA::Any &_tao_any, + CORBA::PolicyError *_tao_elem + ) +{ + TAO::Any_Dual_Impl_T<CORBA::PolicyError>::insert ( + _tao_any, + CORBA::PolicyError::_tao_any_destructor, + CORBA::_tc_PolicyError, + _tao_elem + ); +} + +// Extraction to non-const pointer (deprecated). +CORBA::Boolean operator>>= ( + const CORBA::Any &_tao_any, + CORBA::PolicyError *&_tao_elem + ) +{ + return _tao_any >>= const_cast< + const CORBA::PolicyError *&> ( + _tao_elem + ); +} + +// Extraction to const pointer. +CORBA::Boolean operator>>= ( + const CORBA::Any &_tao_any, + const CORBA::PolicyError *&_tao_elem + ) +{ + return + TAO::Any_Dual_Impl_T<CORBA::PolicyError>::extract ( + _tao_any, + CORBA::PolicyError::_tao_any_destructor, + CORBA::_tc_PolicyError, + _tao_elem + ); +} + +// TAO_IDL - Generated from +// be\be_visitor_exception/any_op_cs.cpp:50 + +namespace TAO +{ + template<> + CORBA::Boolean + Any_Dual_Impl_T<CORBA::InvalidPolicies>::demarshal_value ( + TAO_InputCDR & cdr + ) + { + CORBA::String_var id; + + if (!(cdr >> id.out ())) + { + return false; + } + + ACE_TRY_NEW_ENV + { + this->value_->_tao_decode (cdr ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + return false; + } + ACE_ENDTRY; + + return true; + } +} + +// Copying insertion. +void operator<<= ( + CORBA::Any &_tao_any, + const CORBA::InvalidPolicies &_tao_elem + ) +{ + TAO::Any_Dual_Impl_T<CORBA::InvalidPolicies>::insert_copy ( + _tao_any, + CORBA::InvalidPolicies::_tao_any_destructor, + CORBA::_tc_InvalidPolicies, + _tao_elem + ); +} + +// Non-copying insertion. +void operator<<= ( + CORBA::Any &_tao_any, + CORBA::InvalidPolicies *_tao_elem + ) +{ + TAO::Any_Dual_Impl_T<CORBA::InvalidPolicies>::insert ( + _tao_any, + CORBA::InvalidPolicies::_tao_any_destructor, + CORBA::_tc_InvalidPolicies, + _tao_elem + ); +} + +// Extraction to non-const pointer (deprecated). +CORBA::Boolean operator>>= ( + const CORBA::Any &_tao_any, + CORBA::InvalidPolicies *&_tao_elem + ) +{ + return _tao_any >>= const_cast< + const CORBA::InvalidPolicies *&> ( + _tao_elem + ); +} + +// Extraction to const pointer. +CORBA::Boolean operator>>= ( + const CORBA::Any &_tao_any, + const CORBA::InvalidPolicies *&_tao_elem + ) +{ + return + TAO::Any_Dual_Impl_T<CORBA::InvalidPolicies>::extract ( + _tao_any, + CORBA::InvalidPolicies::_tao_any_destructor, + CORBA::_tc_InvalidPolicies, + _tao_elem + ); +} + +// TAO_IDL - Generated from +// be\be_visitor_interface/any_op_cs.cpp:50 + +namespace TAO +{ + template<> + CORBA::Boolean + Any_Impl_T<CORBA::Policy>::to_object ( + CORBA::Object_ptr &_tao_elem + ) const + { + _tao_elem = CORBA::Object::_duplicate (this->value_); + return true; + } +} + +// Copying insertion. +void +operator<<= ( + CORBA::Any &_tao_any, + CORBA::Policy_ptr _tao_elem + ) +{ + CORBA::Policy_ptr _tao_objptr = + CORBA::Policy::_duplicate (_tao_elem); + _tao_any <<= &_tao_objptr; +} + +// Non-copying insertion. +void +operator<<= ( + CORBA::Any &_tao_any, + CORBA::Policy_ptr *_tao_elem + ) +{ + TAO::Any_Impl_T<CORBA::Policy>::insert ( + _tao_any, + CORBA::Policy::_tao_any_destructor, + CORBA::_tc_Policy, + *_tao_elem + ); +} + +CORBA::Boolean +operator>>= ( + const CORBA::Any &_tao_any, + CORBA::Policy_ptr &_tao_elem + ) +{ + return + TAO::Any_Impl_T<CORBA::Policy>::extract ( + _tao_any, + CORBA::Policy::_tao_any_destructor, + CORBA::_tc_Policy, + _tao_elem + ); +} + +// TAO_IDL - Generated from +// be\be_visitor_interface/any_op_cs.cpp:50 + +namespace TAO +{ + template<> + CORBA::Boolean + Any_Impl_T<CORBA::PolicyManager>::to_object ( + CORBA::Object_ptr &_tao_elem + ) const + { + _tao_elem = CORBA::Object::_duplicate (this->value_); + return true; + } +} + +namespace TAO +{ + template<> + CORBA::Boolean + Any_Impl_T<CORBA::PolicyManager>::marshal_value (TAO_OutputCDR &) + { + return false; + } + + template<> + CORBA::Boolean + Any_Impl_T<CORBA::PolicyManager>::demarshal_value (TAO_InputCDR &) + { + return false; + } +} + +// Copying insertion. +void +operator<<= ( + CORBA::Any &_tao_any, + CORBA::PolicyManager_ptr _tao_elem + ) +{ + CORBA::PolicyManager_ptr _tao_objptr = + CORBA::PolicyManager::_duplicate (_tao_elem); + _tao_any <<= &_tao_objptr; +} + +// Non-copying insertion. +void +operator<<= ( + CORBA::Any &_tao_any, + CORBA::PolicyManager_ptr *_tao_elem + ) +{ + TAO::Any_Impl_T<CORBA::PolicyManager>::insert ( + _tao_any, + CORBA::PolicyManager::_tao_any_destructor, + CORBA::_tc_PolicyManager, + *_tao_elem + ); +} + +CORBA::Boolean +operator>>= ( + const CORBA::Any &_tao_any, + CORBA::PolicyManager_ptr &_tao_elem + ) +{ + return + TAO::Any_Impl_T<CORBA::PolicyManager>::extract ( + _tao_any, + CORBA::PolicyManager::_tao_any_destructor, + CORBA::_tc_PolicyManager, + _tao_elem + ); +} + +// TAO_IDL - Generated from +// be\be_visitor_interface/any_op_cs.cpp:50 + +namespace TAO +{ + template<> + CORBA::Boolean + Any_Impl_T<CORBA::PolicyCurrent>::to_object ( + CORBA::Object_ptr &_tao_elem + ) const + { + _tao_elem = CORBA::Object::_duplicate (this->value_); + return true; + } +} + +namespace TAO +{ + template<> + CORBA::Boolean + Any_Impl_T<CORBA::PolicyCurrent>::marshal_value (TAO_OutputCDR &) + { + return false; + } + + template<> + CORBA::Boolean + Any_Impl_T<CORBA::PolicyCurrent>::demarshal_value (TAO_InputCDR &) + { + return false; + } +} + +// Copying insertion. +void +operator<<= ( + CORBA::Any &_tao_any, + CORBA::PolicyCurrent_ptr _tao_elem + ) +{ + CORBA::PolicyCurrent_ptr _tao_objptr = + CORBA::PolicyCurrent::_duplicate (_tao_elem); + _tao_any <<= &_tao_objptr; +} + +// Non-copying insertion. +void +operator<<= ( + CORBA::Any &_tao_any, + CORBA::PolicyCurrent_ptr *_tao_elem + ) +{ + TAO::Any_Impl_T<CORBA::PolicyCurrent>::insert ( + _tao_any, + CORBA::PolicyCurrent::_tao_any_destructor, + CORBA::_tc_PolicyCurrent, + *_tao_elem + ); +} + +CORBA::Boolean +operator>>= ( + const CORBA::Any &_tao_any, + CORBA::PolicyCurrent_ptr &_tao_elem + ) +{ + return + TAO::Any_Impl_T<CORBA::PolicyCurrent>::extract ( + _tao_any, + CORBA::PolicyCurrent::_tao_any_destructor, + CORBA::_tc_PolicyCurrent, + _tao_elem + ); +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/PolicyA.h b/TAO/tao/AnyTypeCode/PolicyA.h new file mode 100644 index 00000000000..ed2c78d1e3a --- /dev/null +++ b/TAO/tao/AnyTypeCode/PolicyA.h @@ -0,0 +1,159 @@ +// -*- C++ -*- +// +// $Id$ + +// **** Code generated by the The ACE ORB (TAO) IDL Compiler **** +// TAO and the TAO IDL Compiler have been developed by: +// Center for Distributed Object Computing +// Washington University +// St. Louis, MO +// USA +// http://www.cs.wustl.edu/~schmidt/doc-center.html +// and +// Distributed Object Computing Laboratory +// University of California at Irvine +// Irvine, CA +// USA +// http://doc.ece.uci.edu/ +// and +// Institute for Software Integrated Systems +// Vanderbilt University +// Nashville, TN +// USA +// http://www.isis.vanderbilt.edu/ +// +// Information about TAO is available at: +// http://www.cs.wustl.edu/~schmidt/TAO.html + +// TAO_IDL - Generated from +// be\be_codegen.cpp:153 + +#ifndef _TAO_IDL_ORIG_POLICYA_H_ +#define _TAO_IDL_ORIG_POLICYA_H_ + +#include /**/ "ace/pre.h" + + +#include "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/AnyTypeCode/TAO_AnyTypeCode_Export.h" +#include "tao/AnyTypeCode/AnyTypeCode_methods.h" +#include "tao/PolicyC.h" + +#if defined (TAO_EXPORT_MACRO) +#undef TAO_EXPORT_MACRO +#endif +#define TAO_EXPORT_MACRO TAO_AnyTypeCode_Export + +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +#if defined (__BORLANDC__) +#pragma option push -w-rvl -w-rch -w-ccc -w-inl +#endif /* __BORLANDC__ */ + +// TAO_IDL - Generated from +// be\be_visitor_module/module_ch.cpp:48 + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace CORBA +{ + + // TAO_IDL - Generated from + // be\be_visitor_typecode/typecode_decl.cpp:44 + + extern TAO_AnyTypeCode_Export ::CORBA::TypeCode_ptr const _tc_PolicyErrorCode; + + // TAO_IDL - Generated from + // be\be_visitor_typecode/typecode_decl.cpp:44 + + extern TAO_AnyTypeCode_Export ::CORBA::TypeCode_ptr const _tc_PolicyError; + + // TAO_IDL - Generated from + // be\be_visitor_typecode/typecode_decl.cpp:44 + + extern TAO_AnyTypeCode_Export ::CORBA::TypeCode_ptr const _tc_InvalidPolicies; + + // TAO_IDL - Generated from + // be\be_visitor_typecode/typecode_decl.cpp:44 + + extern TAO_AnyTypeCode_Export ::CORBA::TypeCode_ptr const _tc_Policy; + + // TAO_IDL - Generated from + // be\be_visitor_typecode/typecode_decl.cpp:44 + + extern TAO_AnyTypeCode_Export ::CORBA::TypeCode_ptr const _tc_PolicyManager; + + // TAO_IDL - Generated from + // be\be_visitor_typecode/typecode_decl.cpp:44 + + extern TAO_AnyTypeCode_Export ::CORBA::TypeCode_ptr const _tc_PolicyCurrent; + +// TAO_IDL - Generated from +// be\be_visitor_module/module_ch.cpp:66 + +} // module CORBA + + +// TAO_IDL - Generated from +// be\be_visitor_exception/any_op_ch.cpp:52 + +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, const CORBA::PolicyError &); // copying version +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, CORBA::PolicyError*); // noncopying version +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any &, CORBA::PolicyError *&); // deprecated +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any &, const CORBA::PolicyError *&); + +// TAO_IDL - Generated from +// be\be_visitor_exception/any_op_ch.cpp:52 + +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, const CORBA::InvalidPolicies &); // copying version +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, CORBA::InvalidPolicies*); // noncopying version +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any &, CORBA::InvalidPolicies *&); // deprecated +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any &, const CORBA::InvalidPolicies *&); + +// TAO_IDL - Generated from +// be\be_visitor_interface/any_op_ch.cpp:52 + +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, CORBA::Policy_ptr); // copying +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, CORBA::Policy_ptr *); // non-copying +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any &, CORBA::Policy_ptr &); + +// TAO_IDL - Generated from +// be\be_visitor_interface/any_op_ch.cpp:52 + +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, CORBA::PolicyManager_ptr); // copying +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, CORBA::PolicyManager_ptr *); // non-copying +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any &, CORBA::PolicyManager_ptr &); + +// TAO_IDL - Generated from +// be\be_visitor_interface/any_op_ch.cpp:52 + +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, CORBA::PolicyCurrent_ptr); // copying +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, CORBA::PolicyCurrent_ptr *); // non-copying +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any &, CORBA::PolicyCurrent_ptr &); + +// TAO_IDL - Generated from +// be\be_codegen.cpp:955 + +TAO_END_VERSIONED_NAMESPACE_DECL + +#if defined(_MSC_VER) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#if defined (__BORLANDC__) +#pragma option pop +#endif /* __BORLANDC__ */ + +#include /**/ "ace/post.h" + +#endif /* ifndef */ + + diff --git a/TAO/tao/AnyTypeCode/Recursive_Type_TypeCode.cpp b/TAO/tao/AnyTypeCode/Recursive_Type_TypeCode.cpp new file mode 100644 index 00000000000..be526f4b094 --- /dev/null +++ b/TAO/tao/AnyTypeCode/Recursive_Type_TypeCode.cpp @@ -0,0 +1,141 @@ +// $Id$ + +#include "tao/CDR.h" + +#ifndef __ACE_INLINE__ +# include "tao/AnyTypeCode/Recursive_Type_TypeCode.inl" +#endif /* __ACE_INLINE__ */ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +template <class TypeCodeBase, typename TypeCodeType, typename MemberArrayType> +bool +TAO::TypeCode::Recursive_Type<TypeCodeBase, + TypeCodeType, + MemberArrayType>::tao_marshal ( + TAO_OutputCDR & cdr, + CORBA::ULong offset) const +{ + ACE_GUARD_RETURN (TAO_SYNCH_RECURSIVE_MUTEX, + guard, + this->lock_, + false); + + // Top-level TypeCode case. + if (!(this->in_recursion_)) + { + this->in_recursion_ = true; + + // Starting offset should point to the CORBA::TCKind value. + + // Note that this doesn't need to take into account alignment + // padding since CORBA::TCKind (encoded as a CORBA::ULong) is + // already aligned on the appropriate boundary, and since the + // CORBA::TCKind was the last thing marshaled into the CDR + // stream before getting here. + offset = sizeof (CORBA::ULong); + + // Reset recursion flag to false in an exception-safe manner once + // marshaling is done. + // + // Only reset the recursion flag at the top-level. + Reset flag (this->in_recursion_); + + return this->TypeCodeBase::tao_marshal (cdr, offset); + } + + // Recursive/indirected TypeCode case. + +// ACE_ASSERT (offset > 4 +// && offset < static_cast<CORBA::ULong> (ACE_INT32_MAX)); + + return (cdr << -static_cast<CORBA::Long> (offset)); +} + +template <class TypeCodeBase, typename TypeCodeType, typename MemberArrayType> +CORBA::Boolean +TAO::TypeCode::Recursive_Type<TypeCodeBase, + TypeCodeType, + MemberArrayType>::equal_i ( + CORBA::TypeCode_ptr tc + ACE_ENV_ARG_DECL) const +{ + ACE_GUARD_RETURN (TAO_SYNCH_RECURSIVE_MUTEX, + guard, + this->lock_, + false); + + // Top-level TypeCode case. + if (!(this->in_recursion_)) + { + this->in_recursion_ = true; + + // Reset recursion flag to false in an exception-safe manner once + // equality determination is done. + // + // Only reset the recursion flag at the top-level. + Reset flag (this->in_recursion_); + + return this->TypeCodeBase::equal_i (tc + ACE_ENV_ARG_PARAMETER); + } + + // Nothing else to do. + return true; +} + +template <class TypeCodeBase, typename TypeCodeType, typename MemberArrayType> +CORBA::Boolean +TAO::TypeCode::Recursive_Type<TypeCodeBase, + TypeCodeType, + MemberArrayType>::equivalent_i ( + CORBA::TypeCode_ptr tc + ACE_ENV_ARG_DECL) const +{ + ACE_GUARD_RETURN (TAO_SYNCH_RECURSIVE_MUTEX, + guard, + this->lock_, + false); + + // Top-level TypeCode case. + if (!(this->in_recursion_)) + { + this->in_recursion_ = true; + + // Reset recursion flag to false in an exception-safe manner once + // equivalence determination is done. + // + // Only reset the recursion flag at the top-level. + Reset flag (this->in_recursion_); + + return this->TypeCodeBase::equivalent_i (tc + ACE_ENV_ARG_PARAMETER); + } + + // Nothing else to do. + return true; +} + +template <class TypeCodeBase, typename TypeCodeType, typename MemberArrayType> +bool +TAO::TypeCode::Recursive_Type<TypeCodeBase, + TypeCodeType, + MemberArrayType>::tao_marshal_kind ( + TAO_OutputCDR & cdr) const +{ + ACE_GUARD_RETURN (TAO_SYNCH_RECURSIVE_MUTEX, + guard, + this->lock_, + false); + + // Top-level TypeCode case. + if (!(this->in_recursion_)) + return this->::CORBA::TypeCode::tao_marshal_kind (cdr); + + // Recursive/indirected TypeCode case. + CORBA::ULong const indirection_kind = 0xffffffff; + + return (cdr << indirection_kind); +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/Recursive_Type_TypeCode.h b/TAO/tao/AnyTypeCode/Recursive_Type_TypeCode.h new file mode 100644 index 00000000000..027100bb476 --- /dev/null +++ b/TAO/tao/AnyTypeCode/Recursive_Type_TypeCode.h @@ -0,0 +1,220 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Recursive_Type_TypeCode.h + * + * $Id$ + * + * Header file for a recursive type (@c struct, @c union or + * @c valuetype) CORBA::TypeCode. + * + * @author Ossama Othman + */ +//============================================================================= + +#ifndef TAO_RECURSIVE_TYPE_TYPECODE_H +#define TAO_RECURSIVE_TYPE_TYPECODE_H + +#include /**/ "ace/pre.h" + +#include "tao/Basic_Types.h" +#include "tao/Typecode_typesC.h" +#include "ace/Recursive_Thread_Mutex.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + namespace TypeCode + { + + /** + * @class Recursive_Type + * + * @brief Recursive type @c TypeCode decorator template. + * + * This class template decorates the underlying @c TypeCode + * implementation @a TypeCodeBase to provide support for IDL + * defined recursive types. Only IDL an @c struct, @c union or + * @c valuetype may be recursive, which is why this decorator only + * supports constructors for the corresponding @c TypeCode + * implementations. + */ + template <class TypeCodeBase, + typename TypeCodeType, + typename MemberArrayType> + class Recursive_Type + : public TypeCodeBase + { + public: + + /// Recursive @c struct constructor. + Recursive_Type (CORBA::TCKind kind, + char const * id, + char const * name, + MemberArrayType const & fields, + CORBA::ULong nfields); + + /// Recursive @c union constructor. + Recursive_Type (char const * id, + char const * name, +#if defined (__BORLANDC__) && (__BORLANDC__ < 0x572) + // Borland C++ currently can't handle a + // reference to const pointer to const + // CORBA::TypeCode_ptr. + TypeCodeType discriminant_type, +#else + TypeCodeType const & discriminant_type, +#endif + MemberArrayType const & cases, + CORBA::ULong ncases, + CORBA::Long default_index); + + /// Recursive @c valuetype constructor. + Recursive_Type (CORBA::TCKind kind, + char const * id, + char const * name, + CORBA::ValueModifier modifier, +#if defined (__BORLANDC__) && (__BORLANDC__ < 0x572) + // Borland C++ currently can't handle a + // reference to const pointer to const + // CORBA::TypeCode_ptr. + TypeCodeType concrete_base, +#else + TypeCodeType const & concrete_base, +#endif + MemberArrayType const & fields, + CORBA::ULong nfields); + + /// Dynamic @c Recursive_Type TypeCode constructor. + Recursive_Type (CORBA::TCKind kind, + char const * id); + + /** + * @name TAO-specific @c CORBA::TypeCode Methods + * + * Methods required by TAO's implementation of the + * @c CORBA::TypeCode class. + * + * @par + * + * These are recursive type @c TypeCode marshaling operation + * overrides. + * + * @see @c CORBA::TypeCode + */ + //@{ + virtual bool tao_marshal_kind (TAO_OutputCDR & cdr) const; + virtual bool tao_marshal (TAO_OutputCDR & cdr, + CORBA::ULong offset) const; + //@} + + protected: + + /** + * @name TAO @c CORBA::TypeCode Template Methods + * + * Recursive type @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; + //@} + + + public: + + /// Set @c struct @c TypeCode parameters. + void struct_parameters (char const * name, + MemberArrayType const & fields, + CORBA::ULong nfields); + + /// Set @c union @c TypeCode parameters. + void union_parameters ( + char const * name, +#if defined (__BORLANDC__) && (__BORLANDC__ < 0x572) + // Borland C++ currently can't handle a + // reference to const pointer to const + // CORBA::TypeCode_ptr. + TypeCodeType discriminant_type, +#else + TypeCodeType const & discriminant_type, +#endif + MemberArrayType const & cases, + CORBA::ULong ncases, + CORBA::Long default_index); + + /// Set @c valuetype or @c eventtype @c TypeCode parameters. + void valuetype_parameters (char const * name, + CORBA::ValueModifier modifier, +#if defined (__BORLANDC__) && (__BORLANDC__ < 0x572) + // Borland C++ currently can't handle a + // reference to const pointer to const + // CORBA::TypeCode_ptr. + TypeCodeType concrete_base, +#else + TypeCodeType const & concrete_base, +#endif + MemberArrayType const & fields, + CORBA::ULong nfields); + + private: + + /** + * @class Reset + * + * @brief Reset flag to false in an exception-safe manner. + * + * Reset flag to false in an exception-safe manner. + */ + class Reset + { + public: + Reset (bool & flag) : flag_ (flag) { } + ~Reset (void) { this->flag_ = false; } + private: + bool & flag_; + }; + + private: + + /// Internal state thread synchronization mutex. + mutable TAO_SYNCH_RECURSIVE_MUTEX lock_; + + /// @c true if equality or equivalence is being determined + /// recursively. + /** + * This flag is used to prevent @c TypeCode equality and + * equivalence operations from recursing indefinitely. + */ + mutable bool in_recursion_; + + }; + + } // End namespace TypeCode +} // End namespace TAO + +TAO_END_VERSIONED_NAMESPACE_DECL + + +#ifdef __ACE_INLINE__ +# include "tao/AnyTypeCode/Recursive_Type_TypeCode.inl" +#endif /* __ACE_INLINE__ */ + +#ifdef ACE_TEMPLATES_REQUIRE_SOURCE +# include "tao/AnyTypeCode/Recursive_Type_TypeCode.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#ifdef ACE_TEMPLATES_REQUIRE_PRAGMA +# pragma implementation ("Recursive_Type_TypeCode.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" + +#endif /* TAO_RECURSIVE_TYPE_TYPECODE_H */ diff --git a/TAO/tao/AnyTypeCode/Recursive_Type_TypeCode.inl b/TAO/tao/AnyTypeCode/Recursive_Type_TypeCode.inl new file mode 100644 index 00000000000..efd9091a125 --- /dev/null +++ b/TAO/tao/AnyTypeCode/Recursive_Type_TypeCode.inl @@ -0,0 +1,153 @@ +// -*- C++ -*- +// +// $Id$ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +template <class TypeCodeBase, typename TypeCodeType, typename MemberArrayType> +ACE_INLINE +TAO::TypeCode::Recursive_Type<TypeCodeBase, + TypeCodeType, + MemberArrayType>::Recursive_Type ( + CORBA::TCKind kind, + char const * id, + char const * name, + MemberArrayType const & fields, + CORBA::ULong nfields) + : TypeCodeBase (kind, id, name, fields, nfields) + , lock_ () + , in_recursion_ (false) +{ + // ACE_ASSERT (kind != CORBA::tk_except); +} + +template <class TypeCodeBase, typename TypeCodeType, typename MemberArrayType> +ACE_INLINE +TAO::TypeCode::Recursive_Type<TypeCodeBase, + TypeCodeType, + MemberArrayType>::Recursive_Type ( + char const * id, + char const * name, +#if defined (__BORLANDC__) && (__BORLANDC__ < 0x572) + TypeCodeType discriminant_type, +#else + TypeCodeType const & discriminant_type, +#endif + MemberArrayType const & cases, + CORBA::ULong ncases, + CORBA::Long default_index) + : TypeCodeBase (id, + name, + discriminant_type, + cases, + ncases, + default_index) + , lock_ () + , in_recursion_ (false) +{ +} + +template <class TypeCodeBase, typename TypeCodeType, typename MemberArrayType> +ACE_INLINE +TAO::TypeCode::Recursive_Type<TypeCodeBase, + TypeCodeType, + MemberArrayType>::Recursive_Type ( + CORBA::TCKind kind, + char const * id, + char const * name, + CORBA::ValueModifier modifier, +#if defined (__BORLANDC__) && (__BORLANDC__ < 0x572) + TypeCodeType concrete_base, +#else + TypeCodeType const & concrete_base, +#endif + MemberArrayType const & fields, + CORBA::ULong nfields) + : TypeCodeBase (kind, + id, + name, + modifier, + concrete_base, + fields, + nfields) + , lock_ () + , in_recursion_ (false) +{ +} + +template <class TypeCodeBase, typename TypeCodeType, typename MemberArrayType> +ACE_INLINE +TAO::TypeCode::Recursive_Type<TypeCodeBase, + TypeCodeType, + MemberArrayType>::Recursive_Type ( + CORBA::TCKind kind, + char const * id) + : TypeCodeBase (kind, id) + , lock_ () + , in_recursion_ (false) +{ +// ACE_ASSERT (kind == CORBA::tk_struct +// || kind == CORBA::tk_union +// || kind == CORBA::tk_value +// || kind == CORBA::tk_event); +} + +template <class TypeCodeBase, typename TypeCodeType, typename MemberArrayType> +ACE_INLINE void +TAO::TypeCode::Recursive_Type<TypeCodeBase, + TypeCodeType, + MemberArrayType>::struct_parameters ( + char const * name, + MemberArrayType const & fields, + CORBA::ULong nfields) +{ + this->base_attributes_.name (name); + this->fields_ = fields; + this->nfields_ = nfields; +} + +template <class TypeCodeBase, typename TypeCodeType, typename MemberArrayType> +ACE_INLINE void +TAO::TypeCode::Recursive_Type<TypeCodeBase, + TypeCodeType, + MemberArrayType>::union_parameters ( + char const * name, +#if defined (__BORLANDC__) && (__BORLANDC__ < 0x572) + TypeCodeType discriminant_type, +#else + TypeCodeType const & discriminant_type, +#endif + MemberArrayType const & cases, + CORBA::ULong ncases, + CORBA::Long default_index) +{ + this->base_attributes_.name (name); + this->discriminant_type_ = discriminant_type; + this->cases_ = cases; + this->ncases_ = ncases; + this->default_index_ = default_index; +} + +template <class TypeCodeBase, typename TypeCodeType, typename MemberArrayType> +ACE_INLINE void +TAO::TypeCode::Recursive_Type<TypeCodeBase, + TypeCodeType, + MemberArrayType>::valuetype_parameters ( + char const * name, + CORBA::ValueModifier modifier, +#if defined (__BORLANDC__) && (__BORLANDC__ < 0x572) + TypeCodeType concrete_base, +#else + TypeCodeType const & concrete_base, +#endif + MemberArrayType const & fields, + CORBA::ULong nfields) +{ + this->base_attributes_.name (name); + this->type_modifier_ = modifier; + this->concrete_base_ = concrete_base; + this->fields_ = fields; + this->nfields_ = nfields; +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/RefCount_Policy_Traits.h b/TAO/tao/AnyTypeCode/RefCount_Policy_Traits.h new file mode 100644 index 00000000000..d5e4f08d50d --- /dev/null +++ b/TAO/tao/AnyTypeCode/RefCount_Policy_Traits.h @@ -0,0 +1,82 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file RefCount_Policy_Traits.h + * + * $Id$ + * + * Header file for TAO's reference count policy (unrelated to CORBA + * policies) traits. + * + * @author Ossama Othman <ossama@dre.vanderbilt.edu> + */ +//============================================================================= + +#ifndef TAO_REFCOUNT_POLICY_TRAITS_H +#define TAO_REFCOUNT_POLICY_TRAITS_H + +#include /**/ "ace/pre.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/AnyTypeCode/AnyTypeCode_methods.h" + + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + class Null_RefCount_Policy; + class True_RefCount_Policy; + + /** + * @struct RefCount_Policy_Traits + * + * @brief Compile-time selection of RefCount_Policy operations, + * etc. + * + * This primary template is used to select RefCount_Policy + * operations, etc at compile-time based on the reference counting + * policy and type being operated on. + * + * @note This merely a forward declaration since we really only care + * about the partial specializations below. + */ + template<class RefCountPolicy, typename TypePtr> + struct RefCount_Policy_Traits; + + /** + * @struct RefCount_Policy_Traits + * + * @brief No-op reference count policy traits. + * + * This partial specialization performs no-op reference counting + * operations on values of type @a TypePtr if the @a RefCountPolicy + * first argument is @c Null_RefCount_Policy. + */ + template<typename TypePtr> + struct RefCount_Policy_Traits<Null_RefCount_Policy, TypePtr> + { + /// No-op "release" operation. + static void release (TypePtr) { } + }; + + template<typename TypePtr> + struct RefCount_Policy_Traits<True_RefCount_Policy, TypePtr> + { + /// Call actual "release" operation on @a ptr value. + static void release (TypePtr ptr) + { + CORBA::release (ptr); + } + }; +} // End namespace TAO + +TAO_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" + +#endif /* TAO_REFCOUNT_POLICY_TRAITS_H */ diff --git a/TAO/tao/AnyTypeCode/Sequence_TypeCode.cpp b/TAO/tao/AnyTypeCode/Sequence_TypeCode.cpp new file mode 100644 index 00000000000..76016fe93fe --- /dev/null +++ b/TAO/tao/AnyTypeCode/Sequence_TypeCode.cpp @@ -0,0 +1,150 @@ +// $Id$ + +#ifndef TAO_SEQUENCE_TYPECODE_CPP +#define TAO_SEQUENCE_TYPECODE_CPP + +#include "tao/AnyTypeCode/Sequence_TypeCode.h" +#include "tao/CDR.h" +#include "tao/AnyTypeCode/TypeCode_Traits.h" + +#ifndef __ACE_INLINE__ +# include "tao/AnyTypeCode/Sequence_TypeCode.inl" +#endif /* !__ACE_INLINE__ */ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +template <typename TypeCodeType, class RefCountPolicy> +bool +TAO::TypeCode::Sequence<TypeCodeType, RefCountPolicy>::tao_marshal ( + TAO_OutputCDR & cdr, + CORBA::ULong offset) const +{ + // A tk_array or tk_sequence 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. + TAO_OutputCDR enc; + + // Account for the encoded CDR encapsulation length and byte order. + // + // Aligning on an octet since the next value after the CDR + // encapsulation length will always be the byte order octet/boolean + // in this case. + offset = ACE_align_binary (offset + 4, + ACE_CDR::OCTET_ALIGN); + + return + enc << TAO_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER) + && marshal (enc, + Traits<TypeCodeType>::get_typecode (this->content_type_), + offset + enc.total_length ()) + && enc << this->length_ + && cdr << static_cast<CORBA::ULong> (enc.total_length ()) + && cdr.write_octet_array_mb (enc.begin ()); +} + +template <typename TypeCodeType, class RefCountPolicy> +void +TAO::TypeCode::Sequence<TypeCodeType, RefCountPolicy>::tao_duplicate (void) +{ + this->RefCountPolicy::add_ref (); +} + +template <typename TypeCodeType, class RefCountPolicy> +void +TAO::TypeCode::Sequence<TypeCodeType, RefCountPolicy>::tao_release (void) +{ + this->RefCountPolicy::remove_ref (); +} + +template <typename TypeCodeType, class RefCountPolicy> +CORBA::Boolean +TAO::TypeCode::Sequence<TypeCodeType, + RefCountPolicy>::equal_i (CORBA::TypeCode_ptr tc + ACE_ENV_ARG_DECL) const +{ + // The following calls won't throw since CORBA::TypeCode::equal() + // has already established the kind of tc is the same as our kind. + CORBA::ULong const tc_length = tc->length (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + if (this->length_ != tc_length) + return 0; + + CORBA::TypeCode_var rhs_content_type = + tc->content_type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + return + Traits<TypeCodeType>::get_typecode (this->content_type_)->equal ( + rhs_content_type.in () + ACE_ENV_ARG_PARAMETER); +} + +template <typename TypeCodeType, class RefCountPolicy> +CORBA::Boolean +TAO::TypeCode::Sequence<TypeCodeType, + RefCountPolicy>::equivalent_i (CORBA::TypeCode_ptr tc + ACE_ENV_ARG_DECL) const +{ + // The following calls won't throw since CORBA::TypeCode::equal() + // has already established the kind of tc is the same as our kind. + CORBA::ULong const tc_length = tc->length (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + if (this->length_ != tc_length) + return 0; + + CORBA::TypeCode_var rhs_content_type = + tc->content_type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + return + Traits<TypeCodeType>::get_typecode (this->content_type_)->equivalent ( + rhs_content_type.in () + ACE_ENV_ARG_PARAMETER); +} + +template <typename TypeCodeType, class RefCountPolicy> +CORBA::TypeCode_ptr +TAO::TypeCode::Sequence<TypeCodeType, RefCountPolicy>::get_compact_typecode_i ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const +{ + // Already compact since tk_sequence and tk_array TypeCodes have no + // name or member names, meaning that we can simply call + // _duplicate() on this TypeCode. + + // @@ There is a potential problem here if this TypeCode is a static + // and const since it may have been placed in read-only memory by + // the compiler. A const_cast<> can return undefined results in + // that case. + + CORBA::TypeCode_ptr mutable_tc = + const_cast<TAO::TypeCode::Sequence<TypeCodeType, RefCountPolicy> *> (this); + + return CORBA::TypeCode::_duplicate (mutable_tc); +} + +template <typename TypeCodeType, class RefCountPolicy> +CORBA::ULong +TAO::TypeCode::Sequence<TypeCodeType, RefCountPolicy>::length_i ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const +{ + return this->length_; +} + +template <typename TypeCodeType, class RefCountPolicy> +CORBA::TypeCode_ptr +TAO::TypeCode::Sequence<TypeCodeType, RefCountPolicy>::content_type_i ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const +{ + return + CORBA::TypeCode::_duplicate ( + Traits<TypeCodeType>::get_typecode (this->content_type_)); +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +#endif /* TAO_SEQUENCE_TYPECODE_CPP */ diff --git a/TAO/tao/AnyTypeCode/Sequence_TypeCode.h b/TAO/tao/AnyTypeCode/Sequence_TypeCode.h new file mode 100644 index 00000000000..3b8cd242ade --- /dev/null +++ b/TAO/tao/AnyTypeCode/Sequence_TypeCode.h @@ -0,0 +1,138 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Sequence_TypeCode.h + * + * $Id$ + * + * Header file for @c tk_sequence and @c tk_array @c CORBA::TypeCodes. + * + * @author Ossama Othman <ossama@dre.vanderbilt.edu> + */ +//============================================================================= + +#ifndef TAO_SEQUENCE_TYPECODE_H +#define TAO_SEQUENCE_TYPECODE_H + +#include /**/ "ace/pre.h" + +#include "tao/AnyTypeCode/TypeCode.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + namespace TypeCode + { + + /** + * @class Sequence + * + * @brief @c CORBA::TypeCode implementation for OMG IDL + * @c sequence and @c array types. + * + * This class implements a @c CORBA::TypeCode for OMG IDL + * @c sequence and array types. + */ + template <typename TypeCodeType, class RefCountPolicy> + class Sequence + : public CORBA::TypeCode + , private RefCountPolicy + { + public: + + /// Constructor. + Sequence (CORBA::TCKind kind, +#if defined (__BORLANDC__) && (__BORLANDC__ < 0x572) + // Borland C++ currently can't handle a reference to + // const pointer to const CORBA::TypeCode_ptr + TypeCodeType content_type, +#else + TypeCodeType const & content_type, +#endif + CORBA::ULong length); + + /** + * @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, + CORBA::ULong offset) const; + virtual void tao_duplicate (void); + virtual void tao_release (void); + //@} + + protected: + + /** + * @name @c TAO CORBA::TypeCode Template Methods + * + * @c CORBA::TypeCode template methods specific to @c tk_sequence + * @c TypeCodes. + * + * @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::TypeCode_ptr get_compact_typecode_i ( + ACE_ENV_SINGLE_ARG_DECL) const; + virtual CORBA::ULong length_i (ACE_ENV_SINGLE_ARG_DECL) const; + virtual CORBA::TypeCode_ptr content_type_i ( + ACE_ENV_SINGLE_ARG_DECL) const; + + private: + + /// Element type of the sequence. + /** + * 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::Sequence. + */ + TypeCodeType const content_type_; + + /// Length of the @c sequence or array. A length of zero + /// indicates an unbounded @c sequence. + CORBA::ULong const length_; + + }; + + } // End namespace TypeCode +} // End namespace TAO + +TAO_END_VERSIONED_NAMESPACE_DECL + +#ifdef __ACE_INLINE__ +# include "tao/AnyTypeCode/Sequence_TypeCode.inl" +#endif /* __ACE_INLINE__ */ + +#ifdef ACE_TEMPLATES_REQUIRE_SOURCE +# include "tao/AnyTypeCode/Sequence_TypeCode.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#ifdef ACE_TEMPLATES_REQUIRE_PRAGMA +# pragma implementation ("Sequence_TypeCode.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + + +#include /**/ "ace/post.h" + +#endif /* TAO_SEQUENCE_TYPECODE_H */ diff --git a/TAO/tao/AnyTypeCode/Sequence_TypeCode.inl b/TAO/tao/AnyTypeCode/Sequence_TypeCode.inl new file mode 100644 index 00000000000..eced0644709 --- /dev/null +++ b/TAO/tao/AnyTypeCode/Sequence_TypeCode.inl @@ -0,0 +1,27 @@ +// -*- C++ -*- +// +// $Id$ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +template <typename TypeCodeType, class RefCountPolicy> +ACE_INLINE +TAO::TypeCode::Sequence<TypeCodeType, RefCountPolicy>::Sequence ( + CORBA::TCKind kind, +#if defined (__BORLANDC__) && (__BORLANDC__ < 0x572) + // Borland C++ currently can't handle a reference to + // const pointer to const CORBA::TypeCode_ptr + TypeCodeType content_type, +#else + TypeCodeType const & content_type, +#endif + CORBA::ULong length) + : ::CORBA::TypeCode (kind) + , RefCountPolicy () + , content_type_ (content_type) + , length_ (length) +{ + // ACE_ASSERT (kind == CORBA::tk_array || kind == CORBA::tk_sequence); +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/Sequence_TypeCode_Static.cpp b/TAO/tao/AnyTypeCode/Sequence_TypeCode_Static.cpp new file mode 100644 index 00000000000..874fe38365b --- /dev/null +++ b/TAO/tao/AnyTypeCode/Sequence_TypeCode_Static.cpp @@ -0,0 +1,150 @@ +// $Id$ + +#include "tao/AnyTypeCode/Sequence_TypeCode_Static.h" +#include "tao/CDR.h" +#include "tao/AnyTypeCode/TypeCode_Traits.h" + +#ifndef __ACE_INLINE__ +# include "tao/AnyTypeCode/Sequence_TypeCode_Static.inl" +#endif /* !__ACE_INLINE__ */ + + +ACE_RCSID (AnyTypeCode, + Sequence_TypeCode_Static, + "$Id$") + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +bool +TAO::TypeCode::Sequence<CORBA::TypeCode_ptr const *, + TAO::Null_RefCount_Policy>::tao_marshal ( + TAO_OutputCDR & cdr, + CORBA::ULong offset) const +{ + // A tk_array or tk_sequence 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. + TAO_OutputCDR enc; + + // Account for the encoded CDR encapsulation length and byte order. + // + // Aligning on an octet since the next value after the CDR + // encapsulation length will always be the byte order octet/boolean + // in this case. + offset = ACE_align_binary (offset + 4, + ACE_CDR::OCTET_ALIGN); + + return + enc << TAO_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER) + && marshal (enc, + Traits<CORBA::TypeCode_ptr const *>::get_typecode ( + this->content_type_), + offset + enc.total_length ()) + && enc << this->length_ + && cdr << static_cast<CORBA::ULong> (enc.total_length ()) + && cdr.write_octet_array_mb (enc.begin ()); +} + +void +TAO::TypeCode::Sequence<CORBA::TypeCode_ptr const *, + TAO::Null_RefCount_Policy>::tao_duplicate (void) +{ +} + +void +TAO::TypeCode::Sequence<CORBA::TypeCode_ptr const *, + TAO::Null_RefCount_Policy>::tao_release (void) +{ +} + +CORBA::Boolean +TAO::TypeCode::Sequence<CORBA::TypeCode_ptr const *, + TAO::Null_RefCount_Policy>::equal_i ( + CORBA::TypeCode_ptr tc + ACE_ENV_ARG_DECL) const +{ + // The following calls won't throw since CORBA::TypeCode::equal() + // has already established the kind of tc is the same as our kind. + CORBA::ULong const tc_length = tc->length (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + if (this->length_ != tc_length) + return 0; + + CORBA::TypeCode_var rhs_content_type = + tc->content_type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + return + Traits<CORBA::TypeCode_ptr const *>::get_typecode (this->content_type_)->equal ( + rhs_content_type.in () + ACE_ENV_ARG_PARAMETER); +} + +CORBA::Boolean +TAO::TypeCode::Sequence<CORBA::TypeCode_ptr const *, + TAO::Null_RefCount_Policy>::equivalent_i ( + CORBA::TypeCode_ptr tc + ACE_ENV_ARG_DECL) const +{ + // The following calls won't throw since CORBA::TypeCode::equal() + // has already established the kind of tc is the same as our kind. + CORBA::ULong const tc_length = tc->length (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + if (this->length_ != tc_length) + return 0; + + CORBA::TypeCode_var rhs_content_type = + tc->content_type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + return + Traits<CORBA::TypeCode_ptr const *>::get_typecode (this->content_type_)->equivalent ( + rhs_content_type.in () + ACE_ENV_ARG_PARAMETER); +} + +CORBA::TypeCode_ptr +TAO::TypeCode::Sequence<CORBA::TypeCode_ptr const *, + TAO::Null_RefCount_Policy>::get_compact_typecode_i ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const +{ + // Already compact since tk_sequence and tk_array TypeCodes have no + // name or member names, meaning that we can simply call + // _duplicate() on this TypeCode. + + // @@ There is a potential problem here if this TypeCode is a static + // and const since it may have been placed in read-only memory by + // the compiler. A const_cast<> can return undefined results in + // that case. + + CORBA::TypeCode_ptr mutable_tc = + const_cast<TAO::TypeCode::Sequence<CORBA::TypeCode_ptr const *, + TAO::Null_RefCount_Policy> *> (this); + + return CORBA::TypeCode::_duplicate (mutable_tc); +} + +CORBA::ULong +TAO::TypeCode::Sequence<CORBA::TypeCode_ptr const *, + TAO::Null_RefCount_Policy>::length_i ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const +{ + return this->length_; +} + +CORBA::TypeCode_ptr +TAO::TypeCode::Sequence<CORBA::TypeCode_ptr const *, + TAO::Null_RefCount_Policy>::content_type_i ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const +{ + return + CORBA::TypeCode::_duplicate ( + Traits<CORBA::TypeCode_ptr const *>::get_typecode (this->content_type_)); +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/Sequence_TypeCode_Static.h b/TAO/tao/AnyTypeCode/Sequence_TypeCode_Static.h new file mode 100644 index 00000000000..7c3d4746fbc --- /dev/null +++ b/TAO/tao/AnyTypeCode/Sequence_TypeCode_Static.h @@ -0,0 +1,127 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Sequence_TypeCode_Static.h + * + * $Id$ + * + * Header file for static @c tk_sequence and @c tk_array + * @c CORBA::TypeCodes. + * + * @author Ossama Othman <ossama@dre.vanderbilt.edu> + */ +//============================================================================= + +#ifndef TAO_SEQUENCE_TYPECODE_STATIC_H +#define TAO_SEQUENCE_TYPECODE_STATIC_H + +#include /**/ "ace/pre.h" + +#include "tao/AnyTypeCode/TypeCode.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/AnyTypeCode/Null_RefCount_Policy.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + namespace TypeCode + { + template <typename TypeCodeType, class RefCountPolicy> class Sequence; + + /** + * @class Sequence + * + * @brief @c CORBA::TypeCode implementation for OMG IDL + * @c sequence and @c array types. + * + * This class implements a @c CORBA::TypeCode for OMG IDL + * @c sequence and array types. + */ + template<> + class TAO_AnyTypeCode_Export Sequence<CORBA::TypeCode_ptr const *, + TAO::Null_RefCount_Policy> + : public CORBA::TypeCode + , private TAO::Null_RefCount_Policy + { + public: + + /// Constructor. + Sequence (CORBA::TCKind kind, + CORBA::TypeCode_ptr const * content_type, + CORBA::ULong length); + + /** + * @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, + CORBA::ULong offset) const; + virtual void tao_duplicate (void); + virtual void tao_release (void); + //@} + + protected: + + /** + * @name @c TAO CORBA::TypeCode Template Methods + * + * @c CORBA::TypeCode template methods specific to @c tk_sequence + * @c TypeCodes. + * + * @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::TypeCode_ptr get_compact_typecode_i ( + ACE_ENV_SINGLE_ARG_DECL) const; + virtual CORBA::ULong length_i (ACE_ENV_SINGLE_ARG_DECL) const; + virtual CORBA::TypeCode_ptr content_type_i ( + ACE_ENV_SINGLE_ARG_DECL) const; + + private: + + /// Element type of the sequence. + /** + * 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::Sequence. + */ + CORBA::TypeCode_ptr const * const content_type_; + + /// Length of the @c sequence or array. A length of zero + /// indicates an unbounded @c sequence. + CORBA::ULong const length_; + + }; + + } // End namespace TypeCode +} // End namespace TAO + +TAO_END_VERSIONED_NAMESPACE_DECL + +#ifdef __ACE_INLINE__ +# include "tao/AnyTypeCode/Sequence_TypeCode_Static.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" + +#endif /* TAO_SEQUENCE_TYPECODE_STATIC_H */ diff --git a/TAO/tao/AnyTypeCode/Sequence_TypeCode_Static.inl b/TAO/tao/AnyTypeCode/Sequence_TypeCode_Static.inl new file mode 100644 index 00000000000..84361bf52de --- /dev/null +++ b/TAO/tao/AnyTypeCode/Sequence_TypeCode_Static.inl @@ -0,0 +1,20 @@ +// -*- C++ -*- +// +// $Id$ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE +TAO::TypeCode::Sequence<CORBA::TypeCode_ptr const *, + TAO::Null_RefCount_Policy>::Sequence ( + CORBA::TCKind kind, + CORBA::TypeCode_ptr const * content_type, + CORBA::ULong length) + : ::CORBA::TypeCode (kind) + , ::TAO::Null_RefCount_Policy () + , content_type_ (content_type) + , length_ (length) +{ +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/String_TypeCode.cpp b/TAO/tao/AnyTypeCode/String_TypeCode.cpp new file mode 100644 index 00000000000..bae404af34e --- /dev/null +++ b/TAO/tao/AnyTypeCode/String_TypeCode.cpp @@ -0,0 +1,93 @@ +// $Id$ + +#ifndef TAO_STRING_TYPECODE_CPP +#define TAO_STRING_TYPECODE_CPP + +#include "tao/AnyTypeCode/String_TypeCode.h" +#include "tao/CDR.h" + +#ifndef __ACE_INLINE__ +# include "tao/AnyTypeCode/String_TypeCode.inl" +#endif /* !__ACE_INLINE__ */ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +template <class RefCountPolicy> +bool +TAO::TypeCode::String<RefCountPolicy>::tao_marshal (TAO_OutputCDR & cdr, + CORBA::ULong) const +{ + // A tk_string TypeCode has a "simple" parameter list type (see + // Table 15-2 in Section 15.3.5.1 "TypeCode" in the CDR section of + // the CORBA specification), meaning that its parameter(s) must be + // marshaled immediately following the TCKind. No CDR encapsulation + // is to be created. + + return (cdr << this->length_); +} + +template <class RefCountPolicy> +void +TAO::TypeCode::String<RefCountPolicy>::tao_duplicate (void) +{ + this->RefCountPolicy::add_ref (); +} + +template <class RefCountPolicy> +void +TAO::TypeCode::String<RefCountPolicy>::tao_release (void) +{ + this->RefCountPolicy::remove_ref (); +} + +template <class RefCountPolicy> +CORBA::Boolean +TAO::TypeCode::String<RefCountPolicy>::equal_i (CORBA::TypeCode_ptr tc + ACE_ENV_ARG_DECL) const +{ + // The following call won't throw since CORBA::TypeCode::equal() has + // already established the kind of tc is the same as our kind. + CORBA::ULong const tc_length = tc->length (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + return (this->length_ == tc_length); +} + +template <class RefCountPolicy> +CORBA::Boolean +TAO::TypeCode::String<RefCountPolicy>::equivalent_i (CORBA::TypeCode_ptr tc + ACE_ENV_ARG_DECL) const +{ + // Since TCKind comparisons must be performed before equal_i() is + // called, we can also call it to determine equivalence of + // tk_string-based TypeCodes. + return this->equal_i (tc + ACE_ENV_ARG_PARAMETER); +} + +template <class RefCountPolicy> +CORBA::TypeCode_ptr +TAO::TypeCode::String<RefCountPolicy>::get_compact_typecode_i ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const +{ + // Already compact since tk_string and tk_wstring TypeCodes have no + // name or member names, meaning that we can simply call + // _duplicate() on this TypeCode. + + CORBA::TypeCode_ptr mutable_tc = + const_cast<TAO::TypeCode::String<RefCountPolicy> *> (this); + + return CORBA::TypeCode::_duplicate (mutable_tc); +} + +template <class RefCountPolicy> +CORBA::ULong +TAO::TypeCode::String<RefCountPolicy>::length_i ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const +{ + return this->length_; +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +#endif /* TAO_STRING_TYPECODE_CPP */ diff --git a/TAO/tao/AnyTypeCode/String_TypeCode.h b/TAO/tao/AnyTypeCode/String_TypeCode.h new file mode 100644 index 00000000000..86a7270f12b --- /dev/null +++ b/TAO/tao/AnyTypeCode/String_TypeCode.h @@ -0,0 +1,115 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file String_TypeCode.h + * + * $Id$ + * + * Header file for @c CORBA::tk_string or @c CORBA::tk_wstring + * @c CORBA::TypeCodes. + * + * @author Ossama Othman <ossama@dre.vanderbilt.edu> + */ +//============================================================================= + +#ifndef TAO_STRING_TYPECODE_H +#define TAO_STRING_TYPECODE_H + +#include /**/ "ace/pre.h" + +#include "tao/AnyTypeCode/TypeCode.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + namespace TypeCode + { + + /** + * @class String + * + * @brief @c CORBA::TypeCode implementation for OMG IDL string + * types. + * + * This class implements a @c CORBA::TypeCode for OMG IDL string + * types, including @c wstring. + */ + template <class RefCountPolicy> + class String + : public CORBA::TypeCode, + private RefCountPolicy + { + public: + + /// Constructor. + String (CORBA::TCKind kind, CORBA::ULong length); + + /** + * @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, + CORBA::ULong offset) const; + virtual void tao_duplicate (void); + virtual void tao_release (void); + //@} + + protected: + + /** + * @name @c TAO CORBA::TypeCode Template Methods + * + * @c CORBA::TypeCode template methods specific to @c tk_string + * @c TypeCodes. + * + * @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::TypeCode_ptr get_compact_typecode_i ( + ACE_ENV_SINGLE_ARG_DECL) const; + virtual CORBA::ULong length_i (ACE_ENV_SINGLE_ARG_DECL) const; + + private: + + /// Length of the @c string. A length of zero indicates an + /// unbounded @c string. + CORBA::ULong const length_; + + }; + + } // End namespace TypeCode +} // End namespace TAO + +TAO_END_VERSIONED_NAMESPACE_DECL + + +#ifdef __ACE_INLINE__ +# include "tao/AnyTypeCode/String_TypeCode.inl" +#endif /* __ACE_INLINE__ */ + +#ifdef ACE_TEMPLATES_REQUIRE_SOURCE +# include "tao/AnyTypeCode/String_TypeCode.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#ifdef ACE_TEMPLATES_REQUIRE_PRAGMA +# pragma implementation ("String_TypeCode.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" + +#endif /* TAO_STRING_TYPECODE_H */ diff --git a/TAO/tao/AnyTypeCode/String_TypeCode.inl b/TAO/tao/AnyTypeCode/String_TypeCode.inl new file mode 100644 index 00000000000..c83c7be8667 --- /dev/null +++ b/TAO/tao/AnyTypeCode/String_TypeCode.inl @@ -0,0 +1,18 @@ +// -*- C++ -*- +// +// $Id$ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +template <class RefCountPolicy> +ACE_INLINE +TAO::TypeCode::String<RefCountPolicy>::String (CORBA::TCKind kind, + CORBA::ULong length) + : ::CORBA::TypeCode (kind) + , RefCountPolicy () + , length_ (length) +{ + // ACE_ASSERT (kind == CORBA::tk_string || kind == CORBA::tk_wstring); +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/String_TypeCode_Static.cpp b/TAO/tao/AnyTypeCode/String_TypeCode_Static.cpp new file mode 100644 index 00000000000..2066078627a --- /dev/null +++ b/TAO/tao/AnyTypeCode/String_TypeCode_Static.cpp @@ -0,0 +1,88 @@ +// $Id$ + +#include "tao/AnyTypeCode/String_TypeCode_Static.h" +#include "tao/CDR.h" + +#ifndef __ACE_INLINE__ +# include "tao/AnyTypeCode/String_TypeCode_Static.inl" +#endif /* !__ACE_INLINE__ */ + + +ACE_RCSID (AnyTypeCode, + String_TypeCode_Static, + "$Id$") + + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +bool +TAO::TypeCode::String<TAO::Null_RefCount_Policy>::tao_marshal ( + TAO_OutputCDR & cdr, + CORBA::ULong) const +{ + // A tk_string TypeCode has a "simple" parameter list type (see + // Table 15-2 in Section 15.3.5.1 "TypeCode" in the CDR section of + // the CORBA specification), meaning that its parameter(s) must be + // marshaled immediately following the TCKind. No CDR encapsulation + // is to be created. + + return (cdr << this->length_); +} + +void +TAO::TypeCode::String<TAO::Null_RefCount_Policy>::tao_duplicate (void) +{ +} + +void +TAO::TypeCode::String<TAO::Null_RefCount_Policy>::tao_release (void) +{ +} + +CORBA::Boolean +TAO::TypeCode::String<TAO::Null_RefCount_Policy>::equal_i ( + CORBA::TypeCode_ptr tc + ACE_ENV_ARG_DECL) const +{ + // The following call won't throw since CORBA::TypeCode::equal() has + // already established the kind of tc is the same as our kind. + CORBA::ULong const tc_length = tc->length (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + return (this->length_ == tc_length); +} + +CORBA::Boolean +TAO::TypeCode::String<TAO::Null_RefCount_Policy>::equivalent_i ( + CORBA::TypeCode_ptr tc + ACE_ENV_ARG_DECL) const +{ + // Since TCKind comparisons must be performed before equal_i() is + // called, we can also call it to determine equivalence of + // tk_string-based TypeCodes. + return this->equal_i (tc + ACE_ENV_ARG_PARAMETER); +} + +CORBA::TypeCode_ptr +TAO::TypeCode::String<TAO::Null_RefCount_Policy>::get_compact_typecode_i ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const +{ + // Already compact since tk_string and tk_wstring TypeCodes have no + // name or member names, meaning that we can simply call + // _duplicate() on this TypeCode. + + CORBA::TypeCode_ptr mutable_tc = + const_cast<TAO::TypeCode::String<TAO::Null_RefCount_Policy> *> (this); + + return CORBA::TypeCode::_duplicate (mutable_tc); +} + +CORBA::ULong +TAO::TypeCode::String<TAO::Null_RefCount_Policy>::length_i ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const +{ + return this->length_; +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/String_TypeCode_Static.h b/TAO/tao/AnyTypeCode/String_TypeCode_Static.h new file mode 100644 index 00000000000..8911843a9ee --- /dev/null +++ b/TAO/tao/AnyTypeCode/String_TypeCode_Static.h @@ -0,0 +1,110 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file String_TypeCode_Static.h + * + * $Id$ + * + * Header file for static @c CORBA::tk_string or @c CORBA::tk_wstring + * @c CORBA::TypeCodes. + * + * @author Ossama Othman <ossama@dre.vanderbilt.edu> + */ +//============================================================================= + +#ifndef TAO_STRING_TYPECODE_STATIC_H +#define TAO_STRING_TYPECODE_STATIC_H + +#include /**/ "ace/pre.h" + +#include "tao/AnyTypeCode/TypeCode.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/AnyTypeCode/Null_RefCount_Policy.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + namespace TypeCode + { + template <class RefCountPolicy> class String; + + /** + * @class String + * + * @brief @c CORBA::TypeCode implementation for OMG IDL string + * types. + * + * This class implements a @c CORBA::TypeCode for OMG IDL string + * types, including @c wstring. + */ + template<> + class TAO_AnyTypeCode_Export String<TAO::Null_RefCount_Policy> + : public CORBA::TypeCode, + private TAO::Null_RefCount_Policy + { + public: + + /// Constructor. + String (CORBA::TCKind kind, CORBA::ULong length); + + /** + * @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, + CORBA::ULong offset) const; + virtual void tao_duplicate (void); + virtual void tao_release (void); + //@} + + protected: + + /** + * @name @c TAO CORBA::TypeCode Template Methods + * + * @c CORBA::TypeCode template methods specific to @c tk_string + * @c TypeCodes. + * + * @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::TypeCode_ptr get_compact_typecode_i ( + ACE_ENV_SINGLE_ARG_DECL) const; + virtual CORBA::ULong length_i (ACE_ENV_SINGLE_ARG_DECL) const; + + private: + + /// Length of the @c string. A length of zero indicates an + /// unbounded @c string. + CORBA::ULong const length_; + + }; + + } // End namespace TypeCode +} // End namespace TAO + +TAO_END_VERSIONED_NAMESPACE_DECL + + +#ifdef __ACE_INLINE__ +# include "tao/AnyTypeCode/String_TypeCode_Static.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" + +#endif /* TAO_STRING_TYPECODE_STATIC_H */ diff --git a/TAO/tao/AnyTypeCode/String_TypeCode_Static.inl b/TAO/tao/AnyTypeCode/String_TypeCode_Static.inl new file mode 100644 index 00000000000..f9b3517f049 --- /dev/null +++ b/TAO/tao/AnyTypeCode/String_TypeCode_Static.inl @@ -0,0 +1,18 @@ +// -*- C++ -*- +// +// $Id$ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE +TAO::TypeCode::String<TAO::Null_RefCount_Policy>::String ( + CORBA::TCKind kind, + CORBA::ULong length) + : ::CORBA::TypeCode (kind) + , ::TAO::Null_RefCount_Policy () + , length_ (length) +{ + // ACE_ASSERT (kind == CORBA::tk_string || kind == CORBA::tk_wstring); +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/String_TypeCode_Traits.h b/TAO/tao/AnyTypeCode/String_TypeCode_Traits.h new file mode 100644 index 00000000000..670e6a835ba --- /dev/null +++ b/TAO/tao/AnyTypeCode/String_TypeCode_Traits.h @@ -0,0 +1,81 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file String_TypeCode_Traits.h + * + * $Id$ + * + * Header file for bound + * @c tk_string, + * @c tk_wstring, + * @c CORBA::TypeCode factories. + * + * @author Ossama Othman <ossama@dre.vanderbilt.edu> + */ +//============================================================================= + +#ifndef TAO_STRING_TYPECODE_TRAITS_H +#define TAO_STRING_TYPECODE_TRAITS_H + +#include /**/ "ace/pre.h" + + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/AnyTypeCode/String_TypeCode.h" +#include "tao/AnyTypeCode/True_RefCount_Policy.h" + + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + namespace TypeCodeFactory + { + template <typename T> struct String_Traits; + + template<> + struct String_Traits<CORBA::Any::from_string> + { + static CORBA::TypeCode_ptr create_typecode (CORBA::TCKind kind, + CORBA::ULong bound) + { + typedef TAO::TypeCode::String<TAO::True_RefCount_Policy> typecode_type; + + CORBA::TypeCode_ptr tc = CORBA::TypeCode::_nil (); + ACE_NEW_RETURN (tc, + typecode_type (kind, bound), + tc); + + return tc; + } + }; + + template <> + struct String_Traits<CORBA::Any::from_wstring> + { + static CORBA::TypeCode_ptr create_typecode (CORBA::TCKind kind, + CORBA::ULong bound) + { + typedef TAO::TypeCode::String<TAO::True_RefCount_Policy> typecode_type; + + CORBA::TypeCode_ptr tc = CORBA::TypeCode::_nil (); + ACE_NEW_RETURN (tc, + typecode_type (kind, bound), + tc); + + return tc; + } + }; + + } // End namespace TypeCodeFactory +} // End namespace TAO + +TAO_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" + +#endif /* TAO_STRING_TYPECODE_TRAITS_H */ diff --git a/TAO/tao/AnyTypeCode/Struct_TypeCode.cpp b/TAO/tao/AnyTypeCode/Struct_TypeCode.cpp new file mode 100644 index 00000000000..aa50e7bdf78 --- /dev/null +++ b/TAO/tao/AnyTypeCode/Struct_TypeCode.cpp @@ -0,0 +1,349 @@ +// $Id$ + +#ifndef TAO_STRUCT_TYPECODE_CPP +#define TAO_STRUCT_TYPECODE_CPP + +#include "tao/AnyTypeCode/Struct_TypeCode.h" +#include "tao/AnyTypeCode/TypeCode_Struct_Field.h" +#include "tao/AnyTypeCode/TypeCode_Traits.h" +#include "tao/ORB_Core.h" +#include "tao/TypeCodeFactory_Adapter.h" +#include "tao/CDR.h" + + +#ifndef __ACE_INLINE__ +# include "tao/AnyTypeCode/Struct_TypeCode.inl" +#endif /* !__ACE_INLINE__ */ + +#include "ace/Dynamic_Service.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +template <typename StringType, + typename TypeCodeType, + class FieldArrayType, + class RefCountPolicy> +bool +TAO::TypeCode::Struct<StringType, + TypeCodeType, + FieldArrayType, + RefCountPolicy>::tao_marshal (TAO_OutputCDR & cdr, + CORBA::ULong offset) const +{ + // A tk_struct 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. + TAO_OutputCDR enc; + + // Account for the encoded CDR encapsulation length and byte order. + // + // Aligning on an octet since the next value after the CDR + // encapsulation length will always be the byte order octet/boolean + // in this case. + offset = ACE_align_binary (offset + 4, + ACE_CDR::OCTET_ALIGN); + + bool const success = + (enc << TAO_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER)) + && (enc << TAO_OutputCDR::from_string (this->base_attributes_.id (), 0)) + && (enc << TAO_OutputCDR::from_string (this->base_attributes_.name (), 0)) + && (enc << this->nfields_); + + if (!success) + return false; + + Struct_Field<StringType, TypeCodeType> const * const begin = + &this->fields_[0]; + Struct_Field<StringType, TypeCodeType> const * const end = + begin + this->nfields_; + + for (Struct_Field<StringType, TypeCodeType> const * i = begin; i != end; ++i) + { + Struct_Field<StringType, TypeCodeType> const & field = *i; + + if (!(enc << TAO_OutputCDR::from_string ( + Traits<StringType>::get_string (field.name), 0)) + || !marshal (enc, + Traits<StringType>::get_typecode (field.type), + offset + enc.total_length ())) + return false; + } + + return + cdr << static_cast<CORBA::ULong> (enc.total_length ()) + && cdr.write_octet_array_mb (enc.begin ()); +} + +template <typename StringType, + typename TypeCodeType, + class FieldArrayType, + class RefCountPolicy> +void +TAO::TypeCode::Struct<StringType, + TypeCodeType, + FieldArrayType, + RefCountPolicy>::tao_duplicate (void) +{ + this->RefCountPolicy::add_ref (); +} + +template <typename StringType, + typename TypeCodeType, + class FieldArrayType, + class RefCountPolicy> +void +TAO::TypeCode::Struct<StringType, + TypeCodeType, + FieldArrayType, + RefCountPolicy>::tao_release (void) +{ + this->RefCountPolicy::remove_ref (); +} + +template <typename StringType, + typename TypeCodeType, + class FieldArrayType, + class RefCountPolicy> +CORBA::Boolean +TAO::TypeCode::Struct<StringType, + TypeCodeType, + FieldArrayType, + 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 (false); + + if (tc_nfields != this->nfields_) + return false; + + for (CORBA::ULong i = 0; i < this->nfields_; ++i) + { + Struct_Field<StringType, TypeCodeType> const & lhs_field = + this->fields_[i]; + + char const * const lhs_name = + Traits<StringType>::get_string (lhs_field.name); + char const * const rhs_name = tc->member_name (i + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + if (ACE_OS::strcmp (lhs_name, rhs_name) != 0) + return false; + + CORBA::TypeCode_ptr const lhs_tc = + Traits<StringType>::get_typecode (lhs_field.type); + CORBA::TypeCode_var const rhs_tc = + tc->member_type (i + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + CORBA::Boolean const equal_members = + lhs_tc->equal (rhs_tc.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + if (!equal_members) + return false; + } + + return true; +} + +template <typename StringType, + typename TypeCodeType, + class FieldArrayType, + class RefCountPolicy> +CORBA::Boolean +TAO::TypeCode::Struct<StringType, + TypeCodeType, + FieldArrayType, + RefCountPolicy>::equivalent_i ( + CORBA::TypeCode_ptr tc + ACE_ENV_ARG_DECL) const +{ + // 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 (false); + + if (tc_nfields != this->nfields_) + return false; + + for (CORBA::ULong i = 0; i < this->nfields_; ++i) + { + CORBA::TypeCode_ptr const lhs = + Traits<StringType>::get_typecode (this->fields_[i].type); + CORBA::TypeCode_var const rhs = + tc->member_type (i + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + CORBA::Boolean const equiv_members = + lhs->equivalent (rhs.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + if (!equiv_members) + return false; + } + + return true; +} + +template <typename StringType, + typename TypeCodeType, + class FieldArrayType, + class RefCountPolicy> +CORBA::TypeCode_ptr +TAO::TypeCode::Struct<StringType, + TypeCodeType, + FieldArrayType, + RefCountPolicy>::get_compact_typecode_i ( + ACE_ENV_SINGLE_ARG_DECL) const +{ + ACE_Array_Base<Struct_Field<CORBA::String_var, + CORBA::TypeCode_var> > + tc_fields (this->nfields_); + + if (this->nfields_ > 0) + { + // Dynamically construct a new array of fields stripped of + // member names. + + static char 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 = + Traits<StringType>::get_typecode ( + this->fields_[i].type)->get_compact_typecode ( + ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (CORBA::TypeCode::_nil ()); + } + } + + TAO_TypeCodeFactory_Adapter * const 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 ()); + } + + return + adapter->create_struct_except_tc (this->kind_, + this->base_attributes_.id (), + "" /* empty name */, + tc_fields, + this->nfields_ + ACE_ENV_ARG_PARAMETER); +} + +template <typename StringType, + typename TypeCodeType, + class FieldArrayType, + class RefCountPolicy> +char const * +TAO::TypeCode::Struct<StringType, + TypeCodeType, + FieldArrayType, + 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, + typename TypeCodeType, + class FieldArrayType, + class RefCountPolicy> +char const * +TAO::TypeCode::Struct<StringType, + TypeCodeType, + FieldArrayType, + 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, + typename TypeCodeType, + class FieldArrayType, + class RefCountPolicy> +CORBA::ULong +TAO::TypeCode::Struct<StringType, + TypeCodeType, + FieldArrayType, + RefCountPolicy>::member_count_i ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const +{ + return this->nfields_; +} + +template <typename StringType, + typename TypeCodeType, + class FieldArrayType, + class RefCountPolicy> +char const * +TAO::TypeCode::Struct<StringType, + TypeCodeType, + FieldArrayType, + 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 Traits<StringType>::get_string (this->fields_[index].name); +} + +template <typename StringType, + typename TypeCodeType, + class FieldArrayType, + class RefCountPolicy> +CORBA::TypeCode_ptr +TAO::TypeCode::Struct<StringType, + TypeCodeType, + FieldArrayType, + 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 ( + Traits<StringType>::get_typecode (this->fields_[index].type)); +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +#endif /* TAO_STRUCT_TYPECODE_CPP */ diff --git a/TAO/tao/AnyTypeCode/Struct_TypeCode.h b/TAO/tao/AnyTypeCode/Struct_TypeCode.h new file mode 100644 index 00000000000..df44f2d2a3a --- /dev/null +++ b/TAO/tao/AnyTypeCode/Struct_TypeCode.h @@ -0,0 +1,158 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Struct_TypeCode.h + * + * $Id$ + * + * Header file for a @c tk_struct and @c tk_except + * @c CORBA::TypeCodes. + * + * @author Ossama Othman <ossama@dre.vanderbilt.edu> + * @author Carlos O'Ryan + */ +//============================================================================= + +#ifndef TAO_STRUCT_TYPECODE_H +#define TAO_STRUCT_TYPECODE_H + +#include /**/ "ace/pre.h" + +#include "tao/AnyTypeCode/TypeCode.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/AnyTypeCode/TypeCode_Base_Attributes.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + namespace TypeCode + { + template<typename StringType, typename TypeCodeType> struct Struct_Field; + + /** + * @class Struct + * + * @brief @c CORBA::TypeCode implementation for an OMG IDL + * @c struct or @c exception. + * + * This class implements a @c CORBA::TypeCode for an OMG IDL + * @c struct or @c exception. + */ + template <typename StringType, + typename TypeCodeType, + class FieldArrayType, + class RefCountPolicy> + class Struct + : public CORBA::TypeCode, + private RefCountPolicy + { + public: + + /// Constructor. + Struct (CORBA::TCKind kind, + char const * id, + char const * name, + FieldArrayType const & fields, + CORBA::ULong nfields); + + /// Constructor used for recursive TypeCodes. + Struct (CORBA::TCKind kind, + char const * id); + + /** + * @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, + CORBA::ULong offset) const; + virtual void tao_duplicate (void); + virtual void tao_release (void); + //@} + + protected: + + /** + * @name @c TAO CORBA::TypeCode Template Methods + * + * @c tk_struct or @c tk_except @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::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; + //@} + + protected: + + /** + * @c Struct Attributes + * + * Attributes representing the structure of an OMG IDL + * @c struct or @c exception. + * + * @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 + /// structure type. + Base_Attributes<StringType> base_attributes_; + + /// The number of fields in the OMG IDL structure. + CORBA::ULong nfields_; + + /// Array of @c TAO::TypeCode fields representing structure of the + /// OMG IDL defined @c struct. + FieldArrayType fields_; + + //@} + + }; + + } // End namespace TypeCode +} // End namespace TAO + +TAO_END_VERSIONED_NAMESPACE_DECL + +#ifdef __ACE_INLINE__ +# include "tao/AnyTypeCode/Struct_TypeCode.inl" +#endif /* __ACE_INLINE__ */ + +#ifdef ACE_TEMPLATES_REQUIRE_SOURCE +# include "tao/AnyTypeCode/Struct_TypeCode.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#ifdef ACE_TEMPLATES_REQUIRE_PRAGMA +# pragma implementation ("Struct_TypeCode.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + + +#include /**/ "ace/post.h" + +#endif /* TAO_STRUCT_TYPECODE_H */ diff --git a/TAO/tao/AnyTypeCode/Struct_TypeCode.inl b/TAO/tao/AnyTypeCode/Struct_TypeCode.inl new file mode 100644 index 00000000000..d064338ee22 --- /dev/null +++ b/TAO/tao/AnyTypeCode/Struct_TypeCode.inl @@ -0,0 +1,50 @@ +// -*- C++ -*- +// +// $Id$ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +template <typename StringType, + typename TypeCodeType, + class FieldArrayType, + class RefCountPolicy> +ACE_INLINE +TAO::TypeCode::Struct<StringType, + TypeCodeType, + FieldArrayType, + RefCountPolicy>::Struct ( + CORBA::TCKind kind, + char const * id, + char const * name, + FieldArrayType const & fields, + CORBA::ULong nfields) + : ::CORBA::TypeCode (kind) + , RefCountPolicy () + , base_attributes_ (id, name) + , nfields_ (nfields) + , fields_ (fields) +{ +} + +template <typename StringType, + typename TypeCodeType, + class FieldArrayType, + class RefCountPolicy> +ACE_INLINE +TAO::TypeCode::Struct<StringType, + TypeCodeType, + FieldArrayType, + RefCountPolicy>::Struct ( + CORBA::TCKind kind, + char const * id) + : ::CORBA::TypeCode (kind) + , RefCountPolicy () + , base_attributes_ (id) + , nfields_ (0) + , fields_ () +{ + // CORBA::tk_except is not allowed in the recursive TypeCode case. + // ACE_ASSERT (kind == CORBA::tk_struct); +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/Struct_TypeCode_Static.cpp b/TAO/tao/AnyTypeCode/Struct_TypeCode_Static.cpp new file mode 100644 index 00000000000..57e6be6de4e --- /dev/null +++ b/TAO/tao/AnyTypeCode/Struct_TypeCode_Static.cpp @@ -0,0 +1,320 @@ +// $Id$ + +#include "tao/AnyTypeCode/Struct_TypeCode_Static.h" +#include "tao/AnyTypeCode/TypeCode_Struct_Field.h" +#include "tao/AnyTypeCode/TypeCode_Traits.h" +#include "tao/ORB_Core.h" +#include "tao/TypeCodeFactory_Adapter.h" +#include "tao/CDR.h" + + +#ifndef __ACE_INLINE__ +# include "tao/AnyTypeCode/Struct_TypeCode_Static.inl" +#endif /* !__ACE_INLINE__ */ + +#include "ace/Dynamic_Service.h" + + +ACE_RCSID (AnyTypeCode, + Struct_TypeCode_Static, + "$Id$") + + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +bool +TAO::TypeCode::Struct<char const *, + CORBA::TypeCode_ptr const *, + TAO::TypeCode::Struct_Field<char const *, + CORBA::TypeCode_ptr const *> const *, + TAO::Null_RefCount_Policy>::tao_marshal ( + TAO_OutputCDR & cdr, + CORBA::ULong offset) const +{ + // A tk_struct 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. + TAO_OutputCDR enc; + + // Account for the encoded CDR encapsulation length and byte order. + // + // Aligning on an octet since the next value after the CDR + // encapsulation length will always be the byte order octet/boolean + // in this case. + offset = ACE_align_binary (offset + 4, + ACE_CDR::OCTET_ALIGN); + + bool const success = + (enc << TAO_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER)) + && (enc << TAO_OutputCDR::from_string (this->base_attributes_.id (), 0)) + && (enc << TAO_OutputCDR::from_string (this->base_attributes_.name (), 0)) + && (enc << this->nfields_); + + if (!success) + return false; + + Struct_Field<char const *, CORBA::TypeCode_ptr const *> const * const begin = + &this->fields_[0]; + Struct_Field<char const *, CORBA::TypeCode_ptr const *> const * const end = + begin + this->nfields_; + + for (Struct_Field<char const *, CORBA::TypeCode_ptr const *> const * i = + begin; + i != end; + ++i) + { + Struct_Field<char const *, CORBA::TypeCode_ptr const *> const & field = + *i; + + if (!(enc << TAO_OutputCDR::from_string ( + Traits<char const *>::get_string (field.name), 0)) + || !marshal (enc, + Traits<char const *>::get_typecode (field.type), + offset + enc.total_length ())) + return false; + } + + return + cdr << static_cast<CORBA::ULong> (enc.total_length ()) + && cdr.write_octet_array_mb (enc.begin ()); +} + +void +TAO::TypeCode::Struct<char const *, + CORBA::TypeCode_ptr const *, + TAO::TypeCode::Struct_Field<char const *, + CORBA::TypeCode_ptr const *> const *, + TAO::Null_RefCount_Policy>::tao_duplicate (void) +{ +} + +void +TAO::TypeCode::Struct<char const *, + CORBA::TypeCode_ptr const *, + TAO::TypeCode::Struct_Field<char const *, + CORBA::TypeCode_ptr const *> const *, + TAO::Null_RefCount_Policy>::tao_release (void) +{ +} + +CORBA::Boolean +TAO::TypeCode::Struct<char const *, + CORBA::TypeCode_ptr const *, + TAO::TypeCode::Struct_Field<char const *, + CORBA::TypeCode_ptr const *> const *, + TAO::Null_RefCount_Policy>::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 (false); + + if (tc_nfields != this->nfields_) + return false; + + for (CORBA::ULong i = 0; i < this->nfields_; ++i) + { + Struct_Field<char const *, CORBA::TypeCode_ptr const *> const & + lhs_field = this->fields_[i]; + + char const * const lhs_name = + Traits<char const *>::get_string (lhs_field.name); + char const * const rhs_name = tc->member_name (i + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + if (ACE_OS::strcmp (lhs_name, rhs_name) != 0) + return false; + + CORBA::TypeCode_ptr const lhs_tc = + Traits<char const *>::get_typecode (lhs_field.type); + CORBA::TypeCode_var const rhs_tc = + tc->member_type (i + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + CORBA::Boolean const equal_members = + lhs_tc->equal (rhs_tc.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + if (!equal_members) + return false; + } + + return true; +} + +CORBA::Boolean +TAO::TypeCode::Struct<char const *, + CORBA::TypeCode_ptr const *, + TAO::TypeCode::Struct_Field<char const *, + CORBA::TypeCode_ptr const *> const *, + TAO::Null_RefCount_Policy>::equivalent_i ( + CORBA::TypeCode_ptr tc + ACE_ENV_ARG_DECL) const +{ + // 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 (false); + + if (tc_nfields != this->nfields_) + return false; + + for (CORBA::ULong i = 0; i < this->nfields_; ++i) + { + CORBA::TypeCode_ptr const lhs = + Traits<char const *>::get_typecode (this->fields_[i].type); + CORBA::TypeCode_var const rhs = + tc->member_type (i + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + CORBA::Boolean const equiv_members = + lhs->equivalent (rhs.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + if (!equiv_members) + return false; + } + + return true; +} + +CORBA::TypeCode_ptr +TAO::TypeCode::Struct<char const *, + CORBA::TypeCode_ptr const *, + TAO::TypeCode::Struct_Field<char const *, + CORBA::TypeCode_ptr const *> const *, + TAO::Null_RefCount_Policy>::get_compact_typecode_i ( + ACE_ENV_SINGLE_ARG_DECL) const +{ + ACE_Array_Base<Struct_Field<CORBA::String_var, + CORBA::TypeCode_var> > + tc_fields (this->nfields_); + + if (this->nfields_ > 0) + { + // Dynamically construct a new array of fields stripped of + // member names. + + static char 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 = + Traits<char const *>::get_typecode ( + this->fields_[i].type)->get_compact_typecode ( + ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (CORBA::TypeCode::_nil ()); + } + } + + TAO_TypeCodeFactory_Adapter * const 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 ()); + } + + return + adapter->create_struct_except_tc (this->kind_, + this->base_attributes_.id (), + "" /* empty name */, + tc_fields, + this->nfields_ + ACE_ENV_ARG_PARAMETER); +} + +char const * +TAO::TypeCode::Struct<char const *, + CORBA::TypeCode_ptr const *, + TAO::TypeCode::Struct_Field<char const *, + CORBA::TypeCode_ptr const *> const *, + TAO::Null_RefCount_Policy>::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 (); +} + +char const * +TAO::TypeCode::Struct<char const *, + CORBA::TypeCode_ptr const *, + TAO::TypeCode::Struct_Field<char const *, + CORBA::TypeCode_ptr const *> const *, + TAO::Null_RefCount_Policy>::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 (); +} + +CORBA::ULong +TAO::TypeCode::Struct<char const *, + CORBA::TypeCode_ptr const *, + TAO::TypeCode::Struct_Field<char const *, + CORBA::TypeCode_ptr const *> const *, + TAO::Null_RefCount_Policy>::member_count_i ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const +{ + return this->nfields_; +} + +char const * +TAO::TypeCode::Struct<char const *, + CORBA::TypeCode_ptr const *, + TAO::TypeCode::Struct_Field<char const *, + CORBA::TypeCode_ptr const *> const *, + TAO::Null_RefCount_Policy>::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 Traits<char const *>::get_string (this->fields_[index].name); +} + +CORBA::TypeCode_ptr +TAO::TypeCode::Struct<char const *, + CORBA::TypeCode_ptr const *, + TAO::TypeCode::Struct_Field<char const *, + CORBA::TypeCode_ptr const *> const *, + TAO::Null_RefCount_Policy>::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 ( + Traits<char const *>::get_typecode (this->fields_[index].type)); +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/Struct_TypeCode_Static.h b/TAO/tao/AnyTypeCode/Struct_TypeCode_Static.h new file mode 100644 index 00000000000..dea9405238b --- /dev/null +++ b/TAO/tao/AnyTypeCode/Struct_TypeCode_Static.h @@ -0,0 +1,154 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Struct_TypeCode_Static.h + * + * $Id$ + * + * Header file for static @c tk_struct and @c tk_except + * @c CORBA::TypeCodes. + * + * @author Ossama Othman <ossama@dre.vanderbilt.edu> + * @author Carlos O'Ryan + */ +//============================================================================= + +#ifndef TAO_STRUCT_TYPECODE_STATIC_H +#define TAO_STRUCT_TYPECODE_STATIC_H + +#include /**/ "ace/pre.h" + +#include "tao/AnyTypeCode/TypeCode.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/AnyTypeCode/TypeCode_Base_Attributes.h" +#include "tao/AnyTypeCode/Null_RefCount_Policy.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + namespace TypeCode + { + template<typename StringType, typename TypeCodeType> struct Struct_Field; + template <typename StringType, + typename TypeCodeType, + class FieldArrayType, + class RefCountPolicy> class Struct; + + + /** + * @class Struct + * + * @brief @c CORBA::TypeCode implementation for an OMG IDL + * @c struct or @c exception. + * + * This class implements a @c CORBA::TypeCode for an OMG IDL + * @c struct or @c exception. + */ + template<> + class TAO_AnyTypeCode_Export Struct<char const *, + CORBA::TypeCode_ptr const *, + Struct_Field<char const *, + CORBA::TypeCode_ptr const *> const *, + TAO::Null_RefCount_Policy> + : public CORBA::TypeCode, + private TAO::Null_RefCount_Policy + { + public: + + /// Constructor. + Struct (CORBA::TCKind kind, + char const * id, + char const * name, + Struct_Field<char const *, + CORBA::TypeCode_ptr const *> 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, + CORBA::ULong offset) const; + virtual void tao_duplicate (void); + virtual void tao_release (void); + //@} + + protected: + + /** + * @name @c TAO CORBA::TypeCode Template Methods + * + * @c tk_struct or @c tk_except @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::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; + //@} + + private: + + /** + * @c Struct Attributes + * + * Attributes representing the structure of an OMG IDL + * @c struct or @c exception. + * + * @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 + /// structure type. + Base_Attributes<char const *> const base_attributes_; + + /// The number of fields in the OMG IDL structure. + CORBA::ULong const nfields_; + + /// Array of @c TAO::TypeCode fields representing structure of the + /// OMG IDL defined @c struct. + Struct_Field<char const *, + CORBA::TypeCode_ptr const *> const * const fields_; + + //@} + + }; + + } // End namespace TypeCode +} // End namespace TAO + +TAO_END_VERSIONED_NAMESPACE_DECL + +#ifdef __ACE_INLINE__ +# include "tao/AnyTypeCode/Struct_TypeCode_Static.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" + +#endif /* TAO_STRUCT_TYPECODE_H */ diff --git a/TAO/tao/AnyTypeCode/Struct_TypeCode_Static.inl b/TAO/tao/AnyTypeCode/Struct_TypeCode_Static.inl new file mode 100644 index 00000000000..7b2d60faa3f --- /dev/null +++ b/TAO/tao/AnyTypeCode/Struct_TypeCode_Static.inl @@ -0,0 +1,26 @@ +// -*- C++ -*- +// +// $Id$ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE +TAO::TypeCode::Struct<char const *, + CORBA::TypeCode_ptr const *, + TAO::TypeCode::Struct_Field<char const *, + CORBA::TypeCode_ptr const *> const *, + TAO::Null_RefCount_Policy>::Struct ( + CORBA::TCKind kind, + char const * id, + char const * name, + Struct_Field<char const *, CORBA::TypeCode_ptr const *> const * fields, + CORBA::ULong nfields) + : ::CORBA::TypeCode (kind) + , ::TAO::Null_RefCount_Policy () + , base_attributes_ (id, name) + , nfields_ (nfields) + , fields_ (fields) +{ +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/SystemExceptionA.cpp b/TAO/tao/AnyTypeCode/SystemExceptionA.cpp new file mode 100644 index 00000000000..61aa6cd380f --- /dev/null +++ b/TAO/tao/AnyTypeCode/SystemExceptionA.cpp @@ -0,0 +1,185 @@ +// $Id$ + +#include "tao/AnyTypeCode/SystemExceptionA.h" +#include "tao/AnyTypeCode/Any_SystemException.h" +#include "tao/AnyTypeCode/Any_Dual_Impl_T.h" +#include "tao/AnyTypeCode/TypeCode.h" +#include "tao/AnyTypeCode/TypeCode_Constants.h" +#include "tao/AnyTypeCode/Enum_TypeCode_Static.h" +#include "tao/AnyTypeCode/TypeCode_Struct_Field.h" +#include "tao/AnyTypeCode/Struct_TypeCode_Static.h" +#include "tao/AnyTypeCode/Null_RefCount_Policy.h" + +#include "tao/CORBA_String.h" + +ACE_RCSID (AnyTypeCode, + SystemExceptionA, + "$Id$") + + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +#if defined (THREAD_CANCELLED) +#undef THREAD_CANCELLED +#endif /* THREAD_CANCELLED */ + +// List of standard/system exceptions ... used to create static +// storage for their typecodes. + +#define STANDARD_EXCEPTION_LIST \ + TAO_SYSTEM_EXCEPTION (UNKNOWN) \ + TAO_SYSTEM_EXCEPTION (BAD_PARAM) \ + TAO_SYSTEM_EXCEPTION (NO_MEMORY) \ + TAO_SYSTEM_EXCEPTION (IMP_LIMIT) \ + TAO_SYSTEM_EXCEPTION (COMM_FAILURE) \ + TAO_SYSTEM_EXCEPTION (INV_OBJREF) \ + TAO_SYSTEM_EXCEPTION (OBJECT_NOT_EXIST) \ + TAO_SYSTEM_EXCEPTION (NO_PERMISSION) \ + TAO_SYSTEM_EXCEPTION (INTERNAL) \ + TAO_SYSTEM_EXCEPTION (MARSHAL) \ + TAO_SYSTEM_EXCEPTION (INITIALIZE) \ + TAO_SYSTEM_EXCEPTION (NO_IMPLEMENT) \ + TAO_SYSTEM_EXCEPTION (BAD_TYPECODE) \ + TAO_SYSTEM_EXCEPTION (BAD_OPERATION) \ + TAO_SYSTEM_EXCEPTION (NO_RESOURCES) \ + TAO_SYSTEM_EXCEPTION (NO_RESPONSE) \ + TAO_SYSTEM_EXCEPTION (PERSIST_STORE) \ + TAO_SYSTEM_EXCEPTION (BAD_INV_ORDER) \ + TAO_SYSTEM_EXCEPTION (TRANSIENT) \ + TAO_SYSTEM_EXCEPTION (FREE_MEM) \ + TAO_SYSTEM_EXCEPTION (INV_IDENT) \ + TAO_SYSTEM_EXCEPTION (INV_FLAG) \ + TAO_SYSTEM_EXCEPTION (INTF_REPOS) \ + TAO_SYSTEM_EXCEPTION (BAD_CONTEXT) \ + TAO_SYSTEM_EXCEPTION (OBJ_ADAPTER) \ + TAO_SYSTEM_EXCEPTION (DATA_CONVERSION) \ + TAO_SYSTEM_EXCEPTION (INV_POLICY) \ + TAO_SYSTEM_EXCEPTION (REBIND) \ + TAO_SYSTEM_EXCEPTION (TIMEOUT) \ + TAO_SYSTEM_EXCEPTION (TRANSACTION_UNAVAILABLE) \ + TAO_SYSTEM_EXCEPTION (TRANSACTION_MODE) \ + TAO_SYSTEM_EXCEPTION (TRANSACTION_REQUIRED) \ + TAO_SYSTEM_EXCEPTION (TRANSACTION_ROLLEDBACK) \ + TAO_SYSTEM_EXCEPTION (INVALID_TRANSACTION) \ + TAO_SYSTEM_EXCEPTION (CODESET_INCOMPATIBLE) \ + TAO_SYSTEM_EXCEPTION (BAD_QOS) \ + TAO_SYSTEM_EXCEPTION (INVALID_ACTIVITY) \ + TAO_SYSTEM_EXCEPTION (ACTIVITY_COMPLETED) \ + TAO_SYSTEM_EXCEPTION (ACTIVITY_REQUIRED) \ + TAO_SYSTEM_EXCEPTION (THREAD_CANCELLED) + +namespace TAO +{ + namespace TypeCode + { + char const * const enumerators_CORBA_CompletionStatus[] = + { + "COMPLETED_YES", + "COMPLETED_NO", + "COMPLETED_MAYBE" + }; + + Enum<char const *, + char const * const *, + TAO::Null_RefCount_Policy> + tc_CompletionStatus ("IDL:omg.org/CORBA/CompletionStatus:1.0", + "CompletionStatus", + enumerators_CORBA_CompletionStatus, + 3 /* # of enumerators */); + } +} + +namespace CORBA +{ + // An internal TypeCode. + TypeCode_ptr const _tc_CompletionStatus = + &TAO::TypeCode::tc_CompletionStatus; +} + +namespace TAO +{ + namespace TypeCode + { + Struct_Field<char const *, + CORBA::TypeCode_ptr const *> const + fields_CORBA_SystemException[] = + { + { "minor", &CORBA::_tc_ulong }, + { "completed", &CORBA::_tc_CompletionStatus } + }; + + typedef TAO::TypeCode::Struct<char const *, + CORBA::TypeCode_ptr const *, + TAO::TypeCode::Struct_Field<char const *, + CORBA::TypeCode_ptr const *> const *, + TAO::Null_RefCount_Policy> tc_SystemException; + } +} + +#define TAO_SYSTEM_EXCEPTION(name) \ +namespace TAO \ +{ \ + namespace TypeCode \ + { \ + tc_SystemException tc_CORBA_ ## name ( \ + CORBA::tk_except, \ + "IDL:omg.org/CORBA/" #name ":1.0", \ + #name, \ + TAO::TypeCode::fields_CORBA_SystemException, \ + 2 /* # of fields */); \ + } \ +} \ +CORBA::TypeCode_ptr const CORBA::_tc_ ## name = \ + &TAO::TypeCode::tc_CORBA_ ## name; + +STANDARD_EXCEPTION_LIST +#undef TAO_SYSTEM_EXCEPTION + + +#define TAO_SYSTEM_EXCEPTION(name) \ +void \ +CORBA::operator<<= (CORBA::Any &any, const CORBA::name &ex) \ +{ \ + TAO::Any_SystemException::insert_copy ( \ + any, \ + CORBA::name ::_tao_any_destructor, \ + CORBA::_tc_ ## name, \ + ex \ + ); \ +} + +STANDARD_EXCEPTION_LIST +#undef TAO_SYSTEM_EXCEPTION + +#define TAO_SYSTEM_EXCEPTION(name) \ +void \ +CORBA::operator<<= (CORBA::Any &any, CORBA::name *ex) \ +{ \ + TAO::Any_SystemException::insert ( \ + any, \ + CORBA::name ::_tao_any_destructor, \ + CORBA::_tc_ ## name, \ + ex \ + ); \ +} + +STANDARD_EXCEPTION_LIST +#undef TAO_SYSTEM_EXCEPTION + +#define TAO_SYSTEM_EXCEPTION(name) \ +CORBA::Boolean operator>>= (const CORBA::Any &any, \ + const CORBA::name *&ex) \ +{ \ + return \ + TAO::Any_SystemException::extract ( \ + any, \ + CORBA::name ::_tao_any_destructor, \ + CORBA::_tc_ ## name, \ + (const CORBA::SystemException *&) ex, \ + &CORBA::name ::_tao_create); \ +} + +STANDARD_EXCEPTION_LIST +#undef TAO_SYSTEM_EXCEPTION + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/SystemExceptionA.h b/TAO/tao/AnyTypeCode/SystemExceptionA.h new file mode 100644 index 00000000000..b6ca62d2e55 --- /dev/null +++ b/TAO/tao/AnyTypeCode/SystemExceptionA.h @@ -0,0 +1,93 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file SystemExceptionA.h + * + * $Id$ + * + * SystemException Any operator and typecode decls. + * + * @author Jeff Parsons <j.parsons@vanderbilt.edu> + */ +//============================================================================= + +#ifndef TAO_SYSTEMEXCEPTIONA_H +#define TAO_SYSTEMEXCEPTIONA_H + +#include /**/ "ace/pre.h" +#include "tao/AnyTypeCode/TAO_AnyTypeCode_Export.h" +#include "tao/AnyTypeCode/AnyTypeCode_methods.h" +#include "tao/SystemException.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace CORBA +{ + class TypeCode; + typedef TypeCode *TypeCode_ptr; + + class Any; + typedef Any *Any_ptr; + +#define TAO_SYSTEM_EXCEPTION(name) \ + TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, \ + const CORBA::name &); \ + TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, \ + CORBA::name *); \ + TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any &, \ + const CORBA::name *&); \ + extern TAO_AnyTypeCode_Export TypeCode_ptr const _tc_ ## name + + TAO_SYSTEM_EXCEPTION(UNKNOWN); // the unknown exception + TAO_SYSTEM_EXCEPTION(BAD_PARAM); // an invalid parameter was passed + TAO_SYSTEM_EXCEPTION(NO_MEMORY); // memory allocation failure + TAO_SYSTEM_EXCEPTION(IMP_LIMIT); // violated implementation limit + TAO_SYSTEM_EXCEPTION(COMM_FAILURE); // communication failure + TAO_SYSTEM_EXCEPTION(INV_OBJREF); // invalid object reference + TAO_SYSTEM_EXCEPTION(OBJECT_NOT_EXIST); // no such object + TAO_SYSTEM_EXCEPTION(NO_PERMISSION); // no permission for operation + TAO_SYSTEM_EXCEPTION(INTERNAL); // ORB internal error + TAO_SYSTEM_EXCEPTION(MARSHAL); // error marshaling param/result + TAO_SYSTEM_EXCEPTION(INITIALIZE); // ORB initialization failure + TAO_SYSTEM_EXCEPTION(NO_IMPLEMENT); // implementation unavailable + TAO_SYSTEM_EXCEPTION(BAD_TYPECODE); // bad typecode + TAO_SYSTEM_EXCEPTION(BAD_OPERATION); // invalid operation + TAO_SYSTEM_EXCEPTION(NO_RESOURCES); // out of resources for request + TAO_SYSTEM_EXCEPTION(NO_RESPONSE); // response not yet available + TAO_SYSTEM_EXCEPTION(PERSIST_STORE); // persistent storage failure + TAO_SYSTEM_EXCEPTION(BAD_INV_ORDER); // routine invocations out of order + TAO_SYSTEM_EXCEPTION(TRANSIENT); // transient error, try again later + TAO_SYSTEM_EXCEPTION(FREE_MEM); // cannot free memory + TAO_SYSTEM_EXCEPTION(INV_IDENT); // invalid identifier syntax + TAO_SYSTEM_EXCEPTION(INV_FLAG); // invalid flag was specified + TAO_SYSTEM_EXCEPTION(INTF_REPOS); // interface repository unavailable + TAO_SYSTEM_EXCEPTION(BAD_CONTEXT); // error processing context object + TAO_SYSTEM_EXCEPTION(OBJ_ADAPTER); // object adapter failure + TAO_SYSTEM_EXCEPTION(DATA_CONVERSION); // data conversion error + TAO_SYSTEM_EXCEPTION(INV_POLICY); // invalid policies present + TAO_SYSTEM_EXCEPTION(REBIND); // rebind needed + TAO_SYSTEM_EXCEPTION(TIMEOUT); // operation timed out + TAO_SYSTEM_EXCEPTION(TRANSACTION_UNAVAILABLE); // no transaction + TAO_SYSTEM_EXCEPTION(TRANSACTION_MODE); // invalid transaction mode + TAO_SYSTEM_EXCEPTION(TRANSACTION_REQUIRED); // operation needs transaction + TAO_SYSTEM_EXCEPTION(TRANSACTION_ROLLEDBACK); // operation was a no-op + TAO_SYSTEM_EXCEPTION(INVALID_TRANSACTION); // invalid TP context passed + TAO_SYSTEM_EXCEPTION(CODESET_INCOMPATIBLE); // incompatible code set + TAO_SYSTEM_EXCEPTION(BAD_QOS); // bad quality of service + TAO_SYSTEM_EXCEPTION(INVALID_ACTIVITY); + TAO_SYSTEM_EXCEPTION(ACTIVITY_COMPLETED); + TAO_SYSTEM_EXCEPTION(ACTIVITY_REQUIRED); + TAO_SYSTEM_EXCEPTION(THREAD_CANCELLED); + +#undef TAO_SYSTEM_EXCEPTION + +} // End CORBA namespace + +TAO_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" + +#endif /* TAO_SYSTEMEXCEPTIONA_H */ + + diff --git a/TAO/tao/AnyTypeCode/TAO_AnyTypeCode.pc.in b/TAO/tao/AnyTypeCode/TAO_AnyTypeCode.pc.in new file mode 100644 index 00000000000..3e73594ee47 --- /dev/null +++ b/TAO/tao/AnyTypeCode/TAO_AnyTypeCode.pc.in @@ -0,0 +1,11 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: TAO_AnyTypeCode +Description: TAO AnyTypeCode Library +Requires: TAO +Version: @VERSION@ +Libs: -L${libdir} -lTAO_AnyTypeCode +Cflags: -I${includedir} diff --git a/TAO/tao/AnyTypeCode/TAO_AnyTypeCode_Export.h b/TAO/tao/AnyTypeCode/TAO_AnyTypeCode_Export.h new file mode 100644 index 00000000000..4767016fbcc --- /dev/null +++ b/TAO/tao/AnyTypeCode/TAO_AnyTypeCode_Export.h @@ -0,0 +1,40 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl +// ------------------------------ +#ifndef TAO_ANYTYPECODE_EXPORT_H +#define TAO_ANYTYPECODE_EXPORT_H + +#include "ace/config-all.h" + +#if defined (TAO_AS_STATIC_LIBS) +# if !defined (TAO_ANYTYPECODE_HAS_DLL) +# define TAO_ANYTYPECODE_HAS_DLL 0 +# endif /* ! TAO_ANYTYPECODE_HAS_DLL */ +#else +# if !defined (TAO_ANYTYPECODE_HAS_DLL) +# define TAO_ANYTYPECODE_HAS_DLL 1 +# endif /* ! TAO_ANYTYPECODE_HAS_DLL */ +#endif + +#if defined (TAO_ANYTYPECODE_HAS_DLL) && (TAO_ANYTYPECODE_HAS_DLL == 1) +# if defined (TAO_ANYTYPECODE_BUILD_DLL) +# define TAO_AnyTypeCode_Export ACE_Proper_Export_Flag +# define TAO_ANYTYPECODE_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define TAO_ANYTYPECODE_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* TAO_ANYTYPECODE_BUILD_DLL */ +# define TAO_AnyTypeCode_Export ACE_Proper_Import_Flag +# define TAO_ANYTYPECODE_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define TAO_ANYTYPECODE_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* TAO_ANYTYPECODE_BUILD_DLL */ +#else /* TAO_ANYTYPECODE_HAS_DLL == 1 */ +# define TAO_AnyTypeCode_Export +# define TAO_ANYTYPECODE_SINGLETON_DECLARATION(T) +# define TAO_ANYTYPECODE_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* TAO_ANYTYPECODE_HAS_DLL == 1 */ + +#endif /* TAO_ANYTYPECODE_EXPORT_H */ + +// End of auto generated file. diff --git a/TAO/tao/AnyTypeCode/TC_Constants_Forward.h b/TAO/tao/AnyTypeCode/TC_Constants_Forward.h new file mode 100644 index 00000000000..e0d8853654d --- /dev/null +++ b/TAO/tao/AnyTypeCode/TC_Constants_Forward.h @@ -0,0 +1,20 @@ +// -*- C++ -*- + +// ------------------------------------------------------------- +/** + * @file TC_Constants_Forward.h + * + * $Id$ + * + * Backward compatibility header. + * + * @deprecated Use TypeCode_Constants.h instead. + */ +// ------------------------------------------------------------- + +#ifndef TAO_TC_CONSTANTS_FORWARD_H +#define TAO_TC_CONSTANTS_FORWARD_H + +#include "tao/AnyTypeCode/TypeCode_Constants.h" + +#endif /* TAO_TC_CONSTANTS_FORWARD_H */ diff --git a/TAO/tao/AnyTypeCode/True_RefCount_Policy.cpp b/TAO/tao/AnyTypeCode/True_RefCount_Policy.cpp new file mode 100644 index 00000000000..7c88dcd4577 --- /dev/null +++ b/TAO/tao/AnyTypeCode/True_RefCount_Policy.cpp @@ -0,0 +1,20 @@ +// $Id$ + +#include "tao/AnyTypeCode/True_RefCount_Policy.h" + +#ifndef __ACE_INLINE__ +# include "True_RefCount_Policy.inl" +#endif /* !__ACE_INLINE__ */ + + +ACE_RCSID (AnyTypeCode, + True_RefCount_Policy, + "$Id$") + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +TAO::True_RefCount_Policy::~True_RefCount_Policy (void) +{ +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/True_RefCount_Policy.h b/TAO/tao/AnyTypeCode/True_RefCount_Policy.h new file mode 100644 index 00000000000..6bef507fae0 --- /dev/null +++ b/TAO/tao/AnyTypeCode/True_RefCount_Policy.h @@ -0,0 +1,119 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file True_RefCount_Policy.h + * + * $Id$ + * + * Header file for TAO's true reference count policy (unrelated to + * CORBA policies). + * + * @author Ossama Othman <ossama@dre.vanderbilt.edu> + */ +//============================================================================= + +#ifndef TAO_TRUE_REFCOUNT_POLICY_H +#define TAO_TRUE_REFCOUNT_POLICY_H + +#include /**/ "ace/pre.h" + +#include "tao/AnyTypeCode/TAO_AnyTypeCode_Export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/orbconf.h" + +#include "ace/Thread_Mutex.h" +#include "ace/Atomic_Op.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + /** + * @class True_RefCount_Policy + * + * @brief True reference counting policy. + * + * This class is intended to be used as a "policy" argument to a + * host class template that requires true/functional reference + * counting. That class would then inherit privately from it like + * so: + * + * @code + * template <class RefCountPolicy> + * class MyHostClass : private RefCountPolicy + * { + * public: + * void my_add_ref (void) { this->RefCountPolicy::add_ref (); } + * void my_remove_ref (void) { this->RefCountPolicy::remove_ref (); } + * }; + * @endcode + * + * and use it like so: + * + * @code + * typedef MyHostClass<TAO::True_RefCount_Policy> MyRefCountedClass; + * MyRefCountedClass * p = new MyRefCountedClass; + * ... + * p->my_remove_ref (); + * @endcode + * + * @note Ideally, the host class should declare a protected + * destructor to enforce proper memory management through the + * reference counting mechanism, i.e. to prevent clients from + * calling @c operator @c delete() directly on the host class + * object. + */ + class TAO_AnyTypeCode_Export True_RefCount_Policy + { + public: + + /// Increase the reference count on this object. + void add_ref (void); + + /// Decrease the reference count on this object. + /** + * Decrease the reference count on this object. Once the + * reference count drops to zero, call @c operator @c delete() + * on this object. + */ + void remove_ref (void); + + protected: + + /// Constructor. + /** + * @note This constructor is protected since it not meant to be + * instantiated/used as a standalone object. + */ + True_RefCount_Policy (void); + + /// Destructor. + /** + * @note The destructor must be virtual to ensure that subclass + * destructors are called when the reference count drops to + * zero, i.e. when @c remove_ref() calls @c operator + * @c delete @c this. + */ + virtual ~True_RefCount_Policy (void); + + private: + /// Reference counter. + ACE_Atomic_Op<TAO_SYNCH_MUTEX, unsigned long> refcount_; + }; + +} // End namespace TAO + +TAO_END_VERSIONED_NAMESPACE_DECL + +#ifdef __ACE_INLINE__ +# include "tao/AnyTypeCode/True_RefCount_Policy.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" + +#endif /* TAO_TRUE_REFCOUNT_POLICY_H */ diff --git a/TAO/tao/AnyTypeCode/True_RefCount_Policy.inl b/TAO/tao/AnyTypeCode/True_RefCount_Policy.inl new file mode 100644 index 00000000000..db9631237de --- /dev/null +++ b/TAO/tao/AnyTypeCode/True_RefCount_Policy.inl @@ -0,0 +1,28 @@ +// -*- C++ -*- +// +// $Id$ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE +TAO::True_RefCount_Policy::True_RefCount_Policy (void) + : refcount_ (1) +{ +} + +ACE_INLINE void +TAO::True_RefCount_Policy::add_ref (void) +{ + ++this->refcount_; +} + +ACE_INLINE void +TAO::True_RefCount_Policy::remove_ref (void) +{ + const unsigned long new_count = --this->refcount_; + + if (new_count == 0) + delete this; +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/TypeCode.cpp b/TAO/tao/AnyTypeCode/TypeCode.cpp new file mode 100644 index 00000000000..596b4484cac --- /dev/null +++ b/TAO/tao/AnyTypeCode/TypeCode.cpp @@ -0,0 +1,489 @@ +// $Id$ + +#include "tao/AnyTypeCode/TypeCode.h" + +ACE_RCSID (AnyTypeCode, + TypeCode, + "$Id$") + + +#if !defined (__ACE_INLINE__) +# include "tao/AnyTypeCode/TypeCode.inl" +#endif /* ! __ACE_INLINE__ */ + +#include "tao/SystemException.h" +#include "tao/CDR.h" +#include "tao/ORB_Constants.h" +#include "tao/debug.h" + +#include "ace/OS_NS_string.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +CORBA::TypeCode::~TypeCode (void) +{ +} + +bool +CORBA::TypeCode::tao_marshal_kind (TAO_OutputCDR & cdr) const +{ + return cdr << this->kind_; +} + +CORBA::Boolean +CORBA::TypeCode::equal (TypeCode_ptr tc + ACE_ENV_ARG_DECL) const +{ + if (this == tc) + { + return true; + } + else if (CORBA::is_nil (tc)) + { + ACE_THROW_RETURN (CORBA::BAD_PARAM (CORBA::OMGVMCID | 13, + CORBA::COMPLETED_NO), + false); + } + + CORBA::TCKind const tc_kind = tc->kind (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + if (tc_kind != this->kind_) + return 0; + + ACE_TRY + { + char const * const tc_id = tc->id (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + char const * const this_id = this->id (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (ACE_OS::strcmp (this_id, tc_id) != 0) + return 0; + + char const * const tc_name = tc->name (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + char const * const this_name = this->name (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (ACE_OS::strcmp (this_name, tc_name) != 0) + return 0; + } + ACE_CATCH (CORBA::TypeCode::BadKind, ex) + { + // Some TypeCodes do not support the id() and name() + // operations. Ignore the failure, and continue equality + // verification using TypeCode subclass-specific techniques + // below. + } + ACE_ENDTRY; + ACE_CHECK_RETURN (0); + + return this->equal_i (tc + ACE_ENV_ARG_PARAMETER); +} + +CORBA::Boolean +CORBA::TypeCode::equivalent (TypeCode_ptr tc + ACE_ENV_ARG_DECL) const +{ + if (this == tc) + { + return true; + } + else if (CORBA::is_nil (tc)) + { + ACE_THROW_RETURN (CORBA::BAD_PARAM (CORBA::OMGVMCID | 13, + CORBA::COMPLETED_NO), + false); + } + + CORBA::TypeCode_ptr const mutable_this = + const_cast<CORBA::TypeCode_ptr> (this); + + CORBA::TypeCode_var unaliased_this = + TAO::unaliased_typecode (mutable_this + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + CORBA::TypeCode_var unaliased_tc = + TAO::unaliased_typecode (tc + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + + CORBA::TCKind const this_kind = + unaliased_this->kind (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + CORBA::TCKind const tc_kind = + unaliased_tc->kind (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + if (tc_kind != this_kind) + return false; + + ACE_TRY + { + char const * const this_id = + unaliased_this->id (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + char const * const tc_id = + unaliased_tc->id (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (ACE_OS::strlen (this_id) == 0 + || ACE_OS::strlen (tc_id) == 0) + { + return unaliased_this->equivalent_i (unaliased_tc.in () + ACE_ENV_ARG_PARAMETER); + } + else if (ACE_OS::strcmp (this_id, tc_id) != 0) + { + return false; + } + } + ACE_CATCH (CORBA::TypeCode::BadKind, ex) + { + // Some TypeCodes do not support the id() operation. Ignore the + // failure, and continue equivalence verification using TypeCode + // subclass-specific techniques. + return unaliased_this->equivalent_i (unaliased_tc.in () + ACE_ENV_ARG_PARAMETER); + } + ACE_ENDTRY; + ACE_CHECK_RETURN (false); + + return true; +} + +char const * +CORBA::TypeCode::id_i (ACE_ENV_SINGLE_ARG_DECL) const +{ + ACE_THROW_RETURN (CORBA::TypeCode::BadKind (), 0); +} + +char const * +CORBA::TypeCode::name_i (ACE_ENV_SINGLE_ARG_DECL) const +{ + ACE_THROW_RETURN (CORBA::TypeCode::BadKind (), 0); +} + +CORBA::ULong +CORBA::TypeCode::member_count_i (ACE_ENV_SINGLE_ARG_DECL) const +{ + ACE_THROW_RETURN (CORBA::TypeCode::BadKind (), 0); +} + +char const * +CORBA::TypeCode::member_name_i (CORBA::ULong /* index */ + ACE_ENV_ARG_DECL) const +{ + ACE_THROW_RETURN (CORBA::TypeCode::BadKind (), 0); +} + +CORBA::TypeCode_ptr +CORBA::TypeCode::member_type_i (CORBA::ULong /* index */ + ACE_ENV_ARG_DECL) const +{ + ACE_THROW_RETURN (CORBA::TypeCode::BadKind (), + CORBA::TypeCode::_nil ()); +} + +CORBA::Any * +CORBA::TypeCode::member_label_i (CORBA::ULong /* index */ + ACE_ENV_ARG_DECL) const +{ + ACE_THROW_RETURN (CORBA::TypeCode::BadKind (), 0); +} + +CORBA::TypeCode_ptr +CORBA::TypeCode::discriminator_type_i (ACE_ENV_SINGLE_ARG_DECL) const +{ + ACE_THROW_RETURN (CORBA::TypeCode::BadKind (), + CORBA::TypeCode::_nil ()); +} + +CORBA::Long +CORBA::TypeCode::default_index_i (ACE_ENV_SINGLE_ARG_DECL) const +{ + ACE_THROW_RETURN (CORBA::TypeCode::BadKind (), 0); +} + +CORBA::ULong +CORBA::TypeCode::length_i (ACE_ENV_SINGLE_ARG_DECL) const +{ + ACE_THROW_RETURN (CORBA::TypeCode::BadKind (), 0); +} + +CORBA::TypeCode_ptr +CORBA::TypeCode::content_type_i (ACE_ENV_SINGLE_ARG_DECL) const +{ + ACE_THROW_RETURN (CORBA::TypeCode::BadKind (), + CORBA::TypeCode::_nil ()); +} + +CORBA::UShort +CORBA::TypeCode::fixed_digits_i (ACE_ENV_SINGLE_ARG_DECL) const +{ + ACE_THROW_RETURN (CORBA::TypeCode::BadKind (), 0); +} + +CORBA::UShort +CORBA::TypeCode::fixed_scale_i (ACE_ENV_SINGLE_ARG_DECL) const +{ + ACE_THROW_RETURN (CORBA::TypeCode::BadKind (), 0); +} + +CORBA::Visibility +CORBA::TypeCode::member_visibility_i (CORBA::ULong /* index */ + ACE_ENV_ARG_DECL) const +{ + ACE_THROW_RETURN (CORBA::TypeCode::BadKind (), + CORBA::PRIVATE_MEMBER); +} + +CORBA::ValueModifier +CORBA::TypeCode::type_modifier_i (ACE_ENV_SINGLE_ARG_DECL) const +{ + ACE_THROW_RETURN (CORBA::TypeCode::BadKind (), + CORBA::VM_NONE); +} + +CORBA::TypeCode_ptr +CORBA::TypeCode::concrete_base_type_i (ACE_ENV_SINGLE_ARG_DECL) const +{ + ACE_THROW_RETURN (CORBA::TypeCode::BadKind (), + CORBA::TypeCode::_nil ()); +} + +// --------------------------------------------------------------- + +CORBA::TypeCode::Bounds::Bounds (void) + : CORBA::UserException ("IDL:omg.org/CORBA/TypeCode/Bounds:1.0", + "Bounds") +{ +} + +CORBA::TypeCode::Bounds* +CORBA::TypeCode::Bounds::_downcast (CORBA::Exception *ex) +{ + return dynamic_cast <CORBA::TypeCode::Bounds*> (ex); +} + +CORBA::Exception * +CORBA::TypeCode::Bounds::_alloc (void) +{ + CORBA::Exception *retval = 0; + ACE_NEW_RETURN (retval, ::CORBA::TypeCode::Bounds, 0); + return retval; +} + +CORBA::Exception * +CORBA::TypeCode::Bounds::_tao_duplicate (void) const +{ + CORBA::Exception *result; + ACE_NEW_RETURN (result, + CORBA::TypeCode::Bounds (*this), + 0); + return result; +} + +void +CORBA::TypeCode::Bounds::_raise (void) const +{ + TAO_RAISE(*this); +} + +void +CORBA::TypeCode::Bounds::_tao_encode (TAO_OutputCDR &cdr + ACE_ENV_ARG_DECL) const +{ + if (cdr << this->_rep_id ()) + { + return; + } + + ACE_THROW (CORBA::MARSHAL ()); +} + +void +CORBA::TypeCode::Bounds::_tao_decode (TAO_InputCDR & + ACE_ENV_ARG_DECL_NOT_USED) +{ +} + +// **************************************************************** + +CORBA::TypeCode::BadKind::BadKind (void) + : CORBA::UserException ("IDL:omg.org/CORBA/TypeCode/BadKind:1.0", + "BadKind") +{ +} + +CORBA::TypeCode::BadKind* +CORBA::TypeCode::BadKind::_downcast (CORBA::Exception *ex) +{ + return dynamic_cast <CORBA::TypeCode::BadKind*> (ex); +} + +CORBA::Exception * +CORBA::TypeCode::BadKind::_tao_duplicate (void) const +{ + CORBA::Exception *result = 0; + ACE_NEW_RETURN (result, + CORBA::TypeCode::BadKind (*this), + 0); + return result; +} + +void +CORBA::TypeCode::BadKind::_raise (void) const +{ + TAO_RAISE(*this); +} + +void +CORBA::TypeCode::BadKind::_tao_encode (TAO_OutputCDR &cdr + ACE_ENV_ARG_DECL) const +{ + if (cdr << this->_rep_id ()) + { + return; + } + + ACE_THROW (CORBA::MARSHAL ()); +} + +void +CORBA::TypeCode::BadKind::_tao_decode (TAO_InputCDR & + ACE_ENV_ARG_DECL_NOT_USED) +{ +} + +// --------------------------------------------------------------- + +bool +TAO::TypeCode::marshal (TAO_OutputCDR & cdr, + CORBA::TypeCode_ptr tc, + CORBA::ULong offset) +{ + // Marshal the TypeCode TCKind and TypeCode body. + // + // Update the offset value in case a recursive TypeCode is being + // marshaled. + + return + tc != 0 + && tc->tao_marshal_kind (cdr) + && tc->tao_marshal (cdr, aligned_offset (offset) + sizeof (CORBA::ULong)); +} + +CORBA::ULong +TAO::TypeCode::aligned_offset (CORBA::ULong offset) +{ + ptrdiff_t const unaligned_offset = + static_cast<ptrdiff_t> (offset); + + return + static_cast<CORBA::ULong> (ACE_align_binary (unaligned_offset, + ACE_CDR::LONG_ALIGN)); +} + +// --------------------------------------------------------------- + +CORBA::Boolean +operator<< (TAO_OutputCDR & cdr, + const CORBA::TypeCode_ptr tc) +{ + return TAO::TypeCode::marshal (cdr, tc, 0); +} + +// --------------------------------------------------------------- + +CORBA::TypeCode_ptr +TAO::unaliased_typecode (CORBA::TypeCode_ptr tc + ACE_ENV_ARG_DECL) +{ + if (CORBA::is_nil (tc)) + { + ACE_THROW_RETURN (CORBA::BAD_PARAM (CORBA::OMGVMCID | 13, + CORBA::COMPLETED_NO), + tc); + } + + CORBA::TCKind tc_kind = tc->kind (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (tc); + + if (tc_kind == CORBA::tk_alias) + { + CORBA::TypeCode_var tc_content = + CORBA::TypeCode::_duplicate (tc); + + // Iterate until we get to the actual unaliased type. + do + { + tc_content = + tc_content->content_type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (tc); + + tc_kind = tc_content->kind (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (tc); + } + while (tc_kind == CORBA::tk_alias); + + return tc_content._retn (); + } + + return CORBA::TypeCode::_duplicate (tc); +} + +// ========================================================= + +// Traits specializations for CORBA::TypeCode. +namespace TAO +{ + CORBA::TypeCode_ptr + Objref_Traits<CORBA::TypeCode>::duplicate (CORBA::TypeCode_ptr p) + { + return CORBA::TypeCode::_duplicate (p); + } + + void + Objref_Traits<CORBA::TypeCode>::release (CORBA::TypeCode_ptr p) + { + ::CORBA::release (p); + } + + CORBA::TypeCode_ptr + Objref_Traits<CORBA::TypeCode>::nil (void) + { + return CORBA::TypeCode::_nil (); + } + + CORBA::Boolean + Objref_Traits<CORBA::TypeCode>::marshal (CORBA::TypeCode_ptr p, + TAO_OutputCDR & cdr) + { + return cdr << p; + } +} + +// ========================================================= + +CORBA::TCKind +TAO::unaliased_kind (CORBA::TypeCode_ptr tc + ACE_ENV_ARG_DECL) +{ + CORBA::TypeCode_var unaliased_tc = + TAO::unaliased_typecode (tc + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (CORBA::TAO_TC_KIND_COUNT); + + return unaliased_tc->kind (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/TypeCode.h b/TAO/tao/AnyTypeCode/TypeCode.h new file mode 100644 index 00000000000..5502f17609d --- /dev/null +++ b/TAO/tao/AnyTypeCode/TypeCode.h @@ -0,0 +1,594 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file TypeCode.h + * + * $Id$ + * + * Header file the @c CORBA::TypeCode class. + * + * @author Ossama Othman <ossama@dre.vanderbilt.edu> + * @author DOC group at Vanderbilt University, Washington University + * and the University of California at Irvine. + */ +//============================================================================= + +#ifndef TAO_TYPECODE_H +#define TAO_TYPECODE_H + +#include /**/ "ace/pre.h" + +#include "tao/AnyTypeCode/TAO_AnyTypeCode_Export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/AnyTypeCode/AnyTypeCode_methods.h" +#include "tao/AnyTypeCode/ValueModifierC.h" +#include "tao/AnyTypeCode/VisibilityC.h" +#include "tao/UserException.h" +#include "tao/Basic_Types.h" +#include "tao/Typecode_typesC.h" +#include "tao/Any_Insert_Policy_T.h" +#include "tao/CORBA_methods.h" +#include "tao/Pseudo_VarOut_T.h" +#include "tao/Object_Argument_T.h" +#include "tao/Arg_Traits_T.h" +#include "tao/Objref_VarOut_T.h" + +#if defined (TAO_EXPORT_MACRO) +#undef TAO_EXPORT_MACRO +#endif +#define TAO_EXPORT_MACRO TAO_AnyTypeCode_Export + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace CORBA +{ + typedef TAO_Pseudo_Var_T<TypeCode> TypeCode_var; + typedef TAO_Pseudo_Out_T<TypeCode> TypeCode_out; + + /** + * @class TypeCode + * + * @brief A representation of the structure of a given OMG + * IDL-declared type. + * + * @c TypeCodes are primarily used by @c CORBA::Anys, the CORBA + * Interface Repository and the CORBA Dynamic Invocation Interface. + */ + class TAO_AnyTypeCode_Export TypeCode + { + public: + + /** + * @class Bounds + * + * @brief Out-of-bounds member index exception. + * + * Exception thrown when attempting to pass an out-of-bounds index + * value to a @c TypeCode operation that accepts a member index + * argument. + */ + class TAO_AnyTypeCode_Export Bounds : public UserException + { + public: + + /// Constructor. + Bounds (void); + + static Bounds * _downcast (CORBA::Exception * ex); + static CORBA::Exception * _alloc (void); + + virtual CORBA::Exception * _tao_duplicate (void) const; + + virtual void _raise (void) const; + + virtual void _tao_encode (TAO_OutputCDR & cdr + ACE_ENV_ARG_DECL) const; + virtual void _tao_decode (TAO_InputCDR & cdr + ACE_ENV_ARG_DECL); + + }; + + /** + * @class BadKind + * + * @brief Invalid @c TypeCode operation exception. + * + * Exception thrown when attempting to invoke a @c TypeCode + * operation that is not valid for the type represented by the + * @c TypeCode. + */ + class TAO_AnyTypeCode_Export BadKind : public CORBA::UserException + { + public: + + BadKind (void); + + static BadKind * _downcast (CORBA::Exception * ex); + static CORBA::Exception * _alloc (void); + + virtual CORBA::Exception * _tao_duplicate (void) const; + + virtual void _raise (void) const; + + virtual void _tao_encode (TAO_OutputCDR & cdr + ACE_ENV_ARG_DECL) const; + virtual void _tao_decode (TAO_InputCDR & cdr + ACE_ENV_ARG_DECL); + + }; + + static CORBA::TypeCode_ptr const _tc_Bounds; + static CORBA::TypeCode_ptr const _tc_BadKind; + + /// Duplicate this @c TypeCode. + /** + * Statically instantiated @c TypeCodes incur no reference count + * manipulation, i.e. reference counting is a no-op. + * + * Dynamically instantiated @c TypeCodes will have their reference + * count incremented by one each time this function is called. + */ + static CORBA::TypeCode_ptr _duplicate (CORBA::TypeCode_ptr tc); + + /// Returns a NULL typecode. + static CORBA::TypeCode_ptr _nil (void); + + /** + * @name @c CORBA::TypeCode Methods + * + * These methods are part of the public interface of @c + * CORBA::TypeCode class, as defined by the OMG CORBA + * specification and C++ mapping. + * + * The C++ mapping does not declare the methods in the public + * @c CORBA::TypeCode API as @c virtual, so work around that by + * making these methods inlined to forward all calls to the + * corresponding protected template method (i.e. the design + * pattern, not the C++ feature) listed below in the @c protected + * block. + */ + //@{ + /// Equality of two @c TypeCodes. + /** + * @return @c true if and only if the set of legal operations is + * the same and invoking any operation on the this + * @c TypeCode and @a tc returns identical results. + */ + Boolean equal (TypeCode_ptr tc + ACE_ENV_ARG_DECL) const; + + /// Equivalence of two @c TypeCodes. + /** + * Equivalence of two @c TypeCodes satisfies a subset of the + * requirements necessary for equality. + * + * @see equal + */ + Boolean equivalent (TypeCode_ptr tc + ACE_ENV_ARG_DECL) const; + + /// The kind of @c TypeCode. + TCKind kind (ACE_ENV_SINGLE_ARG_DECL) const; + + /// Return @c TypeCode stripped of optional @c name and + /// @c member_name fields. + /** + * @note Calling this method will incur additional run-time memory + * consumption since TAO's implementation relies on the + * TypeCodeFactory to dynamically create a compact @c + * TypeCode; the exception being @c TypeCodes with empty + * parameter lists. Those @c TypeCodes are already compact, + * meaning that call this method on such @c TypeCodes incurs + * no additional run-time memory requirements. + * + * Unless you need to send compact @c TypeCodes + * "over-the-wire" or your @c TypeCode corresponds to a + * type with a large number of members, try to stick with + * the existing potentially non-compact @c TypeCode. + * + * @note Compact @c TypeCodes may also be generated statically by + * the TAO_IDL compiler by invoking it with its "-Gt" + * (i.e. enable optimized TypeCodes) command line option. + */ + TypeCode_ptr get_compact_typecode (ACE_ENV_SINGLE_ARG_DECL) const; + + /// The @c RepositoryId globally identifying the type. + /** + * This method is valid for the following kinds of @c TypeCodes: + * + * @li @c tk_objref + * @li @c tk_struct + * @li @c tk_union + * @li @c tk_enum + * @li @c tk_alias + * @li @c tk_value + * @li @c tk_value_box + * @li @c tk_native + * @li @c tk_abstract_interface + * @li @c tk_local_interface + * @li @c tk_except + * @li @c tk_component + * @li @c tk_home + * @li @c tk_event + * + * @note CORBA::TypeCode::id() does not follow the usual parameter + * passing rules defined by the C++ mapping. This behavior + * is required by the C++ mapping. In particular, ownership + * is maintained by the @c TypeCode. + */ + char const * id (ACE_ENV_SINGLE_ARG_DECL) const; + + /// The simple name identifying the type within its enclosing + /// scope. + /** + * This method is valid for the following kinds of @c TypeCodes: + * + * @li @c tk_objref + * @li @c tk_struct + * @li @c tk_union + * @li @c tk_enum + * @li @c tk_alias + * @li @c tk_value + * @li @c tk_value_box + * @li @c tk_native + * @li @c tk_abstract_interface + * @li @c tk_local_interface + * @li @c tk_except + * @li @c tk_component + * @li @c tk_home + * @li @c tk_event + * + * @note CORBA::TypeCode::name() does not follow the usual + * parameter passing rules defined by the C++ mapping. This + * behavior is required by the C++ mapping. In particular, + * ownership is maintained by the @c TypeCode. + */ + char const * name (ACE_ENV_SINGLE_ARG_DECL) const; + + /// The type member count. + /** + * This method is valid for the following kinds of @c TypeCodes: + * + * @li @c tk_struct + * @li @c tk_union + * @li @c tk_enum + * @li @c tk_value + * @li @c tk_except + * @li @c tk_event + */ + ULong member_count (ACE_ENV_SINGLE_ARG_DECL) const; + + /// The type member name. + /** + * This method is valid for the following kinds of @c TypeCodes: + * + * @li @c tk_struct + * @li @c tk_union + * @li @c tk_enum + * @li @c tk_value + * @li @c tk_except + * @li @c tk_event + * + * @note CORBA::TypeCode::member_name() does not follow the usual + * parameter passing rules defined by the C++ mapping. This + * behavior is required by the C++ mapping. In particular, + * ownership is maintained by the @c TypeCode. + */ + char const * member_name (ULong index + ACE_ENV_ARG_DECL) const; + + /// The type member @c TypeCode. + /** + * This method is valid for the following kinds of @c TypeCodes: + * + * @li @c tk_struct + * @li @c tk_union + * @li @c tk_value + * @li @c tk_except + * @li @c tk_event + */ + TypeCode_ptr member_type (ULong index + ACE_ENV_ARG_DECL) const; + + /// The union member label. + /** + * This method is valid for the following kinds of @c TypeCodes: + * + * @li @c tk_union + */ + Any * member_label (ULong index + ACE_ENV_ARG_DECL) const; + + /// The type of all non-default union member labels. + /** + * This method is valid for the following kinds of @c TypeCodes: + * + * @li @c tk_union + */ + TypeCode_ptr discriminator_type (ACE_ENV_SINGLE_ARG_DECL) const; + + /// The index of the default union member. + /** + * This method is valid for the following kinds of @c TypeCodes: + * + * @li @c tk_union + */ + Long default_index (ACE_ENV_SINGLE_ARG_DECL) const; + + /// The length of the type. + /** + * This method is valid for the following kinds of @c TypeCodes: + * + * @li @c tk_string + * @li @c tk_wstring + * @li @c tk_sequence + * @li @c tk_array + */ + ULong length (ACE_ENV_SINGLE_ARG_DECL) const; + + /// The underlying content type. + /** + * This method is valid for the following kinds of @c TypeCodes: + * + * @li @c tk_sequence + * @li @c tk_array + * @li @c tk_value_box + * @li @c tk_alias + */ + TypeCode_ptr content_type (ACE_ENV_SINGLE_ARG_DECL) const; + + /// The number of significant digits. + /** + * This method is valid for the following kinds of @c TypeCodes: + * + * @li @c tk_fixed + */ + UShort fixed_digits (ACE_ENV_SINGLE_ARG_DECL) const; + + /// The scale factor. + /** + * This method is valid for the following kinds of @c TypeCodes: + * + * @li @c tk_fixed + */ + UShort fixed_scale (ACE_ENV_SINGLE_ARG_DECL) const; + + /// The @c Visibility of the @c valuetype or @c eventtype member + /// corresponding to index @a index. + /** + * This method is valid for the following kinds of @c TypeCodes: + * + * @li @c tk_value + * @li @c tk_event + */ + Visibility member_visibility (ULong index + ACE_ENV_ARG_DECL) const; + + /// The @c ValueModifier of the @c valuetype of @c eventtype + /// represented by this @c TypeCode. + /** + * This method is valid for the following kinds of @c TypeCodes: + * + * @li @c tk_value + * @li @c tk_event + */ + ValueModifier type_modifier (ACE_ENV_SINGLE_ARG_DECL) const; + + /// The @c TypeCode corresponding to the concrete base + /// @c valuetype or @c eventtype. + /** + * This method is valid for the following kinds of @c TypeCodes: + * + * @li @c tk_value + * @li @c tk_event + * + * @return @c TypeCode corresponding to the concrete base + * @c valuetype or @c eventtype. + * @c CORBA::TypeCode::_nil() if no concrete base exists. + */ + TypeCode_ptr concrete_base_type (ACE_ENV_SINGLE_ARG_DECL) const; + //@} + + /// Marshal the @c TypeCode @c TCKind. + /** + * + */ + virtual bool tao_marshal_kind (TAO_OutputCDR & cdr) const; + + /// Marshal this @c TypeCode into a CDR output stream. + /** + * Marshal this @c TypeCode into the @a cdr output CDR stream, + * excluding the @c TypeCode kind. Existing @a cdr contents will + * not be altered. The marshaled @c TypeCode will be appended to + * the given @a cdr CDR output stream. + * + * @param cdr Output CDR stream into which the @c TypeCode will be + * marshaled. + * + * @param offset Number of bytes currently in the output CDR + * stream, including the top-level TypeCode @c + * TCKind. This argument is useful for recursive + * @c TypeCodes. @c TypeCodes that contain other + * @c TypeCodes should pass an updated @a offset + * value to the marshaling operation for those + * contained @c TypeCodes. + * + * @return @c true if marshaling was successful. + * + * @note This is a TAO-specific method that is not part of the + * standard @c CORBA::TypeCode interface. + * + * @note If this method returns @false, the contents of the @a cdr + * output CDR stream are undefined. + */ + virtual bool tao_marshal (TAO_OutputCDR & cdr, + CORBA::ULong offset) const = 0; + + /// Increase the reference count on this @c TypeCode. + virtual void tao_duplicate (void) = 0; + + /// Decrease the reference count on this object. + virtual void tao_release (void) = 0; + + /// Destruction callback for Anys. + static void _tao_any_destructor (void * x); + + typedef CORBA::TypeCode_ptr _ptr_type; + typedef CORBA::TypeCode_var _var_type; + typedef CORBA::TypeCode_out _out_type; + + protected: + + /// Constructor. + TypeCode (CORBA::TCKind kind); + + /// Destructor. + /** + * Protected destructor to enforce proper memory management + * through the reference counting mechanism. + */ + virtual ~TypeCode (void); + + /** + * @name @c TypeCode Template Methods + * + * Methods that must be implemented by @c CORBA::TypeCode + * subclasses if valid for those subclasses. + * + * The default implementations of the non-pure virtual methods + * throw the @c CORBA::TypeCode::BadKind exception since many of + * these methods are @c TypeCode type-specific. This reduces code + * duplication and bloat. + * + * The @c TypeCode @c equal(), @c equivalent(), @c kind() and + * @c get_compact_typecode() methods are valid for all + * @c TypeCodes which is why their template method "@c _i" + * counterparts are pure virtual. + */ + //@{ + virtual Boolean equal_i (TypeCode_ptr tc + ACE_ENV_ARG_DECL) const = 0; + virtual Boolean equivalent_i (TypeCode_ptr tc + ACE_ENV_ARG_DECL) const = 0; + virtual TypeCode_ptr get_compact_typecode_i ( + ACE_ENV_SINGLE_ARG_DECL) const = 0; + + virtual char const * id_i (ACE_ENV_SINGLE_ARG_DECL) const; + virtual char const * name_i (ACE_ENV_SINGLE_ARG_DECL) const; + virtual ULong member_count_i (ACE_ENV_SINGLE_ARG_DECL) const; + virtual char const * member_name_i (ULong index + ACE_ENV_ARG_DECL) const; + virtual TypeCode_ptr member_type_i (ULong index + ACE_ENV_ARG_DECL) const; + virtual Any * member_label_i (ULong index + ACE_ENV_ARG_DECL) const; + virtual TypeCode_ptr discriminator_type_i ( + ACE_ENV_SINGLE_ARG_DECL) const; + virtual Long default_index_i (ACE_ENV_SINGLE_ARG_DECL) const; + virtual ULong length_i (ACE_ENV_SINGLE_ARG_DECL) const; + virtual TypeCode_ptr content_type_i (ACE_ENV_SINGLE_ARG_DECL) const; + virtual UShort fixed_digits_i (ACE_ENV_SINGLE_ARG_DECL) const; + virtual UShort fixed_scale_i (ACE_ENV_SINGLE_ARG_DECL) const; + virtual Visibility member_visibility_i (ULong index + ACE_ENV_ARG_DECL) const; + virtual ValueModifier type_modifier_i (ACE_ENV_SINGLE_ARG_DECL) const; + virtual TypeCode_ptr concrete_base_type_i ( + ACE_ENV_SINGLE_ARG_DECL) const; + //@} + + private: + + // Prevent copying and assignment. + TypeCode (TypeCode const &); + void operator= (TypeCode const &); + + protected: + + /// The kind of TypeCode. + TCKind const kind_; + + }; +} // End namespace CORBA + + +TAO_AnyTypeCode_Export +CORBA::Boolean operator<< (TAO_OutputCDR & cdr, + const CORBA::TypeCode_ptr tc); + +TAO_AnyTypeCode_Export +CORBA::Boolean operator>> (TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc); + +namespace TAO +{ + namespace TypeCode + { + /// Marshal the @c TypeCode @a tc in to the output CDR stream @a + /// cdr. + /** + * @see @CORBA::TypeCode::tao_marshal() description for details. + */ + + TAO_AnyTypeCode_Export bool marshal (TAO_OutputCDR & cdr, + CORBA::TypeCode_ptr tc, + CORBA::ULong offset); + + /// Return @a offset aligned on the appropriate CDR boundary. + TAO_AnyTypeCode_Export CORBA::ULong aligned_offset (CORBA::ULong offset); + } + + /// Return the unaliased content @c TypeCode of the given + /// @c TypeCode. + TAO_AnyTypeCode_Export CORBA::TypeCode_ptr unaliased_typecode ( + CORBA::TypeCode_ptr tc + ACE_ENV_ARG_DECL); + + /// Return the unaliased @c TCKind of the given @c TypeCode. + /** + * @note This is a convenience function that simply calls @c kind() + * on the unaliased @c TypeCode returned from + * @c unaliased_typecode(). + */ + TAO_AnyTypeCode_Export + CORBA::TCKind unaliased_kind (CORBA::TypeCode_ptr tc + ACE_ENV_ARG_DECL); + + // --------------------------------------------------------------- + + // Used in generated code if CORBA::TypeCode is an argument or + // return type. + template<> + class TAO_AnyTypeCode_Export Arg_Traits<CORBA::TypeCode> + : public Object_Arg_Traits_T<CORBA::TypeCode_ptr, + CORBA::TypeCode_var, + CORBA::TypeCode_out, + TAO::Objref_Traits<CORBA::TypeCode>, + TAO::Any_Insert_Policy_Stream <CORBA::TypeCode_ptr> > + { + }; + + template<> + struct TAO_AnyTypeCode_Export Objref_Traits< ::CORBA::TypeCode> + { + static ::CORBA::TypeCode_ptr duplicate (::CORBA::TypeCode_ptr); + static void release (::CORBA::TypeCode_ptr); + static ::CORBA::TypeCode_ptr nil (void); + static CORBA::Boolean marshal (::CORBA::TypeCode_ptr p, + TAO_OutputCDR & cdr); + }; +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +# include "tao/AnyTypeCode/TypeCode.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" + +#endif /* TAO_TYPECODE_H */ diff --git a/TAO/tao/AnyTypeCode/TypeCode.inl b/TAO/tao/AnyTypeCode/TypeCode.inl new file mode 100644 index 00000000000..f06f9f5ba2d --- /dev/null +++ b/TAO/tao/AnyTypeCode/TypeCode.inl @@ -0,0 +1,162 @@ +// -*- C++ -*- +// +// $Id$ + +#include "tao/Environment.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE CORBA::Boolean +CORBA::is_nil (CORBA::TypeCode_ptr obj) +{ + return obj == 0; +} + +ACE_INLINE void +CORBA::release (CORBA::TypeCode_ptr obj) +{ + if (obj) + obj->tao_release (); +} + +// -------------------------------------------------------------- + +ACE_INLINE +CORBA::TypeCode::TypeCode (CORBA::TCKind k) + : kind_ (k) +{ +} + +ACE_INLINE CORBA::TypeCode_ptr +CORBA::TypeCode::_duplicate (CORBA::TypeCode_ptr tc) +{ + if (!CORBA::is_nil (tc)) + tc->tao_duplicate (); + + return tc; +} + +ACE_INLINE CORBA::TypeCode_ptr +CORBA::TypeCode::_nil (void) +{ + return static_cast<CORBA::TypeCode_ptr> (0); +} + +ACE_INLINE CORBA::TCKind +CORBA::TypeCode::kind (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const +{ + return this->kind_; +} + +ACE_INLINE CORBA::TypeCode_ptr +CORBA::TypeCode::get_compact_typecode (ACE_ENV_SINGLE_ARG_DECL) const +{ + return this->get_compact_typecode_i (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +ACE_INLINE char const * +CORBA::TypeCode::id (ACE_ENV_SINGLE_ARG_DECL) const +{ + return this->id_i (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +ACE_INLINE char const * +CORBA::TypeCode::name (ACE_ENV_SINGLE_ARG_DECL) const +{ + return this->name_i (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +ACE_INLINE CORBA::ULong +CORBA::TypeCode::member_count (ACE_ENV_SINGLE_ARG_DECL) const +{ + return this->member_count_i (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +ACE_INLINE char const * +CORBA::TypeCode::member_name (ULong index + ACE_ENV_ARG_DECL) const +{ + return this->member_name_i (index + ACE_ENV_ARG_PARAMETER); +} + +ACE_INLINE CORBA::TypeCode_ptr +CORBA::TypeCode::member_type (ULong index + ACE_ENV_ARG_DECL) const +{ + return this->member_type_i (index + ACE_ENV_ARG_PARAMETER); +} + +ACE_INLINE CORBA::Any * +CORBA::TypeCode::member_label (ULong index + ACE_ENV_ARG_DECL) const +{ + return this->member_label_i (index + ACE_ENV_ARG_PARAMETER); +} + +ACE_INLINE CORBA::TypeCode_ptr +CORBA::TypeCode::discriminator_type (ACE_ENV_SINGLE_ARG_DECL) const +{ + return this->discriminator_type_i (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +ACE_INLINE CORBA::Long +CORBA::TypeCode::default_index (ACE_ENV_SINGLE_ARG_DECL) const +{ + return this->default_index_i (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +ACE_INLINE CORBA::ULong +CORBA::TypeCode::length (ACE_ENV_SINGLE_ARG_DECL) const +{ + return this->length_i (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +ACE_INLINE CORBA::TypeCode_ptr +CORBA::TypeCode::content_type (ACE_ENV_SINGLE_ARG_DECL) const +{ + return this->content_type_i (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +ACE_INLINE CORBA::UShort +CORBA::TypeCode::fixed_digits (ACE_ENV_SINGLE_ARG_DECL) const +{ + return this->fixed_digits_i (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +ACE_INLINE CORBA::UShort +CORBA::TypeCode::fixed_scale (ACE_ENV_SINGLE_ARG_DECL) const +{ + return this->fixed_scale_i (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +ACE_INLINE CORBA::Visibility +CORBA::TypeCode::member_visibility (ULong index + ACE_ENV_ARG_DECL) const +{ + return this->member_visibility_i (index + ACE_ENV_ARG_PARAMETER); +} + +ACE_INLINE CORBA::ValueModifier +CORBA::TypeCode::type_modifier (ACE_ENV_SINGLE_ARG_DECL) const +{ + return this->type_modifier_i (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +ACE_INLINE CORBA::TypeCode_ptr +CORBA::TypeCode::concrete_base_type (ACE_ENV_SINGLE_ARG_DECL) const +{ + return this->concrete_base_type_i (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +ACE_INLINE void +CORBA::TypeCode::_tao_any_destructor (void * x) +{ + ::CORBA::release (static_cast <CORBA::TypeCode_ptr> (x)); +} + + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/TypeCodeA.cpp b/TAO/tao/AnyTypeCode/TypeCodeA.cpp new file mode 100644 index 00000000000..ca3156f5d15 --- /dev/null +++ b/TAO/tao/AnyTypeCode/TypeCodeA.cpp @@ -0,0 +1,63 @@ +// $Id$ + +#include "tao/AnyTypeCode/Struct_TypeCode_Static.h" +#include "tao/AnyTypeCode/Null_RefCount_Policy.h" + + +ACE_RCSID (AnyTypeCode, + TypeCode, + "$Id$") + + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + namespace TypeCode + { + // Notice that these are all statically instantiated and not + // exported. + + char const tc_bounds_id[] = "IDL:omg.org/CORBA/TypeCode/Bounds:1.0"; + char const tc_bounds_name[] = "Bounds"; + Struct<char const *, + CORBA::TypeCode_ptr const *, + Struct_Field<char const *, + CORBA::TypeCode_ptr const *> const *, + TAO::Null_RefCount_Policy> tc_Bounds (CORBA::tk_except, + tc_bounds_id, + tc_bounds_name, + 0, + 0); + + char const tc_bad_kind_id[] = "IDL:omg.org/CORBA/TypeCode/BadKind:1.0"; + char const tc_bad_kind_name[] = "BadKind"; + Struct<char const *, + CORBA::TypeCode_ptr const *, + Struct_Field<char const *, + CORBA::TypeCode_ptr const *> const *, + TAO::Null_RefCount_Policy> tc_BadKind (CORBA::tk_except, + tc_bad_kind_id, + tc_bad_kind_name, + 0, + 0); + } +} + + +// ------------------------------------------------------------------ +// OMG defined TypeCode constants +// ------------------------------------------------------------------ + +// Notice that these are constant TypeCode references/pointers, not +// constant TypeCodes. TypeCodes are effectively read-only since +// all non-static TypeCode operations are const. + + +CORBA::TypeCode_ptr const CORBA::TypeCode::_tc_BadKind = + &TAO::TypeCode::tc_BadKind; +CORBA::TypeCode_ptr const CORBA::TypeCode::_tc_Bounds = + &TAO::TypeCode::tc_Bounds; + + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/TypeCode_Base_Attributes.cpp b/TAO/tao/AnyTypeCode/TypeCode_Base_Attributes.cpp new file mode 100644 index 00000000000..da416b4314f --- /dev/null +++ b/TAO/tao/AnyTypeCode/TypeCode_Base_Attributes.cpp @@ -0,0 +1,12 @@ +// $Id$ + +#ifndef TAO_TYPECODE_BASE_ATTRIBUTES_CPP +#define TAO_TYPECODE_BASE_ATTRIBUTES_CPP + +#include "tao/AnyTypeCode/TypeCode_Base_Attributes.h" + +#ifndef __ACE_INLINE__ +# include "tao/AnyTypeCode/TypeCode_Base_Attributes.inl" +#endif /* !__ACE_INLINE__ */ + +#endif /* TAO_TYPECODE_BASE_ATTRIBUTES_CPP */ diff --git a/TAO/tao/AnyTypeCode/TypeCode_Base_Attributes.h b/TAO/tao/AnyTypeCode/TypeCode_Base_Attributes.h new file mode 100644 index 00000000000..03740852534 --- /dev/null +++ b/TAO/tao/AnyTypeCode/TypeCode_Base_Attributes.h @@ -0,0 +1,101 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file TypeCode_Base_Attributes.h + * + * $Id$ + * + * @author Ossama Othman <ossama@dre.vanderbilt.edu> + */ +//============================================================================= + +#ifndef TAO_TYPECODE_BASE_ATTRIBUTES_H +#define TAO_TYPECODE_BASE_ATTRIBUTES_H + +#include /**/ "ace/pre.h" + +#include "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/Versioned_Namespace.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + namespace TypeCode + { + + /** + * @class Base_Attributes + * + * @brief Attributes contained by most @c TypeCodes with complex + * parameter lists. + * + * Most @c TypeCodes with complex parameter lists (see Section + * 15.3.5.1 "TypeCode" in the CORBA specification) contain these + * attributes, namely a repository ID and a name. + */ + template <typename STRING_TYPE> + class Base_Attributes + { + public: + + /// Constructor. + Base_Attributes (char const * id, + char const * name); + + /// Constructor used by recursive @c TypeCodes. + Base_Attributes (char const * id); + + /// Get the @c RepositoryId globally identifying the type. + char const * id (void) const; + + /// Get the simple name identifying the type within its + /// enclosing scope. + char const * name (void) const; + + /// Set the simple name identifying the type within its + /// enclosing scope. + /** + * @note This method only used when creating a recursive + * TypeCode. + */ + void name (char const * the_name); + + private: + + /// The @c RepositoryId globally identifying the type. + STRING_TYPE const id_; + + /// The simple name identifying the type within its enclosing + /// scope. + STRING_TYPE name_; + + }; + + } // End namespace TypeCode +} // End namespace TAO + +TAO_END_VERSIONED_NAMESPACE_DECL + +#ifdef __ACE_INLINE__ +# include "tao/AnyTypeCode/TypeCode_Base_Attributes.inl" +#endif /* __ACE_INLINE__ */ + +#ifdef ACE_TEMPLATES_REQUIRE_SOURCE +# include "tao/AnyTypeCode/TypeCode_Base_Attributes.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#ifdef ACE_TEMPLATES_REQUIRE_PRAGMA +# pragma implementation ("TypeCode_Base_Attributes.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + + +#include /**/ "ace/post.h" + +#endif /* TAO_TYPECODE_BASE_ATTRIBUTES_H */ diff --git a/TAO/tao/AnyTypeCode/TypeCode_Base_Attributes.inl b/TAO/tao/AnyTypeCode/TypeCode_Base_Attributes.inl new file mode 100644 index 00000000000..915e4ed9411 --- /dev/null +++ b/TAO/tao/AnyTypeCode/TypeCode_Base_Attributes.inl @@ -0,0 +1,54 @@ +// -*- C++ -*- +// +// $Id$ + +#include "tao/AnyTypeCode/TypeCode_Traits.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +template <typename STRING_TYPE> +ACE_INLINE +TAO::TypeCode::Base_Attributes<STRING_TYPE>::Base_Attributes ( + char const * id, + char const * name) + : id_ (id), + name_ (name) +{ +} + +template <typename STRING_TYPE> +ACE_INLINE +TAO::TypeCode::Base_Attributes<STRING_TYPE>::Base_Attributes ( + char const * id) + : id_ (id), + name_ () +{ + // Only used in the dynamic (when STRING_TYPE == CORBA::String_var) + // recursive TypeCode case. +} + +template <typename STRING_TYPE> +ACE_INLINE char const * +TAO::TypeCode::Base_Attributes<STRING_TYPE>::id (void) const +{ + return Traits<STRING_TYPE>::get_string (this->id_); +} + +template <typename STRING_TYPE> +ACE_INLINE char const * +TAO::TypeCode::Base_Attributes<STRING_TYPE>::name (void) const +{ + return Traits<STRING_TYPE>::get_string (this->name_); +} + +template <typename STRING_TYPE> +ACE_INLINE void +TAO::TypeCode::Base_Attributes<STRING_TYPE>::name (char const * the_name) +{ + // This method will only be instantiated in the dynamic TypeCode + // case, i.e. when STRING_TYPE is CORBA::String_var. + + this->name_ = the_name; +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/TypeCode_CDR_Extraction.cpp b/TAO/tao/AnyTypeCode/TypeCode_CDR_Extraction.cpp new file mode 100644 index 00000000000..6670f1a10c6 --- /dev/null +++ b/TAO/tao/AnyTypeCode/TypeCode_CDR_Extraction.cpp @@ -0,0 +1,1403 @@ +// $Id$ + +#include "tao/AnyTypeCode/TypeCode_CDR_Extraction.h" + +#include "tao/AnyTypeCode/TypeCode_Constants.h" +#include "tao/AnyTypeCode/True_RefCount_Policy.h" + +#include "tao/AnyTypeCode/Alias_TypeCode.h" +#include "tao/AnyTypeCode/Enum_TypeCode.h" +#include "tao/AnyTypeCode/Fixed_TypeCode.h" +#include "tao/AnyTypeCode/Objref_TypeCode.h" +#include "tao/AnyTypeCode/Sequence_TypeCode.h" +#include "tao/AnyTypeCode/String_TypeCode.h" +#include "tao/AnyTypeCode/Struct_TypeCode.h" +#include "tao/AnyTypeCode/Union_TypeCode.h" +#include "tao/AnyTypeCode/Value_TypeCode.h" +#include "tao/AnyTypeCode/Any.h" + +#include "tao/AnyTypeCode/Recursive_Type_TypeCode.h" + +#include "tao/AnyTypeCode/TypeCode_Case_T.h" +#include "tao/AnyTypeCode/TypeCode_Struct_Field.h" +#include "tao/AnyTypeCode/TypeCode_Value_Field.h" + +#include "tao/CDR.h" + +#include "ace/Array_Base.h" +#include "ace/Value_Ptr.h" + + +ACE_RCSID (AnyTypeCode, + TypeCode_CDR_Extraction, + "$Id$") + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + namespace TypeCodeFactory + { + // An array of TC_Info objects is used instead of a map of + // repository IDs to TypeCodes since it is presumed that the + // number of directly or indirectly embedded types in a TypeCode + // capable of holding another TypeCode will be small enough to + // make traversing a list faster than performing a map lookup. + // Use a simple array also reduces static and run-time footprint. + + struct TC_Info + { + /// Constructor. + TC_Info (void) : id (0), type () {} + + /// Repository ID. + char const * id; + + /// TypeCode + CORBA::TypeCode_ptr type; + }; + + typedef ACE_Array_Base<TC_Info> TC_Info_List; + } +} + +namespace +{ + bool start_cdr_encap_extraction (TAO_InputCDR & cdr) + { + CORBA::Boolean byte_order; + + // Don't bother demarshaling the encapsulation length. Prefer + // speed over early error checking. Any CDR length related + // failures will be detected when demarshaling the remainder of + // the complex parameter list TypeCode. + + if (!(cdr.skip_ulong () // Skip encapsulation length. + && cdr >> TAO_InputCDR::to_boolean (byte_order))) + return false; + + cdr.reset_byte_order (byte_order); + + return true; + } + + // --------------------------------------------------------- + + CORBA::ULong const TYPECODE_INDIRECTION = 0xffffffff; + + // --------------------------------------------------------- + + // Use an ACE::Value_Ptr to provide exception safety and proper + // copying semantics. + typedef ACE::Value_Ptr<TAO::TypeCode::Case<CORBA::String_var, CORBA::TypeCode_var> > union_elem_type; + typedef ACE_Array_Base<union_elem_type> union_case_array_type; + + // ------------------------------------------------------------ + + /// Demarshal a TypeCode. + bool tc_demarshal (TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TAO::TypeCodeFactory::TC_Info_List & infos); + + /// Demarshal an indirected TypeCode. + bool tc_demarshal_indirection (TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TAO::TypeCodeFactory::TC_Info_List & infos); + + bool find_recursive_tc (char const * id, + TAO::TypeCodeFactory::TC_Info_List & tcs, + TAO::TypeCodeFactory::TC_Info_List & infos) + { + // See comments above for rationale behind using an array instead + // of a map. + + size_t const len = infos.size (); + + for (size_t i = 0; i < len; ++i) + { + TAO::TypeCodeFactory::TC_Info & info = infos[i]; + + if (ACE_OS::strcmp (info.id, id) == 0) + { + // We have a mathing id, so store the typecode in the out array + // and then compare the others. + size_t const old_size = tcs.size (); + if (tcs.size (old_size + 1) == -1) // Incremental growth -- *sigh* + return false; + + TAO::TypeCodeFactory::TC_Info & new_info = tcs[old_size]; + new_info.type = info.type; + } + } + + return (tcs.size () > 0) ; + } +} + +bool +TAO::TypeCodeFactory::tc_null_factory (CORBA::TCKind, + TAO_InputCDR &, + CORBA::TypeCode_ptr & tc, + TC_Info_List &) +{ + tc = CORBA::TypeCode::_duplicate (CORBA::_tc_null); + + return true; +} + +bool +TAO::TypeCodeFactory::tc_void_factory (CORBA::TCKind, + TAO_InputCDR &, + CORBA::TypeCode_ptr & tc, + TC_Info_List &) +{ + tc = CORBA::TypeCode::_duplicate (CORBA::_tc_void); + + return true; +} + +bool +TAO::TypeCodeFactory::tc_short_factory (CORBA::TCKind, + TAO_InputCDR &, + CORBA::TypeCode_ptr & tc, + TC_Info_List &) +{ + tc = CORBA::TypeCode::_duplicate (CORBA::_tc_short); + + return true; +} + +bool +TAO::TypeCodeFactory::tc_long_factory (CORBA::TCKind, + TAO_InputCDR &, + CORBA::TypeCode_ptr & tc, + TC_Info_List &) +{ + tc = CORBA::TypeCode::_duplicate (CORBA::_tc_long); + + return true; +} + +bool +TAO::TypeCodeFactory::tc_ushort_factory (CORBA::TCKind, + TAO_InputCDR &, + CORBA::TypeCode_ptr & tc, + TC_Info_List &) +{ + tc = CORBA::TypeCode::_duplicate (CORBA::_tc_ushort); + + return true; +} + +bool +TAO::TypeCodeFactory::tc_ulong_factory (CORBA::TCKind, + TAO_InputCDR &, + CORBA::TypeCode_ptr & tc, + TC_Info_List &) +{ + tc = CORBA::TypeCode::_duplicate (CORBA::_tc_ulong); + + return true; +} + +bool +TAO::TypeCodeFactory::tc_float_factory (CORBA::TCKind, + TAO_InputCDR &, + CORBA::TypeCode_ptr & tc, + TC_Info_List &) +{ + tc = CORBA::TypeCode::_duplicate (CORBA::_tc_float); + + return true; +} + +bool +TAO::TypeCodeFactory::tc_double_factory (CORBA::TCKind, + TAO_InputCDR &, + CORBA::TypeCode_ptr & tc, + TC_Info_List &) +{ + tc = CORBA::TypeCode::_duplicate (CORBA::_tc_double); + + return true; +} + +bool +TAO::TypeCodeFactory::tc_boolean_factory (CORBA::TCKind, + TAO_InputCDR &, + CORBA::TypeCode_ptr & tc, + TC_Info_List &) +{ + tc = CORBA::TypeCode::_duplicate (CORBA::_tc_boolean); + + return true; +} + +bool +TAO::TypeCodeFactory::tc_char_factory (CORBA::TCKind, + TAO_InputCDR &, + CORBA::TypeCode_ptr & tc, + TC_Info_List &) +{ + tc = CORBA::TypeCode::_duplicate (CORBA::_tc_char); + + return true; +} + +bool +TAO::TypeCodeFactory::tc_octet_factory (CORBA::TCKind, + TAO_InputCDR &, + CORBA::TypeCode_ptr & tc, + TC_Info_List &) +{ + tc = CORBA::TypeCode::_duplicate (CORBA::_tc_octet); + + return true; +} + +bool +TAO::TypeCodeFactory::tc_any_factory (CORBA::TCKind, + TAO_InputCDR &, + CORBA::TypeCode_ptr & tc, + TC_Info_List &) +{ + tc = CORBA::TypeCode::_duplicate (CORBA::_tc_any); + + return true; +} + +bool +TAO::TypeCodeFactory::tc_TypeCode_factory (CORBA::TCKind, + TAO_InputCDR &, + CORBA::TypeCode_ptr & tc, + TC_Info_List &) +{ + tc = CORBA::TypeCode::_duplicate (CORBA::_tc_TypeCode); + + return true; +} + +bool +TAO::TypeCodeFactory::tc_Principal_factory (CORBA::TCKind, + TAO_InputCDR &, + CORBA::TypeCode_ptr & tc, + TC_Info_List &) +{ + tc = CORBA::TypeCode::_duplicate (CORBA::_tc_Principal); + + return true; +} + +bool +TAO::TypeCodeFactory::tc_objref_factory (CORBA::TCKind kind, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List &) +{ + // The remainder of a tk_objref TypeCode is encoded in a CDR + // encapsulation. + if (!start_cdr_encap_extraction (cdr)) + return false; + + // Extract the repository ID and name. + CORBA::String_var id; + if (!(cdr >> TAO_InputCDR::to_string (id.out (), 0))) + return false; + + static char const Object_id[] = "IDL:omg.org/CORBA/Object:1.0"; + static char const CCMObject_id[] = "IDL:omg.org/CORBA/CCMObject:1.0"; + static char const CCMHome_id[] = "IDL:omg.org/CORBA/CCMHome:1.0"; + + char const * tc_constant_id = ""; + + switch (kind) + { + case CORBA::tk_component: + tc_constant_id = CCMObject_id; + break; + case CORBA::tk_home: + tc_constant_id = CCMHome_id; + break; + case CORBA::tk_objref: + tc_constant_id = Object_id; + break; + default: + break; + } + + if (ACE_OS::strcmp (id.in (), // len >= 0!!! + tc_constant_id) == 0) + { + if (!cdr.skip_string ()) // No need to demarshal the name. + return false; + + CORBA::TypeCode_ptr tc_constant = CORBA::TypeCode::_nil (); + switch (kind) + { + case CORBA::tk_component: + tc_constant = CORBA::_tc_Component; + break; + case CORBA::tk_home: + tc_constant = CORBA::_tc_Home; + break; + case CORBA::tk_objref: + tc_constant = CORBA::_tc_Object; + break; + default: + break; + } + + // No need to create a TypeCode. Just use the TypeCode + // constant. + tc = + CORBA::TypeCode::_duplicate (tc_constant); + } + else + { + CORBA::String_var name; + + if (!(cdr >> TAO_InputCDR::to_string (name.out (), 0))) + return false; + + typedef TAO::TypeCode::Objref<CORBA::String_var, + TAO::True_RefCount_Policy> typecode_type; + + ACE_NEW_RETURN (tc, + typecode_type (kind, + id.in (), + name.in ()), + false); + } + + return true; +} + +bool +TAO::TypeCodeFactory::tc_struct_factory (CORBA::TCKind kind, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List & infos) +{ + ACE_ASSERT (kind == CORBA::tk_struct || kind == CORBA::tk_except); + + // The remainder of a tk_struct/tk_except TypeCode is encoded in + // a CDR encapsulation. + if (!start_cdr_encap_extraction (cdr)) + return false; + + // Extract the repository ID, name and number of fields. + CORBA::String_var id, name; + CORBA::ULong nfields; + + if (!(cdr >> TAO_InputCDR::to_string (id.out (), 0) + && cdr >> TAO_InputCDR::to_string (name.out (), 0) + && cdr >> nfields)) + return false; + + typedef ACE_Array_Base<TAO::TypeCode::Struct_Field<CORBA::String_var, + CORBA::TypeCode_var> > + member_array_type; + + member_array_type fields (nfields); + + for (CORBA::ULong i = 0; i < nfields; ++i) + { + if (!(cdr >> TAO_InputCDR::to_string (fields[i].name.out (), 0) + && tc_demarshal (cdr, fields[i].type.out (), infos))) + return false; + } + + typedef TAO::TypeCode::Struct< + CORBA::String_var, + CORBA::TypeCode_var, + member_array_type, + TAO::True_RefCount_Policy> typecode_type; + + + // Check if struct TypeCode is recursive. + TAO::TypeCodeFactory::TC_Info_List recursive_tc; + if (kind == CORBA::tk_struct && find_recursive_tc (id.in (), recursive_tc, infos)) + { + // Set remaining parameters. + + typedef TAO::TypeCode::Recursive_Type<typecode_type, + CORBA::TypeCode_var, + member_array_type> + recursive_typecode_type; + + size_t const len = recursive_tc.size (); + + for (size_t i = 0; i < len; ++i) + { + TAO::TypeCodeFactory::TC_Info & info = recursive_tc[i]; + + recursive_typecode_type * const rtc = + dynamic_cast<recursive_typecode_type *> (info.type); + + ACE_ASSERT (rtc); + + rtc->struct_parameters (name.in (), + fields, + nfields); + } + + tc = recursive_tc[0].type; + } + else + { + ACE_NEW_RETURN (tc, + typecode_type (kind, + id.in (), + name.in (), + fields, // Will be copied. + nfields), + false); + } + + return true; +} + +bool +TAO::TypeCodeFactory::tc_union_factory (CORBA::TCKind /* kind */, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List & infos) +{ + // The remainder of a tk_enum TypeCode is encoded in a CDR + // encapsulation. + + if (!start_cdr_encap_extraction (cdr)) + return false; + + // Extract the repository ID, name, discriminant type, default index + // and case count. + CORBA::String_var id, name; + CORBA::TypeCode_var discriminant_type; + CORBA::Long default_index = -1; + CORBA::ULong ncases = 0; // Just 'n case :-) + + if (!(cdr >> TAO_InputCDR::to_string (id.out (), 0) + && cdr >> TAO_InputCDR::to_string (name.out (), 0) + && cdr >> discriminant_type.out ())) // No need to use tc_demarshal() + return false; + + ACE_DECLARE_NEW_CORBA_ENV; + CORBA::TCKind const discriminant_kind = + discriminant_type->kind (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + // Check for valid discriminant type. + if (!(discriminant_kind == CORBA::tk_enum + || discriminant_kind == CORBA::tk_ulong + || discriminant_kind == CORBA::tk_long + || discriminant_kind == CORBA::tk_ushort + || discriminant_kind == CORBA::tk_short + || discriminant_kind == CORBA::tk_char + || discriminant_kind == CORBA::tk_boolean + || discriminant_kind == CORBA::tk_longlong + || discriminant_kind == CORBA::tk_ulonglong)) + return false; + + if (!(cdr >> default_index + && default_index >= -1 + && cdr >> ncases)) + return false; + + typedef union_elem_type elem_type; + typedef union_case_array_type case_array_type; + + case_array_type cases (ncases); + + for (CORBA::ULong i = 0; i < ncases; ++i) + { + elem_type & member = cases[i]; + + TAO::TypeCode::Case<CORBA::String_var, CORBA::TypeCode_var> * the_case = 0; + + // Ugly. *sigh* + switch (discriminant_kind) + { + case CORBA::tk_enum: // Enumerators are encoded as unsigned longs. + case CORBA::tk_ulong: + { + CORBA::ULong label; + if (!(cdr >> label)) + return false; + + typedef TypeCode::Case_T<CORBA::ULong, + CORBA::String_var, + CORBA::TypeCode_var> case_type; + + ACE_NEW_RETURN (the_case, + case_type (label), + false); + } + break; + case CORBA::tk_long: + { + CORBA::Long label; + if (!(cdr >> label)) + return false; + + typedef TypeCode::Case_T<CORBA::Long, + CORBA::String_var, + CORBA::TypeCode_var> case_type; + + ACE_NEW_RETURN (the_case, + case_type (label), + false); + } + break; + case CORBA::tk_ushort: + { + CORBA::UShort label; + if (!(cdr >> label)) + return false; + + typedef TypeCode::Case_T<CORBA::UShort, + CORBA::String_var, + CORBA::TypeCode_var> case_type; + + ACE_NEW_RETURN (the_case, + case_type (label), + false); + } + break; + case CORBA::tk_short: + { + CORBA::Short label; + if (!(cdr >> label)) + return false; + + typedef TypeCode::Case_T<CORBA::Short, + CORBA::String_var, + CORBA::TypeCode_var> case_type; + + ACE_NEW_RETURN (the_case, + case_type (label), + false); + } + break; + case CORBA::tk_char: + { + CORBA::Char label; + if (!(cdr >> CORBA::Any::to_char (label))) + return false; + + typedef TypeCode::Case_T<CORBA::Char, + CORBA::String_var, + CORBA::TypeCode_var> case_type; + + ACE_NEW_RETURN (the_case, + case_type (label), + false); + } + break; + case CORBA::tk_boolean: + { + CORBA::Boolean label; + if (!(cdr >> CORBA::Any::to_boolean (label))) + return false; + + typedef TypeCode::Case_T<CORBA::Boolean, + CORBA::String_var, + CORBA::TypeCode_var> case_type; + + ACE_NEW_RETURN (the_case, + case_type (label), + false); + } + break; + case CORBA::tk_longlong: + { + CORBA::LongLong label; + if (!(cdr >> label)) + return false; + + typedef TypeCode::Case_T<CORBA::LongLong, + CORBA::String_var, + CORBA::TypeCode_var> case_type; + + ACE_NEW_RETURN (the_case, + case_type (label), + false); + } + break; +#if !defined (ACE_LACKS_LONGLONG_T) + case CORBA::tk_ulonglong: + { + CORBA::ULongLong label; + if (!(cdr >> label)) + return false; + + typedef TypeCode::Case_T<CORBA::ULongLong, + CORBA::String_var, + CORBA::TypeCode_var> case_type; + + ACE_NEW_RETURN (the_case, + case_type (label), + false); + } + break; +#endif /* !ACE_LACKS_LONGLONG_T */ + default: + return false; + } + + elem_type case_value (the_case); + member.swap (case_value); // Exception-safe + + CORBA::String_var the_name; + CORBA::TypeCode_var the_type; + + if (!(cdr >> TAO_InputCDR::to_string (the_name.out (), 0) + && tc_demarshal (cdr, the_type.out (), infos))) + return false; + + member->name (the_name.in ()); + member->type (the_type.in ()); + } + + typedef TAO::TypeCode::Union<CORBA::String_var, + CORBA::TypeCode_var, + case_array_type, + TAO::True_RefCount_Policy> typecode_type; + + // Check if we have recursive members, this could be multiple + TAO::TypeCodeFactory::TC_Info_List recursive_tc; + if (find_recursive_tc (id.in (), recursive_tc, infos)) + { + // Set remaining parameters. + + typedef TAO::TypeCode::Recursive_Type<typecode_type, + CORBA::TypeCode_var, + case_array_type> + recursive_typecode_type; + + size_t const len = recursive_tc.size (); + + for (size_t i = 0; i < len; ++i) + { + TAO::TypeCodeFactory::TC_Info & info = recursive_tc[i]; + + recursive_typecode_type * const rtc = + dynamic_cast<recursive_typecode_type *> (info.type); + + ACE_ASSERT (rtc); + + rtc->union_parameters (name.in (), + discriminant_type, + cases, // Will be copied. + ncases, + default_index); + } + + tc = recursive_tc[0].type; + } + else + { + ACE_NEW_RETURN (tc, + typecode_type (id.in (), + name.in (), + discriminant_type, + cases, // Will be copied. + ncases, + default_index), + false); + } + + return true; +} + +bool +TAO::TypeCodeFactory::tc_enum_factory (CORBA::TCKind /* kind */, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List &) +{ + // The remainder of a tk_enum TypeCode is encoded in a CDR + // encapsulation. + + if (!start_cdr_encap_extraction (cdr)) + return false; + + // Extract the repository ID, name and number of fields. + CORBA::String_var id, name; + CORBA::ULong nenumerators; + + if (!(cdr >> TAO_InputCDR::to_string (id.out (), 0) + && cdr >> TAO_InputCDR::to_string (name.out (), 0) + && cdr >> nenumerators)) + return false; + + ACE_Array_Base<CORBA::String_var> enumerators (nenumerators); + + for (CORBA::ULong i = 0; i < nenumerators; ++i) + { + if (!(cdr >> TAO_InputCDR::to_string (enumerators[i].out (), 0))) + return false; + } + + typedef TAO::TypeCode::Enum< + CORBA::String_var, + ACE_Array_Base<CORBA::String_var>, + TAO::True_RefCount_Policy> typecode_type; + + ACE_NEW_RETURN (tc, + typecode_type (id.in (), + name.in (), + enumerators, // Will be copied. + nenumerators), + false); + + return true; +} + +bool +TAO::TypeCodeFactory::tc_string_factory (CORBA::TCKind kind, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List &) +{ + // A tk_string/tk_wstring TypeCode has a simple parameter list, + // i.e. it is not encoded in a CDR encapsulation. + + CORBA::ULong bound; + if (!(cdr >> bound)) + return false; + + if (bound == 0) + { + // Just use the TypeCode constant. + if (kind == CORBA::tk_string) + tc = CORBA::TypeCode::_duplicate (CORBA::_tc_string); + else if (kind == CORBA::tk_wstring) + tc = CORBA::TypeCode::_duplicate (CORBA::_tc_wstring); + else + return false; + + return true; + } + + typedef TAO::TypeCode::String<TAO::True_RefCount_Policy> typecode_type; + + ACE_NEW_RETURN (tc, + typecode_type (kind, bound), + false); + + return true; +} + +bool +TAO::TypeCodeFactory::tc_sequence_factory (CORBA::TCKind kind, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List & infos) +{ + ACE_ASSERT (kind == CORBA::tk_sequence || kind == CORBA::tk_array); + + // The remainder of a tk_sequence TypeCode is encoded in a CDR + // encapsulation. + + if (!start_cdr_encap_extraction (cdr)) + return false; + + // Extract the repository ID, name and content type. + CORBA::TypeCode_var content_type; + CORBA::ULong length; + + if (!(tc_demarshal (cdr, content_type.out (), infos) + && cdr >> length)) + return false; + + typedef TAO::TypeCode::Sequence< + CORBA::TypeCode_var, + TAO::True_RefCount_Policy> typecode_type; + + ACE_NEW_RETURN (tc, + typecode_type (kind, content_type, length), + false); + + return true; +} + +bool +TAO::TypeCodeFactory::tc_array_factory (CORBA::TCKind kind, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List & infos) +{ + return tc_sequence_factory (kind, cdr, tc, infos); +} + +bool +TAO::TypeCodeFactory::tc_alias_factory (CORBA::TCKind kind, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List & infos) +{ + // The remainder of a tk_alias or tk_value_box TypeCode is encoded + // in a CDR encapsulation. + + if (!start_cdr_encap_extraction (cdr)) + return false; + + // Extract the repository ID, name and content type. + CORBA::String_var id, name; + CORBA::TypeCode_var content_type; + if (!(cdr >> TAO_InputCDR::to_string (id.out (), 0) + && cdr >> TAO_InputCDR::to_string (name.out (), 0) + && tc_demarshal (cdr, content_type.out (), infos))) + return false; + + typedef TAO::TypeCode::Alias< + CORBA::String_var, + CORBA::TypeCode_var, + TAO::True_RefCount_Policy> typecode_type; + + ACE_NEW_RETURN (tc, + typecode_type (kind, + id.in (), + name.in (), + content_type), + false); + + return true; +} + +bool +TAO::TypeCodeFactory::tc_except_factory (CORBA::TCKind kind, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List & infos) +{ + return tc_struct_factory (kind, cdr, tc, infos); +} + +bool +TAO::TypeCodeFactory::tc_longlong_factory (CORBA::TCKind, + TAO_InputCDR &, + CORBA::TypeCode_ptr & tc, + TC_Info_List &) +{ + tc = CORBA::TypeCode::_duplicate (CORBA::_tc_longlong); + + return true; +} + +bool +TAO::TypeCodeFactory::tc_ulonglong_factory (CORBA::TCKind, + TAO_InputCDR &, + CORBA::TypeCode_ptr & tc, + TC_Info_List &) +{ + tc = CORBA::TypeCode::_duplicate (CORBA::_tc_ulonglong); + + return true; +} + +bool +TAO::TypeCodeFactory::tc_longdouble_factory (CORBA::TCKind, + TAO_InputCDR &, + CORBA::TypeCode_ptr & tc, + TC_Info_List &) +{ + tc = CORBA::TypeCode::_duplicate (CORBA::_tc_longdouble); + + return true; +} + +bool +TAO::TypeCodeFactory::tc_wchar_factory (CORBA::TCKind, + TAO_InputCDR &, + CORBA::TypeCode_ptr & tc, + TC_Info_List &) +{ + tc = CORBA::TypeCode::_duplicate (CORBA::_tc_wchar); + + return true; +} + +bool +TAO::TypeCodeFactory::tc_wstring_factory (CORBA::TCKind kind, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List & infos) +{ + return tc_string_factory (kind, cdr, tc, infos); +} + +bool +TAO::TypeCodeFactory::tc_fixed_factory (CORBA::TCKind, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List &) +{ + // A tk_fixed TypeCode has a simple parameter list, i.e. it is not + // encoded in a CDR encapsulation. + + CORBA::UShort digits, scale; + if (!(cdr >> digits && cdr >> scale)) + return false; + + typedef TAO::TypeCode::Fixed<TAO::True_RefCount_Policy> typecode_type; + + ACE_NEW_RETURN (tc, + typecode_type (digits, scale), + false); + + return true; +} + +bool +TAO::TypeCodeFactory::tc_value_factory (CORBA::TCKind kind, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List & infos) +{ + // The remainder of a tk_value/tk_event TypeCode is encoded in a + // CDR encapsulation + + if (!start_cdr_encap_extraction (cdr)) + return false; + + // Extract the repository ID, name and number of fields. + CORBA::String_var id; + if (!(cdr >> TAO_InputCDR::to_string (id.out (), 0))) + return false; + +// if (ACE_OS::strcmp (id.in (), "IDL:omg.org/CORBA/ValueBase:1.0") == 0) +// { +// // No need to create a TypeCode. Just use the TypeCode +// // constant. +// tc = CORBA::TypeCode::_duplicate (CORBA::_tc_ValueBase); + +// return true; +// } +// else if (ACE_OS::strcmp (id.in (), +// "IDL:omg.org/CORBA/EventBase:1.0") == 0) +// { +// // No need to create a TypeCode. Just use the TypeCode +// // constant. +// tc = CORBA::TypeCode::_duplicate (CORBA::_tc_EventBase); + +// return true; +// } + + CORBA::String_var name; + CORBA::ValueModifier type_modifier; + CORBA::TypeCode_var concrete_base; + CORBA::ULong nfields; + + if (!(cdr >> TAO_InputCDR::to_string (name.out (), 0) + && cdr >> type_modifier + && cdr >> concrete_base.out () + && cdr >> nfields)) + return false; + + typedef ACE_Array_Base<TAO::TypeCode::Value_Field<CORBA::String_var, + CORBA::TypeCode_var> > + member_array_type; + + member_array_type fields (nfields); + + for (CORBA::ULong i = 0; i < nfields; ++i) + { + TAO::TypeCode::Value_Field<CORBA::String_var, + CORBA::TypeCode_var> & field = fields[i]; + + if (!(cdr >> TAO_InputCDR::to_string (field.name.out (), 0) + && tc_demarshal (cdr, field.type.out (), infos) + && cdr >> field.visibility)) + return false; + } + + typedef TAO::TypeCode::Value< + CORBA::String_var, + CORBA::TypeCode_var, + member_array_type, + TAO::True_RefCount_Policy> typecode_type; + + // Check if valuetype/eventtype TypeCode is recursive. + TAO::TypeCodeFactory::TC_Info_List recursive_tc; + if (find_recursive_tc (id.in (), recursive_tc, infos)) + { + // Set remaining parameters. + + typedef TAO::TypeCode::Recursive_Type<typecode_type, + CORBA::TypeCode_var, + member_array_type> + recursive_typecode_type; + + size_t const len = recursive_tc.size (); + + for (size_t i = 0; i < len; ++i) + { + TAO::TypeCodeFactory::TC_Info & info = recursive_tc[i]; + + recursive_typecode_type * const rtc = + dynamic_cast<recursive_typecode_type *> (info.type); + + ACE_ASSERT (rtc); + + rtc->valuetype_parameters (name.in (), + type_modifier, + concrete_base, + fields, // Will be copied. + nfields); + } + tc = recursive_tc[0].type; + } + else + { + ACE_NEW_RETURN (tc, + typecode_type (kind, + id.in (), + name.in (), + type_modifier, + concrete_base, + fields, // Will be copied. + nfields), + false); + } + + return true; +} + +bool +TAO::TypeCodeFactory::tc_value_box_factory (CORBA::TCKind kind, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List & infos) +{ + return tc_alias_factory (kind, cdr, tc, infos); +} + +bool +TAO::TypeCodeFactory::tc_native_factory (CORBA::TCKind, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List & infos) +{ + return tc_objref_factory (CORBA::tk_native, cdr, tc, infos); +} + +bool +TAO::TypeCodeFactory::tc_abstract_interface_factory (CORBA::TCKind, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List & infos) +{ + return tc_objref_factory (CORBA::tk_abstract_interface, cdr, tc, infos); +} + +bool +TAO::TypeCodeFactory::tc_local_interface_factory (CORBA::TCKind, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List & infos) +{ + return tc_objref_factory (CORBA::tk_local_interface, cdr, tc, infos); +} + +bool +TAO::TypeCodeFactory::tc_component_factory (CORBA::TCKind, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List & infos) +{ + return tc_objref_factory (CORBA::tk_component, cdr, tc, infos); +} + +bool +TAO::TypeCodeFactory::tc_home_factory (CORBA::TCKind, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List & infos) +{ + return tc_objref_factory (CORBA::tk_home, cdr, tc, infos); +} + +bool +TAO::TypeCodeFactory::tc_event_factory (CORBA::TCKind kind, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List & infos) +{ + return tc_value_factory (kind, cdr, tc, infos); +} + +// --------------------------------------------------------------- + +namespace +{ + bool + tc_demarshal (TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TAO::TypeCodeFactory::TC_Info_List & infos) + { + // ULong since we need to detect indirected TypeCodes, too. + + CORBA::ULong kind; + if (!(cdr >> kind) + || (kind >= static_cast<CORBA::ULong> (CORBA::TAO_TC_KIND_COUNT) + && kind != TYPECODE_INDIRECTION)) + return false; + + if (kind == TYPECODE_INDIRECTION) + return tc_demarshal_indirection (cdr, tc, infos); + + using namespace TAO::TypeCodeFactory; + + static factory const factory_map[] = + { + tc_null_factory, + tc_void_factory, + tc_short_factory, + tc_long_factory, + tc_ushort_factory, + tc_ulong_factory, + tc_float_factory, + tc_double_factory, + tc_boolean_factory, + tc_char_factory, + tc_octet_factory, + tc_any_factory, + tc_TypeCode_factory, + tc_Principal_factory, + tc_objref_factory, + tc_struct_factory, + tc_union_factory, + tc_enum_factory, + tc_string_factory, + tc_sequence_factory, + tc_array_factory, + tc_alias_factory, + tc_except_factory, + tc_longlong_factory, + tc_ulonglong_factory, + tc_longdouble_factory, + tc_wchar_factory, + tc_wstring_factory, + tc_fixed_factory, + tc_value_factory, + tc_value_box_factory, + tc_native_factory, + tc_abstract_interface_factory, + tc_local_interface_factory, + tc_component_factory, + tc_home_factory, + tc_event_factory + }; + + return factory_map[kind] (static_cast<CORBA::TCKind> (kind), + cdr, + tc, + infos); + } + + bool + tc_demarshal_indirection (TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TAO::TypeCodeFactory::TC_Info_List & infos) + { + CORBA::Long offset; + + if (!(cdr >> offset) || offset >= -4) + { + // Offsets must be negative since they point back to a + // TypeCode found earlier in the CDR stream. They must be + // less than -4 since an offset of -4 points back to the + // indirection TypeCode itself, meaning that it would be + // self-indirecting. + return false; + } + +// ACE_Message_Block * const mb = +// const_cast<ACE_Message_Block *> (cdr.start ()); + +// TAO_InputCDR indir_stream (mb->rd_ptr () + offset - 4, + TAO_InputCDR indir_stream (cdr.rd_ptr () + offset - sizeof (CORBA::Long), + (-offset) + sizeof (CORBA::Long), + cdr.byte_order ()); + + if (!indir_stream.good_bit ()) + { + return false; + } + + CORBA::TCKind kind; + if (!(indir_stream >> kind) + + // Indirected TypeCode must point to top-level TypeCode. + || static_cast<CORBA::ULong> (kind) == TYPECODE_INDIRECTION + + // Only struct, union and valuetype TypeCodes may be recursive. + || !(kind == CORBA::tk_struct + || kind == CORBA::tk_union + || kind == CORBA::tk_value + || kind == CORBA::tk_event) + + // Currently all recursive TypeCodes have complex parameter + // lists, meaning they are encoded as CDR encapsulations. + || !start_cdr_encap_extraction (indir_stream)) + { + return false; + } + + /** + * @todo Recursive TypeCode demarshaling is currently suboptimal + * due to redundant demarshaling of TypeCode parameters, + * such as repository ID, and excessive + * allocations/copying. + */ + + CORBA::String_var id; + if (!(indir_stream >> TAO_InputCDR::to_string (id.out (), 0))) + return false; + + // Don't bother demarshaling the rest of the parameters. They will + // be handled by the top-level TypeCode demarshaling call. + bool new_tc = false; + + switch (kind) + { + case CORBA::tk_struct: + { + // Check if we already have a tc for this type, if yes, use that + TAO::TypeCodeFactory::TC_Info_List recursive_tc; + if (find_recursive_tc (id.in (), recursive_tc, infos)) + { + tc = recursive_tc[0].type; + } + else + { + new_tc = true; + + typedef ACE_Array_Base< + TAO::TypeCode::Struct_Field< + CORBA::String_var, + CORBA::TypeCode_var> > member_array_type; + + typedef TAO::TypeCode::Struct< + CORBA::String_var, + CORBA::TypeCode_var, + member_array_type, + TAO::True_RefCount_Policy> typecode_type; + + typedef TAO::TypeCode::Recursive_Type<typecode_type, + CORBA::TypeCode_var, + member_array_type> + recursive_typecode_type; + + ACE_NEW_RETURN (tc, + recursive_typecode_type (kind, + id.in ()), + false); + } + } + break; + case CORBA::tk_union: + { + // Check if we already have a tc for this type, if yes, use that + TAO::TypeCodeFactory::TC_Info_List recursive_tc; + if (find_recursive_tc (id.in (), recursive_tc, infos)) + { + tc = recursive_tc[0].type; + } + else + { + new_tc = true; + + typedef union_case_array_type member_array_type; + + typedef TAO::TypeCode::Union< + CORBA::String_var, + CORBA::TypeCode_var, + member_array_type, + TAO::True_RefCount_Policy> typecode_type; + + typedef TAO::TypeCode::Recursive_Type<typecode_type, + CORBA::TypeCode_var, + member_array_type> + recursive_typecode_type; + + ACE_NEW_RETURN (tc, + recursive_typecode_type (kind, + id.in ()), + false); + } + } + break; + case CORBA::tk_value: + case CORBA::tk_event: + { + // Check if we already have a tc for this type, if yes, use that + TAO::TypeCodeFactory::TC_Info_List recursive_tc; + if (find_recursive_tc (id.in (), recursive_tc, infos)) + { + tc = recursive_tc[0].type; + } + else + { + new_tc = true; + + typedef ACE_Array_Base< + TAO::TypeCode::Value_Field< + CORBA::String_var, + CORBA::TypeCode_var> > member_array_type; + + typedef TAO::TypeCode::Value< + CORBA::String_var, + CORBA::TypeCode_var, + member_array_type, + TAO::True_RefCount_Policy> typecode_type; + + typedef TAO::TypeCode::Recursive_Type<typecode_type, + CORBA::TypeCode_var, + member_array_type> + recursive_typecode_type; + + ACE_NEW_RETURN (tc, + recursive_typecode_type (kind, + id.in ()), + false); + } + } + break; + default: + return false; // We should never get here. + }; + + // Only when we created a new tc add it to the list. + if (new_tc) + { + size_t const old_size = infos.size (); + if (infos.size (old_size + 1) == -1) // Incremental growth -- *sigh* + return false; + + TAO::TypeCodeFactory::TC_Info & info = infos[old_size]; + + ACE_DECLARE_NEW_CORBA_ENV; + info.id = tc->id (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (false); // Should never throw! + + info.type = tc; + } + + return true; + } +} + +// ---------------------------------------------------------------- + +CORBA::Boolean +operator>> (TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc) +{ + TAO::TypeCodeFactory::TC_Info_List infos; + + return tc_demarshal (cdr, tc, infos); +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/TypeCode_CDR_Extraction.h b/TAO/tao/AnyTypeCode/TypeCode_CDR_Extraction.h new file mode 100644 index 00000000000..0e6d6015c97 --- /dev/null +++ b/TAO/tao/AnyTypeCode/TypeCode_CDR_Extraction.h @@ -0,0 +1,200 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file TypeCode_CDR_Extraction.h + * + * $Id$ + * + * Header file for TAO TypeCode CDR extraction operations. + * + * @author Ossama Othman <ossama@dre.vanderbilt.edu> + */ +//============================================================================= + +#ifndef TAO_TYPECODE_CDR_EXTRACTION_H +#define TAO_TYPECODE_CDR_EXTRACTION_H + +#include /**/ "ace/pre.h" + +#include "tao/Typecode_typesC.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL +template <class T> class ACE_Array_Base; +ACE_END_VERSIONED_NAMESPACE_DECL + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + namespace TypeCodeFactory + { + struct TC_Info; + typedef ACE_Array_Base<TC_Info> TC_Info_List; + + typedef bool (*factory) (CORBA::TCKind, + TAO_InputCDR &, + CORBA::TypeCode_ptr &, + TC_Info_List &); + + bool tc_null_factory (CORBA::TCKind kind, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List & infos); + bool tc_void_factory (CORBA::TCKind kind, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List & infos); + bool tc_short_factory (CORBA::TCKind kind, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List & infos); + bool tc_long_factory (CORBA::TCKind kind, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List & infos); + bool tc_ushort_factory (CORBA::TCKind kind, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List & infos); + bool tc_ulong_factory (CORBA::TCKind kind, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List & infos); + bool tc_float_factory (CORBA::TCKind kind, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List & infos); + bool tc_double_factory (CORBA::TCKind kind, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List & infos); + bool tc_boolean_factory (CORBA::TCKind kind, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List & infos); + bool tc_char_factory (CORBA::TCKind kind, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List & infos); + bool tc_octet_factory (CORBA::TCKind kind, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List & infos); + bool tc_any_factory (CORBA::TCKind kind, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List & infos); + bool tc_TypeCode_factory (CORBA::TCKind kind, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List & infos); + bool tc_Principal_factory (CORBA::TCKind kind, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List & infos); + bool tc_objref_factory (CORBA::TCKind kind, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List & infos); + bool tc_struct_factory (CORBA::TCKind kind, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List & infos); + bool tc_union_factory (CORBA::TCKind kind, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List & infos); + bool tc_enum_factory (CORBA::TCKind kind, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List & infos); + bool tc_string_factory (CORBA::TCKind kind, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List & infos); + bool tc_sequence_factory (CORBA::TCKind kind, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List & infos); + bool tc_array_factory (CORBA::TCKind kind, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List & infos); + bool tc_alias_factory (CORBA::TCKind kind, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List & infos); + bool tc_except_factory (CORBA::TCKind kind, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List & infos); + bool tc_longlong_factory (CORBA::TCKind kind, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List & infos); + bool tc_ulonglong_factory (CORBA::TCKind kind, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List & infos); + bool tc_longdouble_factory (CORBA::TCKind kind, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List & infos); + bool tc_wchar_factory (CORBA::TCKind kind, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List & infos); + bool tc_wstring_factory (CORBA::TCKind kind, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List & infos); + bool tc_fixed_factory (CORBA::TCKind kind, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List & infos); + bool tc_value_factory (CORBA::TCKind kind, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List & infos); + bool tc_value_box_factory (CORBA::TCKind kind, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List & infos); + bool tc_native_factory (CORBA::TCKind kind, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List & infos); + bool tc_abstract_interface_factory (CORBA::TCKind kind, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List & infos); + bool tc_local_interface_factory (CORBA::TCKind kind, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List & infos); + bool tc_component_factory (CORBA::TCKind kind, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List & infos); + bool tc_home_factory (CORBA::TCKind kind, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List & infos); + bool tc_event_factory (CORBA::TCKind kind, + TAO_InputCDR & cdr, + CORBA::TypeCode_ptr & tc, + TC_Info_List & infos); + + } // End namespace TypeCodeFactory +} // End namespace TAO + +TAO_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" + +#endif /* TAO_TYPECODE_CDR_EXTRACTION_H */ diff --git a/TAO/tao/AnyTypeCode/TypeCode_Case_Base_T.cpp b/TAO/tao/AnyTypeCode/TypeCode_Case_Base_T.cpp new file mode 100644 index 00000000000..67edee2d6b8 --- /dev/null +++ b/TAO/tao/AnyTypeCode/TypeCode_Case_Base_T.cpp @@ -0,0 +1,89 @@ +// $Id$ + +#ifndef TAO_TYPECODE_CASE_CPP +#define TAO_TYPECODE_CASE_CPP + +#include "tao/AnyTypeCode/TypeCode_Case_Base_T.h" +#include "ace/OS_NS_string.h" + +#ifndef __ACE_INLINE__ +# include "tao/AnyTypeCode/TypeCode_Case_Base_T.inl" +#endif /* __ACE_INLINE__ */ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +template <typename StringType, typename TypeCodeType> +TAO::TypeCode::Case<StringType, TypeCodeType>::~Case (void) +{ +} + +template <typename StringType, typename TypeCodeType> +bool +TAO::TypeCode::Case<StringType, TypeCodeType>::equal (CORBA::ULong index, + CORBA::TypeCode_ptr tc + ACE_ENV_ARG_DECL) const +{ + // Check case names. + char const * const lhs_name = this->name (); + char const * const rhs_name = tc->member_name (index + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + if (ACE_OS::strcmp (lhs_name, rhs_name) != 0) + return 0; + + // Check case TypeCodes. + CORBA::TypeCode_ptr const lhs_tc = this->type (); + CORBA::TypeCode_var const rhs_tc = + tc->member_type (index + 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; + + // Check case label. + return this->equal_label (index, + tc + ACE_ENV_ARG_PARAMETER); +} + +template <typename StringType, typename TypeCodeType> +bool +TAO::TypeCode::Case<StringType, TypeCodeType>::equivalent ( + CORBA::ULong index, + CORBA::TypeCode_ptr tc + ACE_ENV_ARG_DECL) const +{ + // Member names are ignore when determining equivalence. + + // Check case TypeCodes. + CORBA::TypeCode_ptr const lhs_tc = this->type (); + CORBA::TypeCode_var const rhs_tc = + tc->member_type (index + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + CORBA::Boolean const equivalent_members = + lhs_tc->equivalent (rhs_tc.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + if (!equivalent_members) + return 0; + + // Check case label. + // The label must be equal when determining equivalence, too. + return this->equal_label (index, + tc + ACE_ENV_ARG_PARAMETER); +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +#endif /* TAO_TYPECODE_CASE_CPP */ diff --git a/TAO/tao/AnyTypeCode/TypeCode_Case_Base_T.h b/TAO/tao/AnyTypeCode/TypeCode_Case_Base_T.h new file mode 100644 index 00000000000..638051bcb6a --- /dev/null +++ b/TAO/tao/AnyTypeCode/TypeCode_Case_Base_T.h @@ -0,0 +1,210 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file TypeCode_Case_Base_T.h + * + * $Id$ + * + * Header file for @c TAO::TypeCode::Case type. + * + * @author Ossama Othman + */ +//============================================================================= + +#ifndef TAO_TYPECODE_CASE_H +#define TAO_TYPECODE_CASE_H + +#include /**/ "ace/pre.h" + +#include "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace CORBA +{ + class TypeCode; + typedef TypeCode* TypeCode_ptr; + + class Any; +} + +namespace TAO +{ + namespace TypeCode + { + + /** + * @class Case + * + * @brief Abstract base class for that represents an IDL @c union + * case/member. + * + * This class hides the actual IDL @c union member label value + * from the @c TAO::TypeCode::Union class by relying on a + * CORBA::Any return value that corresponds to the @c + * CORBA::TypeCode::member_label() return type. It also allows + * the @c TAO::TypeCode::Union class to marshal the member label + * values into a CDR stream without knowledge of the underlying + * member label values. + */ + template <typename StringType, typename TypeCodeType> + class Case + { + public: + + /// Constructor. + /** + * Constructor used when creating static @c union @c TypeCodes. + */ + Case (char const * name, + TypeCodeType tc); + + /// Constructor. + /** + * Constructor used when creating dynamic @c union @c TypeCodes. + */ + Case (void); + + /// Destructor. + virtual ~Case (void); + + /// Cloning/copying operation. + virtual Case * clone (void) const = 0; + + /// Return the IDL @c union case label value embedded within a + /// @c CORBA::Any. + virtual CORBA::Any * label (ACE_ENV_SINGLE_ARG_DECL) const = 0; + + /// Get the name of the @c union case/member. + char const * name (void) const; + + /// Set the name of the @c union case/member. + void name (char const * the_name); + + /// Get the @c CORBA::TypeCode of the @c union case/member. + /** + * @note The reference count is not manipulated by this method, + * i.e., ownership is retained by this class. + */ + CORBA::TypeCode_ptr type (void) const; + + /// Set the @c CORBA::TypeCode of the @c union case/member. + /** + * @note @c CORBA::TypeCode::_duplicate() is called on the + * @c TypeCode @a tc. + */ + void type (CORBA::TypeCode_ptr tc); + + /// Marshal this IDL @c union member into the given output CDR + /// stream. + bool marshal (TAO_OutputCDR & cdr, + CORBA::ULong offset) const; + + /// Check for equality of the @c case attributes contained by this + /// class and the corresponding member attributes at index "@a + /// index" in the given @c TypeCode @a tc. + bool equal (CORBA::ULong index, + CORBA::TypeCode_ptr tc + ACE_ENV_ARG_DECL) const; + + /// Check for equivalence of the @c case attributes contained by + /// this class and the corresponding member attributes at index + /// "@a index" in the given @c TypeCode @a tc. + bool equivalent (CORBA::ULong index, + CORBA::TypeCode_ptr tc + ACE_ENV_ARG_DECL) const; + + protected: + + /// Marshal the IDL @c union @c case label value into the given + /// output CDR stream. + virtual bool marshal_label (TAO_OutputCDR & cdr) const = 0; + + /// Verify equality of member labels. + /** + * Performing member label equality comparisons in the @c Case + * subclass allows us to avoid performing interpretive + * extraction of the value from the @c Any returned from the + * "right hand side" operand @c TypeCode since the @c Case + * subclass already knows what type and value should be + * extracted from the @c Any. + * + * @param index Member index of given @c TypeCode @a tc being + * tested. + * @param tc The @c TypeCode whose member "@a index" label is + * being tested. + */ + virtual bool equal_label (CORBA::ULong index, + CORBA::TypeCode_ptr tc + ACE_ENV_ARG_DECL) const = 0; + + private: + + /// The name of the case. + StringType name_; + + /// Pointer to the @c CORBA::TypeCode of the case. + /** + * 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 Case statically at + * compile-time, hence the indirection. + * + * @note This @c TypeCode is released upon destruction of this + * @c Case. + */ + TypeCodeType type_; + + }; + + typedef Case<CORBA::String_var, CORBA::TypeCode_var> Case_Dynamic; + + } // End namespace TypeCode +} // End namespace TAO + +TAO_END_VERSIONED_NAMESPACE_DECL + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace ACE +{ + /// @see ace/Value_Ptr.h. + template <typename T> struct VP_traits; + + template <> + struct TAO_AnyTypeCode_Export VP_traits<TAO::TypeCode::Case_Dynamic> + { + /// Copy the given object. + static TAO::TypeCode::Case_Dynamic * clone ( + TAO::TypeCode::Case_Dynamic const * p) + { + return p->clone (); + } + }; + +} // End namespace ACE. + +ACE_END_VERSIONED_NAMESPACE_DECL + + +#ifdef __ACE_INLINE__ +# include "tao/AnyTypeCode/TypeCode_Case_Base_T.inl" +#endif /* __ACE_INLINE__ */ + +#ifdef ACE_TEMPLATES_REQUIRE_SOURCE +# include "tao/AnyTypeCode/TypeCode_Case_Base_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#ifdef ACE_TEMPLATES_REQUIRE_PRAGMA +# pragma implementation ("TypeCode_Case_Base_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" + +#endif /* TAO_TYPECODE_CASE_H */ diff --git a/TAO/tao/AnyTypeCode/TypeCode_Case_Base_T.inl b/TAO/tao/AnyTypeCode/TypeCode_Case_Base_T.inl new file mode 100644 index 00000000000..4bd6b4f8a79 --- /dev/null +++ b/TAO/tao/AnyTypeCode/TypeCode_Case_Base_T.inl @@ -0,0 +1,79 @@ +// -*- C++ -*- +// +// $Id$ + +#include "tao/CDR.h" +#include "tao/AnyTypeCode/TypeCode_Traits.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +template <typename StringType, typename TypeCodeType> +ACE_INLINE +TAO::TypeCode::Case<StringType, TypeCodeType>::Case ( + char const * member_name, + TypeCodeType member_type) + : name_ (member_name) + , type_ (member_type) +{ +} + +template <typename StringType, typename TypeCodeType> +ACE_INLINE +TAO::TypeCode::Case<StringType, TypeCodeType>::Case (void) + : name_ () + , type_ () +{ + // Only used when StringType and TypeCodeType are CORBA::String_var + // and CORBA::TypeCode_var, respectively. +} + +template <typename StringType, typename TypeCodeType> +ACE_INLINE bool +TAO::TypeCode::Case<StringType, TypeCodeType>::marshal ( + TAO_OutputCDR & cdr, + CORBA::ULong offset) const +{ + return + this->marshal_label (cdr) + && (cdr << TAO_OutputCDR::from_string ( + Traits<StringType>::get_string (this->name_), 0)) + && TAO::TypeCode::marshal (cdr, + Traits<StringType>::get_typecode (this->type_), + offset + cdr.total_length ()); +} + +template <typename StringType, typename TypeCodeType> +ACE_INLINE char const * +TAO::TypeCode::Case<StringType, TypeCodeType>::name (void) const +{ + return + Traits<StringType>::get_string (this->name_); +} + +template <typename StringType, typename TypeCodeType> +ACE_INLINE void +TAO::TypeCode::Case<StringType, TypeCodeType>::name ( + char const * the_name) +{ + this->name_ = the_name; +} + +template <typename StringType, typename TypeCodeType> +ACE_INLINE CORBA::TypeCode_ptr +TAO::TypeCode::Case<StringType, TypeCodeType>::type (void) const +{ + return + Traits<StringType>::get_typecode (this->type_); +} + +template <typename StringType, typename TypeCodeType> +ACE_INLINE void +TAO::TypeCode::Case<StringType, TypeCodeType>::type (CORBA::TypeCode_ptr tc) +{ + // This assignment works since it is only used when TypeCodeType is + // "CORBA::TypeCode_var", not in the "CORBA::TypeCode_ptr const *" + // case. + this->type_ = CORBA::TypeCode::_duplicate (tc); +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/TypeCode_Case_T.cpp b/TAO/tao/AnyTypeCode/TypeCode_Case_T.cpp new file mode 100644 index 00000000000..fc7533e98ae --- /dev/null +++ b/TAO/tao/AnyTypeCode/TypeCode_Case_T.cpp @@ -0,0 +1,164 @@ +// $Id$ + +#ifndef TAO_TYPECODE_CASE_T_CPP +#define TAO_TYPECODE_CASE_T_CPP + +#include "tao/AnyTypeCode/TypeCode_Case_T.h" + +#include "tao/CDR.h" +#include "tao/AnyTypeCode/Any.h" +#include "tao/SystemException.h" + +#ifndef __ACE_INLINE__ +# include "tao/AnyTypeCode/TypeCode_Case_T.inl" +#endif /* __ACE_INLINE__ */ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + namespace TypeCode + { + template <typename T> + struct Case_Traits + { + inline static T any_from (T v) + { + return v; + } + + inline static T & any_to (T & v) + { + return v; + } + }; + + // Specializations for types that require wrapper for Any + // insertion. Note that we only define specializations for types + // that can be used in an IDL union discriminator. + + template <> + struct Case_Traits<CORBA::Boolean> + { + inline static CORBA::Any::from_boolean any_from (CORBA::Boolean v) + { + return CORBA::Any::from_boolean (v); + } + + inline static CORBA::Any::to_boolean any_to (CORBA::Boolean & v) + { + return CORBA::Any::to_boolean (v); + } + }; + + template <> + struct Case_Traits<CORBA::Char> + { + inline static CORBA::Any::from_char any_from (CORBA::Char v) + { + return CORBA::Any::from_char (v); + } + + inline static CORBA::Any::to_char any_to (CORBA::Char & v) + { + return CORBA::Any::to_char (v); + } + }; + + } // End TypeCode namespace +} // End TAO namespace + +// ---------------------------------------------------------------- + + +template <typename DiscriminatorType, + typename StringType, + typename TypeCodeType> +TAO::TypeCode::Case<StringType, TypeCodeType> * +TAO::TypeCode::Case_T<DiscriminatorType, + StringType, + TypeCodeType>::clone (void) const +{ + Case<StringType, TypeCodeType> * p = 0; + + typedef Case_T<DiscriminatorType, + StringType, + TypeCodeType> case_type; + + // The compiler generated memberwise copy constructor is sufficient. + ACE_NEW_RETURN (p, + case_type (*this), + p); + + return p; +} + +template <typename DiscriminatorType, + typename StringType, + typename TypeCodeType> +bool +TAO::TypeCode::Case_T<DiscriminatorType, + StringType, + TypeCodeType>::marshal_label (TAO_OutputCDR & cdr) const +{ + return + (cdr << + TAO::TypeCode::Case_Traits<DiscriminatorType>::any_from (this->label_)); +} + +template <typename DiscriminatorType, + typename StringType, + typename TypeCodeType> +bool +TAO::TypeCode::Case_T<DiscriminatorType, + StringType, + TypeCodeType>::equal_label (CORBA::ULong index, + CORBA::TypeCode_ptr tc + ACE_ENV_ARG_DECL) const +{ + CORBA::Any_var const any = tc->member_label (index + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + // The equality operator == below is guaranteed to be defined for + // the discriminator type since an IDL union discriminator type must + // be any of the following: (1) an integer, (2) a character, (3) a + // boolean, or (4) an enumeration. + + DiscriminatorType tc_label; + if ((any.in () + >>= TAO::TypeCode::Case_Traits<DiscriminatorType>::any_to (tc_label)) + && this->label_ == tc_label) + { + return true; + } + + return false; +} + +template <typename DiscriminatorType, + typename StringType, + typename TypeCodeType> +CORBA::Any * +TAO::TypeCode::Case_T<DiscriminatorType, + StringType, + TypeCodeType>::label (ACE_ENV_SINGLE_ARG_DECL) const +{ + CORBA::Any * value = 0; + + ACE_NEW_THROW_EX (value, + CORBA::Any, + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (0); + + CORBA::Any_var safe_value (value); + + *value <<= + TAO::TypeCode::Case_Traits<DiscriminatorType>::any_from (this->label_); + + return safe_value._retn (); +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +#endif /* TAO_TYPECODE_CASE_T_CPP */ diff --git a/TAO/tao/AnyTypeCode/TypeCode_Case_T.h b/TAO/tao/AnyTypeCode/TypeCode_Case_T.h new file mode 100644 index 00000000000..c0cff25b880 --- /dev/null +++ b/TAO/tao/AnyTypeCode/TypeCode_Case_T.h @@ -0,0 +1,147 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file TypeCode_Case_T.h + * + * $Id$ + * + * Header file for @c TAO::TypeCode::Case_T template. + * + * @author Ossama Othman + */ +//============================================================================= + +#ifndef TAO_TYPECODE_CASE_T_H +#define TAO_TYPECODE_CASE_T_H + +#include /**/ "ace/pre.h" + +#include "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/AnyTypeCode/TypeCode_Case_Base_T.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + namespace TypeCode + { + /** + * @class Case_T + * + * @brief Representation of an OMG IDL defined @c union @c case. + * + * A @c Case_T contains the corresponding case label value, name and + * pointer to the @c CORBA::TypeCode for a given OMG IDL @c union + * @c case. For + * example, the cases in following OMG IDL @c union: + * + * \code + * union Foo switch (short) + * { + * case 0: + * case 1: short a; + * case 2: long b; + * default: octet c; + * }; + * \endcode + * + * would be represented using the following statically instantiated + * @c TAO::TypeCode::Case_T array: + * + * \code + * typedef TAO::TypeCode::Case_T<CORBA::Short, char const *> Foo_Case; + * Foo_Case _tao_cases_Foo[] = + * { + * Foo_Case (0, "a", &CORBA::_tc_short), + * Foo_Case (1, "a", &CORBA::_tc_short), + * Foo_Case (2, "b", &CORBA::_tc_long), + * Foo_Case (0, "c", &CORBA::_tc_octet) + * }; + * \endcode + * + * The @c default index is passed directly to the + * @c TAO::TypeCode::Union constructor. + * + * The template parameter @a DISCRIMINATOR_TYPE is the + * corresponding C++ type for the IDL defined @c union + * discriminator type. For example, a @c union with an IDL @c + * short discriminator will have a corresponding @c CORBA::Short + * C++ type. This template parameter is necessary to allow the + * actual @c case label value to be stored as its actual type, + * which is particularly important when marshaling that value into + * a CDR stream. + * + * The template parameter @a StringType is either @c char @c + * const @c * or @c CORBA::String_var. The latter is only used + * when creating @c CORBA::tk_union @c TypeCode dynamically, such + * as through the TypeCodeFactory. + */ + template <typename DiscriminatorType, + typename StringType, + typename TypeCodeType> + class Case_T : public Case<StringType, TypeCodeType> + { + public: + + /// Constructor. + Case_T (DiscriminatorType member_label, + char const * member_name, + TypeCodeType member_type); + + /// Constructor. + /** + * Constructor only used in the dynamically constructed @c union + * @c TypeCode case. + */ + Case_T (DiscriminatorType member_label); + + /** + * @name @c TAO::TypeCode::Case Methods + * + * Methods required by the @c TAO::TypeCode::Case abstract base + * class. + * + * @see @c TAO::TypeCode::Case + */ + //@{ + Case<StringType, TypeCodeType> * clone (void) const; + virtual CORBA::Any * label (ACE_ENV_SINGLE_ARG_DECL) const; + virtual bool marshal_label (TAO_OutputCDR & cdr) const; + virtual bool equal_label (CORBA::ULong index, + CORBA::TypeCode_ptr tc + ACE_ENV_ARG_DECL) const; + //@} + + private: + + /// IDL @c union case/member label value. + DiscriminatorType const label_; + + }; + + } // End namespace TypeCode +} // End namespace TAO + +TAO_END_VERSIONED_NAMESPACE_DECL + +#ifdef __ACE_INLINE__ +# include "tao/AnyTypeCode/TypeCode_Case_T.inl" +#endif /* __ACE_INLINE__ */ + +#ifdef ACE_TEMPLATES_REQUIRE_SOURCE +# include "tao/AnyTypeCode/TypeCode_Case_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#ifdef ACE_TEMPLATES_REQUIRE_PRAGMA +# pragma implementation ("TypeCode_Case_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" + +#endif /* TAO_TYPECODE_CASE_T_H */ diff --git a/TAO/tao/AnyTypeCode/TypeCode_Case_T.inl b/TAO/tao/AnyTypeCode/TypeCode_Case_T.inl new file mode 100644 index 00000000000..f95b599c795 --- /dev/null +++ b/TAO/tao/AnyTypeCode/TypeCode_Case_T.inl @@ -0,0 +1,34 @@ +// -*- C++ -*- +// +// $Id$ + + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +template <typename DiscriminatorType, + typename StringType, + typename TypeCodeType> +ACE_INLINE +TAO::TypeCode::Case_T<DiscriminatorType, + StringType, + TypeCodeType>::Case_T (DiscriminatorType member_label, + char const * member_name, + TypeCodeType member_type) + : Case<StringType, TypeCodeType> (member_name, member_type) + , label_ (member_label) +{ +} + +template <typename DiscriminatorType, + typename StringType, + typename TypeCodeType> +ACE_INLINE +TAO::TypeCode::Case_T<DiscriminatorType, + StringType, + TypeCodeType>::Case_T (DiscriminatorType member_label) + : Case<StringType, TypeCodeType> () + , label_ (member_label) +{ +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/TypeCode_Constants.cpp b/TAO/tao/AnyTypeCode/TypeCode_Constants.cpp new file mode 100644 index 00000000000..cc156f63533 --- /dev/null +++ b/TAO/tao/AnyTypeCode/TypeCode_Constants.cpp @@ -0,0 +1,114 @@ +// $Id$ + + +#include "tao/AnyTypeCode/TypeCode_Constants.h" + + +ACE_RCSID (AnyTypeCode, + TypeCode_Constants, + "$Id$") + + +#include "tao/AnyTypeCode/Null_RefCount_Policy.h" +#include "tao/AnyTypeCode/Empty_Param_TypeCode.h" +#include "tao/AnyTypeCode/Objref_TypeCode_Static.h" +#include "tao/AnyTypeCode/String_TypeCode_Static.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + namespace TypeCode + { + // Notice that these are all statically instantiated and not + // exported. There CORBA::TypeCode_ptr counterparts are, however, + // exported. + + Empty_Param tc_null (CORBA::tk_null); + Empty_Param tc_void (CORBA::tk_void); + Empty_Param tc_boolean (CORBA::tk_boolean); + Empty_Param tc_char (CORBA::tk_char); + Empty_Param tc_wchar (CORBA::tk_wchar); + Empty_Param tc_short (CORBA::tk_short); + Empty_Param tc_ushort (CORBA::tk_ushort); + Empty_Param tc_long (CORBA::tk_long); + Empty_Param tc_ulong (CORBA::tk_ulong); + Empty_Param tc_longlong (CORBA::tk_longlong); + Empty_Param tc_ulonglong (CORBA::tk_ulonglong); + Empty_Param tc_float (CORBA::tk_float); + Empty_Param tc_double (CORBA::tk_double); + Empty_Param tc_longdouble (CORBA::tk_longdouble); + Empty_Param tc_octet (CORBA::tk_octet); + Empty_Param tc_any (CORBA::tk_any); + Empty_Param tc_TypeCode (CORBA::tk_TypeCode); + Empty_Param tc_Principal (CORBA::tk_Principal); + + // -------------- + + String<TAO::Null_RefCount_Policy> tc_string (CORBA::tk_string, 0); + String<TAO::Null_RefCount_Policy> tc_wstring (CORBA::tk_wstring, 0); + + // -------------- + + char const tc_object_id[] = "IDL:omg.org/CORBA/Object:1.0"; + char const tc_object_name[] = "Object"; + Objref<char const *, + TAO::Null_RefCount_Policy> tc_Object (CORBA::tk_objref, + tc_object_id, + tc_object_name); + + char const tc_component_id[] = "IDL:omg.org/CORBA/CCMObject:1.0"; + char const tc_component_name[] = "CCMObject"; + Objref<char const *, + TAO::Null_RefCount_Policy> tc_Component (CORBA::tk_component, + tc_component_id, + tc_component_name); + + char const tc_home_id[] = "IDL:omg.org/CORBA/CCMHome:1.0"; + char const tc_home_name[] = "CCMHome"; + Objref<char const *, + TAO::Null_RefCount_Policy> tc_Home (CORBA::tk_home, + tc_home_id, + tc_home_name); + } // End TypeCode namespace +} // End TAO namespace + +// ------------------------------------------------------------------ +// OMG defined TypeCode constants +// ------------------------------------------------------------------ + +namespace CORBA +{ + // Notice that these are constant TypeCode references/pointers, not + // constant TypeCodes. TypeCodes are effectively read-only since + // all non-static TypeCode operations are const. + + TypeCode_ptr const _tc_null = &TAO::TypeCode::tc_null; + TypeCode_ptr const _tc_void = &TAO::TypeCode::tc_void; + TypeCode_ptr const _tc_boolean = &TAO::TypeCode::tc_boolean; + TypeCode_ptr const _tc_char = &TAO::TypeCode::tc_char; + TypeCode_ptr const _tc_wchar = &TAO::TypeCode::tc_wchar; + TypeCode_ptr const _tc_short = &TAO::TypeCode::tc_short; + TypeCode_ptr const _tc_ushort = &TAO::TypeCode::tc_ushort; + TypeCode_ptr const _tc_long = &TAO::TypeCode::tc_long; + TypeCode_ptr const _tc_ulong = &TAO::TypeCode::tc_ulong; + TypeCode_ptr const _tc_longlong = &TAO::TypeCode::tc_longlong; + TypeCode_ptr const _tc_ulonglong = &TAO::TypeCode::tc_ulonglong; + TypeCode_ptr const _tc_float = &TAO::TypeCode::tc_float; + TypeCode_ptr const _tc_double = &TAO::TypeCode::tc_double; + TypeCode_ptr const _tc_longdouble = &TAO::TypeCode::tc_longdouble; + TypeCode_ptr const _tc_octet = &TAO::TypeCode::tc_octet; + TypeCode_ptr const _tc_any = &TAO::TypeCode::tc_any; + TypeCode_ptr const _tc_TypeCode = &TAO::TypeCode::tc_TypeCode; + TypeCode_ptr const _tc_Principal = &TAO::TypeCode::tc_Principal; + + TypeCode_ptr const _tc_string = &TAO::TypeCode::tc_string; + TypeCode_ptr const _tc_wstring = &TAO::TypeCode::tc_wstring; + + TypeCode_ptr const _tc_Object = &TAO::TypeCode::tc_Object; + TypeCode_ptr const _tc_Component = &TAO::TypeCode::tc_Component; + TypeCode_ptr const _tc_Home = &TAO::TypeCode::tc_Home; + +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/TypeCode_Constants.h b/TAO/tao/AnyTypeCode/TypeCode_Constants.h new file mode 100644 index 00000000000..2aea3471df7 --- /dev/null +++ b/TAO/tao/AnyTypeCode/TypeCode_Constants.h @@ -0,0 +1,124 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file TypeCode_Constants.h + * + * $Id$ + * + * Declare the @c TypeCode constants available to the ORB and user + * applications. + * + * @author Jeff Parsons + * @author Ossama Othman + */ +//============================================================================= + +#ifndef TAO_TYPECODE_CONSTANTS_H +#define TAO_TYPECODE_CONSTANTS_H + +#include /**/ "ace/pre.h" + +#include "tao/AnyTypeCode/TAO_AnyTypeCode_Export.h" + +#include "tao/Versioned_Namespace.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace CORBA +{ + class TypeCode; + typedef TypeCode * TypeCode_ptr; + + /** + * @name TypeCode Constants + * + * All the TypeCode constants + */ + //@{ + extern TAO_AnyTypeCode_Export TypeCode_ptr const _tc_null; + extern TAO_AnyTypeCode_Export TypeCode_ptr const _tc_void; + extern TAO_AnyTypeCode_Export TypeCode_ptr const _tc_boolean; + extern TAO_AnyTypeCode_Export TypeCode_ptr const _tc_char; + extern TAO_AnyTypeCode_Export TypeCode_ptr const _tc_wchar; + extern TAO_AnyTypeCode_Export TypeCode_ptr const _tc_short; + extern TAO_AnyTypeCode_Export TypeCode_ptr const _tc_ushort; + extern TAO_AnyTypeCode_Export TypeCode_ptr const _tc_long; + extern TAO_AnyTypeCode_Export TypeCode_ptr const _tc_ulong; + extern TAO_AnyTypeCode_Export TypeCode_ptr const _tc_longlong; + extern TAO_AnyTypeCode_Export TypeCode_ptr const _tc_ulonglong; + extern TAO_AnyTypeCode_Export TypeCode_ptr const _tc_float; + extern TAO_AnyTypeCode_Export TypeCode_ptr const _tc_double; + extern TAO_AnyTypeCode_Export TypeCode_ptr const _tc_longdouble; + extern TAO_AnyTypeCode_Export TypeCode_ptr const _tc_octet; + extern TAO_AnyTypeCode_Export TypeCode_ptr const _tc_any; + extern TAO_AnyTypeCode_Export TypeCode_ptr const _tc_TypeCode; + extern TAO_AnyTypeCode_Export TypeCode_ptr const _tc_Principal; + + extern TAO_AnyTypeCode_Export TypeCode_ptr const _tc_string; + extern TAO_AnyTypeCode_Export TypeCode_ptr const _tc_wstring; + + extern TAO_AnyTypeCode_Export TypeCode_ptr const _tc_Object; + extern TAO_AnyTypeCode_Export TypeCode_ptr const _tc_Component; + extern TAO_AnyTypeCode_Export TypeCode_ptr const _tc_Home; + //@} + +#define TAO_SYSTEM_EXCEPTION_LIST \ + TAO_SYSTEM_EXCEPTION(UNKNOWN); \ + TAO_SYSTEM_EXCEPTION(BAD_PARAM); \ + TAO_SYSTEM_EXCEPTION(NO_MEMORY); \ + TAO_SYSTEM_EXCEPTION(IMP_LIMIT); \ + TAO_SYSTEM_EXCEPTION(COMM_FAILURE); \ + TAO_SYSTEM_EXCEPTION(INV_OBJREF); \ + TAO_SYSTEM_EXCEPTION(OBJECT_NOT_EXIST); \ + TAO_SYSTEM_EXCEPTION(NO_PERMISSION); \ + TAO_SYSTEM_EXCEPTION(INTERNAL); \ + TAO_SYSTEM_EXCEPTION(MARSHAL); \ + TAO_SYSTEM_EXCEPTION(INITIALIZE); \ + TAO_SYSTEM_EXCEPTION(NO_IMPLEMENT); \ + TAO_SYSTEM_EXCEPTION(BAD_TYPECODE); \ + TAO_SYSTEM_EXCEPTION(BAD_OPERATION); \ + TAO_SYSTEM_EXCEPTION(NO_RESOURCES); \ + TAO_SYSTEM_EXCEPTION(NO_RESPONSE); \ + TAO_SYSTEM_EXCEPTION(PERSIST_STORE); \ + TAO_SYSTEM_EXCEPTION(BAD_INV_ORDER); \ + TAO_SYSTEM_EXCEPTION(TRANSIENT); \ + TAO_SYSTEM_EXCEPTION(FREE_MEM); \ + TAO_SYSTEM_EXCEPTION(INV_IDENT); \ + TAO_SYSTEM_EXCEPTION(INV_FLAG); \ + TAO_SYSTEM_EXCEPTION(INTF_REPOS); \ + TAO_SYSTEM_EXCEPTION(BAD_CONTEXT); \ + TAO_SYSTEM_EXCEPTION(OBJ_ADAPTER); \ + TAO_SYSTEM_EXCEPTION(DATA_CONVERSION); \ + TAO_SYSTEM_EXCEPTION(INV_POLICY); \ + TAO_SYSTEM_EXCEPTION(REBIND); \ + TAO_SYSTEM_EXCEPTION(TIMEOUT); \ + TAO_SYSTEM_EXCEPTION(TRANSACTION_UNAVAILABLE); \ + TAO_SYSTEM_EXCEPTION(TRANSACTION_MODE); \ + TAO_SYSTEM_EXCEPTION(TRANSACTION_REQUIRED); \ + TAO_SYSTEM_EXCEPTION(TRANSACTION_ROLLEDBACK); \ + TAO_SYSTEM_EXCEPTION(INVALID_TRANSACTION); \ + TAO_SYSTEM_EXCEPTION(CODESET_INCOMPATIBLE); \ + TAO_SYSTEM_EXCEPTION(BAD_QOS); \ + TAO_SYSTEM_EXCEPTION(INVALID_ACTIVITY); \ + TAO_SYSTEM_EXCEPTION(ACTIVITY_COMPLETED); \ + TAO_SYSTEM_EXCEPTION(ACTIVITY_REQUIRED); \ + TAO_SYSTEM_EXCEPTION(THREAD_CANCELLED); + + // = Typecode constants for system exceptions. +#define TAO_SYSTEM_EXCEPTION(name) \ + extern TAO_AnyTypeCode_Export TypeCode_ptr const _tc_ ## name + TAO_SYSTEM_EXCEPTION_LIST +#undef TAO_SYSTEM_EXCEPTION + //@} + + extern TAO_AnyTypeCode_Export TypeCode_ptr const _tc_Current; + + extern TAO_AnyTypeCode_Export TypeCode_ptr const _tc_NamedValue; +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" + +#endif /* TAO_TYPECODE_CONSTANTS_H */ diff --git a/TAO/tao/AnyTypeCode/TypeCode_Struct_Field.h b/TAO/tao/AnyTypeCode/TypeCode_Struct_Field.h new file mode 100644 index 00000000000..1a3d8c9deb4 --- /dev/null +++ b/TAO/tao/AnyTypeCode/TypeCode_Struct_Field.h @@ -0,0 +1,91 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file TypeCode_Struct_Field.h + * + * $Id$ + * + * Header file for @c TAO::TypeCode::Struct_Field type. + * + * @author Ossama Othman <ossama@dre.vanderbilt.edu> + * @author Carlos O'Ryan + */ +//============================================================================= + +#ifndef TAO_TYPECODE_STRUCT_FIELD_H +#define TAO_TYPECODE_STRUCT_FIELD_H + +#include /**/ "ace/pre.h" + +#include "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace CORBA +{ + class TypeCode; + typedef TypeCode* TypeCode_ptr; +} + +namespace TAO +{ + namespace TypeCode + { + /** + * @struct Struct_Field + * + * @brief Name/type pair for fields of an OMG IDL defined + * structure or exception. + * + * A @c Struct_Field contains the corresponding name and pointer + * to the @c CORBA::TypeCode for a given OMG IDL defined type. + * For example, the fields in following OMG IDL structure: + * + * \code + * struct Foo + * { + * long the_number; + * string the_string; + * }; + * \endcode + * + * would be represented using the following statically instantiated + * @c TAO::TypeCode::Struct_Field array: + * + * \code + * TAO::TypeCode::Struct_Field<char const *> _tao_fields_Foo[] = + * { + * { "the_number", &CORBA::_tc_long }, + * { "the_string", &CORBA::_tc_string }, + * }; + * \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. + */ + template <typename StringType, typename TypeCodeType> + struct Struct_Field + { + /// The name of the field. + StringType name; + + /// The @c CORBA::TypeCode of the field. + TypeCodeType type; + + }; + + } // End namespace TypeCode +} // End namespace TAO + +TAO_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" + +#endif /* TAO_TYPECODE_STRUCT_FIELD_H */ diff --git a/TAO/tao/AnyTypeCode/TypeCode_Traits.h b/TAO/tao/AnyTypeCode/TypeCode_Traits.h new file mode 100644 index 00000000000..7c1fe02b47e --- /dev/null +++ b/TAO/tao/AnyTypeCode/TypeCode_Traits.h @@ -0,0 +1,126 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file TypeCode_Traits.h + * + * $Id$ + * + * @author Ossama Othman <ossama@dre.vanderbilt.edu> + */ +//============================================================================= + +#ifndef TAO_TYPECODE_TRAITS_H +#define TAO_TYPECODE_TRAITS_H + +#include /**/ "ace/pre.h" + +#include "tao/CORBA_String.h" +#include "tao/AnyTypeCode/TypeCode.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + class Null_RefCount_Policy; + class True_RefCount_Policy; + + namespace TypeCode + { + +// enum Storage { STATIC_TYPECODE, DYNAMIC_TYPECODE }; + +// template<Storage S> struct Traits; + + // ---- + // @@ Work around limitations in MSVC++ 6. + typedef char const * STATIC_TYPECODE; + typedef CORBA::String_var DYNAMIC_TYPECODE; + + template<typename S> struct Traits; + // ---- + + template<> + struct Traits<STATIC_TYPECODE> + { + typedef char const * string_type; + + /** + * 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 a static object that + * refers to it, hence the indirection. + */ + typedef CORBA::TypeCode_ptr const * typecode_type; + + typedef TAO::Null_RefCount_Policy refcount_policy_type; + + static char const * get_string (string_type const & str) + { + return str; + } + + static CORBA::TypeCode_ptr get_typecode (typecode_type const & tc) + { + return (tc == 0 ? CORBA::TypeCode::_nil () : *tc); + } + }; + + template<> + struct Traits<DYNAMIC_TYPECODE> + { + typedef CORBA::String_var string_type; + typedef CORBA::TypeCode_var typecode_type; + typedef TAO::True_RefCount_Policy refcount_policy_type; + + static char const * get_string (string_type const & str) + { + return str.in (); + } + + static CORBA::TypeCode_ptr get_typecode (typecode_type const & tc) + { + return tc.in (); + } + }; + + // --------------- + + // Traits based on TypeCode type template parameters. + + template<> + struct Traits<Traits<STATIC_TYPECODE>::typecode_type> + { + typedef Traits<STATIC_TYPECODE>::typecode_type typecode_type; + + static CORBA::TypeCode_ptr get_typecode (typecode_type const & tc) + { + return (tc == 0 ? CORBA::TypeCode::_nil () : *tc); + } + }; + + template<> + struct Traits<Traits<DYNAMIC_TYPECODE>::typecode_type> + { + typedef Traits<DYNAMIC_TYPECODE>::typecode_type typecode_type; + + static CORBA::TypeCode_ptr get_typecode (typecode_type const & tc) + { + return tc.in (); + } + + }; + + } // End namespace TypeCode +} // End namespace TAO + +TAO_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" + +#endif /* TAO_TYPECODE_TRAITS_H */ diff --git a/TAO/tao/AnyTypeCode/TypeCode_Value_Field.h b/TAO/tao/AnyTypeCode/TypeCode_Value_Field.h new file mode 100644 index 00000000000..c421189f0f5 --- /dev/null +++ b/TAO/tao/AnyTypeCode/TypeCode_Value_Field.h @@ -0,0 +1,93 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file TypeCode_Value_Field.h + * + * $Id$ + * + * Header file for @c TAO::TypeCode::Value_Field type. + * + * @author Ossama Othman <ossama@dre.vanderbilt.edu> + */ +//============================================================================= + +#ifndef TAO_TYPECODE_VALUE_FIELD_H +#define TAO_TYPECODE_VALUE_FIELD_H + +#include /**/ "ace/pre.h" + +#include "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace CORBA +{ + class TypeCode; + typedef TypeCode* TypeCode_ptr; +} + +namespace TAO +{ + namespace TypeCode + { + /** + * @struct Value_Field + * + * @brief Name/type/visibility tuple fields of an OMG IDL defined + * @c valuetype or @c eventtype. + * + * A @c Value_Field contains the corresponding name and pointer to the + * @c CORBA::TypeCode for a given OMG IDL defined type. For + * example, the fields in following OMG IDL structure: + * + * \code + * struct Foo + * { + * long the_number; + * string the_string; + * }; + * \endcode + * + * would be represented using the following statically instantiated + * @c TAO::TypeCode::Value_Field array: + * + * \code + * TAO::TypeCode::Value_Field<char const *> _tao_fields_Foo[] = + * { + * { "the_number", &CORBA::_tc_long }, + * { "the_string", &CORBA::_tc_string }, + * }; + * \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_value or @c CORBA::tk_event + * @c TypeCodes dynamically, such as through the TypeCodeFactory. + */ + template <typename StringType, typename TypeCodeType> + struct Value_Field + { + /// The name of the field. + StringType name; + + /// The @c CORBA::TypeCode of the field. + TypeCodeType type; + + /// The visibility of the field. + CORBA::Visibility visibility; + + }; + + } // End namespace TypeCode +} // End namespace TAO + +TAO_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" + +#endif /* TAO_TYPECODE_VALUE_FIELD_H */ diff --git a/TAO/tao/AnyTypeCode/Typecode_typesA.h b/TAO/tao/AnyTypeCode/Typecode_typesA.h new file mode 100644 index 00000000000..ccc5218c384 --- /dev/null +++ b/TAO/tao/AnyTypeCode/Typecode_typesA.h @@ -0,0 +1,47 @@ +// -*- C++ -*- +// +// $Id$ + +// **** Code generated by the The ACE ORB (TAO) IDL Compiler **** +// TAO and the TAO IDL Compiler have been developed by: +// Center for Distributed Object Computing +// Washington University +// St. Louis, MO +// USA +// http://www.cs.wustl.edu/~schmidt/doc-center.html +// and +// Distributed Object Computing Laboratory +// University of California at Irvine +// Irvine, CA +// USA +// http://doc.ece.uci.edu/ +// and +// Institute for Software Integrated Systems +// Vanderbilt University +// Nashville, TN +// USA +// http://www.isis.vanderbilt.edu/ +// +// Information about TAO is available at: +// http://www.cs.wustl.edu/~schmidt/TAO.html + +// TAO_IDL - Generated from +// be\be_codegen.cpp:153 + +#ifndef _TAO_IDL_ORIG_TYPECODE_TYPESA_H_ +#define _TAO_IDL_ORIG_TYPECODE_TYPESA_H_ + +#include /**/ "ace/pre.h" + + +#include "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include /**/ "ace/post.h" + +#endif /* ifndef */ + + diff --git a/TAO/tao/AnyTypeCode/UShortSeqA.cpp b/TAO/tao/AnyTypeCode/UShortSeqA.cpp new file mode 100644 index 00000000000..582d15d69d0 --- /dev/null +++ b/TAO/tao/AnyTypeCode/UShortSeqA.cpp @@ -0,0 +1,146 @@ +// -*- C++ -*- +// +// $Id$ + +// **** Code generated by the The ACE ORB (TAO) IDL Compiler **** +// TAO and the TAO IDL Compiler have been developed by: +// Center for Distributed Object Computing +// Washington University +// St. Louis, MO +// USA +// http://www.cs.wustl.edu/~schmidt/doc-center.html +// and +// Distributed Object Computing Laboratory +// University of California at Irvine +// Irvine, CA +// USA +// http://doc.ece.uci.edu/ +// and +// Institute for Software Integrated Systems +// Vanderbilt University +// Nashville, TN +// USA +// http://www.isis.vanderbilt.edu/ +// +// Information about TAO is available at: +// http://www.cs.wustl.edu/~schmidt/TAO.html + +#include "tao/AnyTypeCode/UShortSeqA.h" +#include "tao/AnyTypeCode/Null_RefCount_Policy.h" +#include "tao/AnyTypeCode/TypeCode_Constants.h" +#include "tao/AnyTypeCode/Alias_TypeCode_Static.h" +#include "tao/AnyTypeCode/Sequence_TypeCode_Static.h" +#include "tao/CDR.h" +#include "tao/AnyTypeCode/Any.h" +#include "tao/AnyTypeCode/Any_Dual_Impl_T.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +// TAO_IDL - Generated from +// be\be_visitor_typecode/alias_typecode.cpp:50 + + + +// TAO_IDL - Generated from +// be\be_visitor_typecode/typecode_defn.cpp:937 + + +#ifndef _TAO_TYPECODE_CORBA_UShortSeq_GUARD +#define _TAO_TYPECODE_CORBA_UShortSeq_GUARD +namespace TAO +{ + namespace TypeCode + { + TAO::TypeCode::Sequence< ::CORBA::TypeCode_ptr const *, + TAO::Null_RefCount_Policy> + CORBA_UShortSeq_0 ( + CORBA::tk_sequence, + &CORBA::_tc_ushort, + 0U); + + ::CORBA::TypeCode_ptr const tc_CORBA_UShortSeq_0 = + &CORBA_UShortSeq_0; + + } +} + + +#endif /* _TAO_TYPECODE_CORBA_UShortSeq_GUARD */ + +static TAO::TypeCode::Alias<char const *, + CORBA::TypeCode_ptr const *, + TAO::Null_RefCount_Policy> + _tao_tc_CORBA_UShortSeq ( + CORBA::tk_alias, + "IDL:omg.org/CORBA/UShortSeq:1.0", + "UShortSeq", + &TAO::TypeCode::tc_CORBA_UShortSeq_0); + +namespace CORBA +{ + ::CORBA::TypeCode_ptr const _tc_UShortSeq = + &_tao_tc_CORBA_UShortSeq; +} + + + +// TAO_IDL - Generated from +// be\be_visitor_sequence/any_op_cs.cpp:54 + + +// Copying insertion. +void operator<<= ( + CORBA::Any &_tao_any, + const CORBA::UShortSeq &_tao_elem + ) +{ + TAO::Any_Dual_Impl_T<CORBA::UShortSeq>::insert_copy ( + _tao_any, + CORBA::UShortSeq::_tao_any_destructor, + TAO::TypeCode::tc_CORBA_UShortSeq_0, + _tao_elem + ); +} + +// Non-copying insertion. +void operator<<= ( + CORBA::Any &_tao_any, + CORBA::UShortSeq *_tao_elem + ) +{ + TAO::Any_Dual_Impl_T<CORBA::UShortSeq>::insert ( + _tao_any, + CORBA::UShortSeq::_tao_any_destructor, + TAO::TypeCode::tc_CORBA_UShortSeq_0, + _tao_elem + ); +} + +// Extraction to non-const pointer (deprecated). +CORBA::Boolean operator>>= ( + const CORBA::Any &_tao_any, + CORBA::UShortSeq *&_tao_elem + ) +{ + return _tao_any >>= const_cast< + const CORBA::UShortSeq *&> ( + _tao_elem + ); +} + +// Extraction to const pointer. +CORBA::Boolean operator>>= ( + const CORBA::Any &_tao_any, + const CORBA::UShortSeq *&_tao_elem + ) +{ + return + TAO::Any_Dual_Impl_T<CORBA::UShortSeq>::extract ( + _tao_any, + CORBA::UShortSeq::_tao_any_destructor, + TAO::TypeCode::tc_CORBA_UShortSeq_0, + _tao_elem + ); +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/UShortSeqA.h b/TAO/tao/AnyTypeCode/UShortSeqA.h new file mode 100644 index 00000000000..824246509de --- /dev/null +++ b/TAO/tao/AnyTypeCode/UShortSeqA.h @@ -0,0 +1,112 @@ +// -*- C++ -*- +// +// $Id$ + +// **** Code generated by the The ACE ORB (TAO) IDL Compiler **** +// TAO and the TAO IDL Compiler have been developed by: +// Center for Distributed Object Computing +// Washington University +// St. Louis, MO +// USA +// http://www.cs.wustl.edu/~schmidt/doc-center.html +// and +// Distributed Object Computing Laboratory +// University of California at Irvine +// Irvine, CA +// USA +// http://doc.ece.uci.edu/ +// and +// Institute for Software Integrated Systems +// Vanderbilt University +// Nashville, TN +// USA +// http://www.isis.vanderbilt.edu/ +// +// Information about TAO is available at: +// http://www.cs.wustl.edu/~schmidt/TAO.html + +// TAO_IDL - Generated from +// be\be_codegen.cpp:153 + +#ifndef _TAO_IDL_ORIG_USHORTSEQA_H_ +#define _TAO_IDL_ORIG_USHORTSEQA_H_ + +#include /**/ "ace/pre.h" + + +#include "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/AnyTypeCode/TAO_AnyTypeCode_Export.h" +#include "tao/AnyTypeCode/AnyTypeCode_methods.h" +#include "tao/UShortSeqC.h" + +#if defined (TAO_EXPORT_MACRO) +#undef TAO_EXPORT_MACRO +#endif +#define TAO_EXPORT_MACRO TAO_AnyTypeCode_Export + +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +#if defined (__BORLANDC__) +#pragma option push -w-rvl -w-rch -w-ccc -w-inl +#endif /* __BORLANDC__ */ + +// TAO_IDL - Generated from +// be\be_visitor_module/module_ch.cpp:48 + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace CORBA +{ + + // TAO_IDL - Generated from + // be\be_visitor_typecode/typecode_decl.cpp:44 + + extern TAO_AnyTypeCode_Export ::CORBA::TypeCode_ptr const _tc_UShortSeq; + +// TAO_IDL - Generated from +// be\be_visitor_module/module_ch.cpp:66 + +} // module CORBA + +// TAO_IDL - Generated from +// be\be_visitor_traits.cpp:61 + +// Traits specializations. +namespace TAO +{ +} + +// TAO_IDL - Generated from +// be\be_visitor_sequence/any_op_ch.cpp:52 + +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, const CORBA::UShortSeq &); // copying version +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, CORBA::UShortSeq*); // noncopying version +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any &, CORBA::UShortSeq *&); // deprecated +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any &, const CORBA::UShortSeq *&); + +// TAO_IDL - Generated from +// be\be_codegen.cpp:955 + +TAO_END_VERSIONED_NAMESPACE_DECL + +#if defined(_MSC_VER) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#if defined (__BORLANDC__) +#pragma option pop +#endif /* __BORLANDC__ */ + +#include /**/ "ace/post.h" + +#endif /* ifndef */ + + diff --git a/TAO/tao/AnyTypeCode/Union_TypeCode.cpp b/TAO/tao/AnyTypeCode/Union_TypeCode.cpp new file mode 100644 index 00000000000..25aba5c6340 --- /dev/null +++ b/TAO/tao/AnyTypeCode/Union_TypeCode.cpp @@ -0,0 +1,463 @@ +// $Id$ + +#ifndef TAO_UNION_TYPECODE_CPP +#define TAO_UNION_TYPECODE_CPP + +#include "tao/AnyTypeCode/Union_TypeCode.h" +#include "tao/AnyTypeCode/TypeCode_Case_Base_T.h" + +#ifndef __ACE_INLINE__ +# include "tao/AnyTypeCode/Union_TypeCode.inl" +#endif /* !__ACE_INLINE__ */ + +#include "tao/SystemException.h" +#include "tao/AnyTypeCode/Any.h" + +#include "ace/Value_Ptr.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +template <typename StringType, + typename TypeCodeType, + class CaseArrayType, + class RefCountPolicy> +bool +TAO::TypeCode::Union<StringType, + TypeCodeType, + CaseArrayType, + RefCountPolicy>::tao_marshal ( + TAO_OutputCDR & cdr, + CORBA::ULong offset) const +{ + // A tk_union 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. + TAO_OutputCDR enc; + + // Account for the encoded CDR encapsulation length and byte order. + // + // Aligning on an octet since the next value after the CDR + // encapsulation length will always be the byte order octet/boolean + // in this case. + offset = ACE_align_binary (offset + 4, + ACE_CDR::OCTET_ALIGN); + + bool const success = + (enc << TAO_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER)) + && (enc << TAO_OutputCDR::from_string (this->base_attributes_.id (), 0)) + && (enc << TAO_OutputCDR::from_string (this->base_attributes_.name (), 0)) + && marshal (enc, + Traits<StringType>::get_typecode (this->discriminant_type_), + offset + enc.total_length ()) + && (enc << this->default_index_) + && (enc << this->ncases_); + + if (!success) + return false; + + offset += enc.total_length (); + + for (CORBA::ULong i = 0; i < this->ncases_; ++i) + { + TAO_OutputCDR case_enc; + offset = ACE_align_binary (offset, + ACE_CDR::LONG_ALIGN); + + case_type const & c = *this->cases_[i]; + + if (!c.marshal (case_enc, offset)) + return false; + + offset += case_enc.total_length (); + + if (!enc.write_octet_array_mb (case_enc.begin ())) + return false; + } + + return + cdr << static_cast<CORBA::ULong> (enc.total_length ()) + && cdr.write_octet_array_mb (enc.begin ()); +} + +template <typename StringType, + typename TypeCodeType, + class CaseArrayType, + class RefCountPolicy> +void +TAO::TypeCode::Union<StringType, + TypeCodeType, + CaseArrayType, + RefCountPolicy>::tao_duplicate (void) +{ + this->RefCountPolicy::add_ref (); +} + +template <typename StringType, + typename TypeCodeType, + class CaseArrayType, + class RefCountPolicy> +void +TAO::TypeCode::Union<StringType, + TypeCodeType, + CaseArrayType, + RefCountPolicy>::tao_release (void) +{ + this->RefCountPolicy::remove_ref (); +} + +template <typename StringType, + typename TypeCodeType, + class CaseArrayType, + class RefCountPolicy> +CORBA::Boolean +TAO::TypeCode::Union<StringType, + TypeCodeType, + CaseArrayType, + RefCountPolicy>::equal_i ( + CORBA::TypeCode_ptr tc + ACE_ENV_ARG_DECL) const +{ + // These calls shouldn't throw since CORBA::TypeCode::equal() + // verified that the TCKind is the same as our's prior to invoking + // this method, meaning that the CORBA::tk_union TypeCode methods + // are supported. + + CORBA::ULong const tc_count = + tc->member_count (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + CORBA::Long tc_def = tc->default_index (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + if (tc_count != this->ncases_ + || tc_def != this->default_index_) + return false; + + // Check the discriminator type. + CORBA::TypeCode_var tc_discriminator = + tc->discriminator_type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + CORBA::Boolean const equal_discriminators = + Traits<StringType>::get_typecode (this->discriminant_type_)->equal ( + tc_discriminator.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + if (!equal_discriminators) + return false; + + for (CORBA::ULong i = 0; i < this->ncases_; ++i) + { + if (this->default_index_ > -1 + && static_cast<CORBA::ULong> (this->default_index_) == i) + { + // Don't bother checking equality of default case label. It + // will always be the zero octet (the CDR encoded value is + // ignored). + continue; + } + + case_type const & lhs_case = *this->cases_[i]; + + bool const equal_case = + lhs_case.equal (i, + tc + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + if (!equal_case) + return false; + } + + return true; +} + +template <typename StringType, + typename TypeCodeType, + class CaseArrayType, + class RefCountPolicy> +CORBA::Boolean +TAO::TypeCode::Union<StringType, + TypeCodeType, + CaseArrayType, + RefCountPolicy>::equivalent_i ( + CORBA::TypeCode_ptr tc + ACE_ENV_ARG_DECL) const +{ + // Perform a structural comparison, excluding the name() and + // member_name() operations. + + CORBA::ULong const tc_count = + tc->member_count (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + CORBA::Long tc_def = tc->default_index (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + if (tc_count != this->ncases_ + || tc_def != this->default_index_) + return false; + + CORBA::TypeCode_var tc_discriminator = + tc->discriminator_type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + CORBA::Boolean const equiv_discriminators = + Traits<StringType>::get_typecode (this->discriminant_type_)->equivalent ( + tc_discriminator.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + if (!equiv_discriminators) + return false; + + for (CORBA::ULong i = 0; i < this->ncases_; ++i) + { + if (this->default_index_ > -1 + && static_cast<CORBA::ULong> (this->default_index_) == i) + { + // Don't bother checking equality/equivalence of default + // case label. It will always be the zero octet (the CDR + // encoded value is ignored). + continue; + } + + case_type const & lhs_case = *this->cases_[i]; + + bool const equivalent_case = + lhs_case.equivalent (i, + tc + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + if (!equivalent_case) + return false; + } + + return true; +} + +template <typename StringType, + typename TypeCodeType, + class CaseArrayType, + class RefCountPolicy> +CORBA::TypeCode_ptr +TAO::TypeCode::Union<StringType, + TypeCodeType, + CaseArrayType, + RefCountPolicy>::get_compact_typecode_i ( + ACE_ENV_SINGLE_ARG_DECL) const +{ +// typedef ACE::Value_Ptr<TAO::TypeCode::Case<CORBA::String_var, +// CORBA::TypeCode_var> > elem_type; + +// ACE_Array_Base<elem_type> tc_cases (this->ncases_); + +// if (this->ncases_ > 0) +// { +// // Dynamically construct a new array of cases stripped of +// // member names. + +// static char const empty_name[] = ""; + +// for (CORBA::ULong i = 0; i < this->ncases_; ++i) +// { +// // Member names will be stripped, i.e. not embedded within +// // the compact TypeCode. +// tc_cases[i].name = empty_name; +// tc_cases[i].type = +// this->cases_[i]->type ()->get_compact_typecode ( +// ACE_ENV_ARG_PARAMETER); +// ACE_CHECK_RETURN (CORBA::TypeCode::_nil ()); +// } +// } + +// // Create the compact union TypeCode. +// 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 ()); +// } + +// return +// adapter->create_union_tc ( +// this->base_attributes_.id (), +// "", /* empty name */ +// Traits<StringType>::get_typecode (this->discriminant_type_), +// tc_cases, +// this->ncases_, +// this->default_index_, +// "", +// Traits<StringType>::get_typecode (this->default_case_.type) +// ACE_ENV_ARG_PARAMETER); +// ACE_CHECK_RETURN (CORBA::TypeCode::_nil ()); + + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), CORBA::TypeCode::_nil ()); + + ACE_NOTREACHED (return CORBA::TypeCode::_nil ()); +} + +template <typename StringType, + typename TypeCodeType, + class CaseArrayType, + class RefCountPolicy> +char const * +TAO::TypeCode::Union<StringType, + TypeCodeType, + CaseArrayType, + 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, + typename TypeCodeType, + class CaseArrayType, + class RefCountPolicy> +char const * +TAO::TypeCode::Union<StringType, + TypeCodeType, + CaseArrayType, + 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, + typename TypeCodeType, + class CaseArrayType, + class RefCountPolicy> +CORBA::ULong +TAO::TypeCode::Union<StringType, + TypeCodeType, + CaseArrayType, + RefCountPolicy>::member_count_i ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const +{ + return this->ncases_; +} + +template <typename StringType, + typename TypeCodeType, + class CaseArrayType, + class RefCountPolicy> +char const * +TAO::TypeCode::Union<StringType, + TypeCodeType, + CaseArrayType, + 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->ncases_) + ACE_THROW_RETURN (CORBA::TypeCode::Bounds (), 0); + + return this->cases_[index]->name (); +} + +template <typename StringType, + typename TypeCodeType, + class CaseArrayType, + class RefCountPolicy> +CORBA::TypeCode_ptr +TAO::TypeCode::Union<StringType, + TypeCodeType, + CaseArrayType, + RefCountPolicy>::member_type_i (CORBA::ULong index + ACE_ENV_ARG_DECL) const +{ + if (index >= this->ncases_) + ACE_THROW_RETURN (CORBA::TypeCode::Bounds (), + CORBA::TypeCode::_nil ()); + + return CORBA::TypeCode::_duplicate (this->cases_[index]->type ()); +} + +template <typename StringType, + typename TypeCodeType, + class CaseArrayType, + class RefCountPolicy> +CORBA::Any * +TAO::TypeCode::Union<StringType, + TypeCodeType, + CaseArrayType, + RefCountPolicy>::member_label_i (CORBA::ULong index + ACE_ENV_ARG_DECL) const +{ + if (index >= this->ncases_) + ACE_THROW_RETURN (CORBA::TypeCode::Bounds (), + 0); + + // Default case. + if (this->default_index_ > -1 + && static_cast<CORBA::ULong> (this->default_index_) == index) + { + CORBA::Any * any = 0; + ACE_NEW_THROW_EX (any, + CORBA::Any, + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (0); + + CORBA::Any_var safe_any (any); + + // Default case's label is a zero octet. + CORBA::Any::from_octet const zero_octet (0); + + // Default case/member has a zero octet label value. + (*any) <<= zero_octet; + + return safe_any._retn (); + } + + // Non-default cases. + return this->cases_[index]->label (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +template <typename StringType, + typename TypeCodeType, + class CaseArrayType, + class RefCountPolicy> +CORBA::TypeCode_ptr +TAO::TypeCode::Union<StringType, + TypeCodeType, + CaseArrayType, + RefCountPolicy>::discriminator_type_i ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const +{ + return + CORBA::TypeCode::_duplicate ( + Traits<StringType>::get_typecode (this->discriminant_type_)); +} + +template <typename StringType, + typename TypeCodeType, + class CaseArrayType, + class RefCountPolicy> +CORBA::Long +TAO::TypeCode::Union<StringType, + TypeCodeType, + CaseArrayType, + RefCountPolicy>::default_index_i ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const +{ + return this->default_index_; +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +#endif /* TAO_UNION_TYPECODE_CPP */ diff --git a/TAO/tao/AnyTypeCode/Union_TypeCode.h b/TAO/tao/AnyTypeCode/Union_TypeCode.h new file mode 100644 index 00000000000..8089aeea48f --- /dev/null +++ b/TAO/tao/AnyTypeCode/Union_TypeCode.h @@ -0,0 +1,182 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Union_TypeCode.h + * + * $Id$ + * + * Header file for a @c tk_union CORBA::TypeCode. + * + * @author Ossama Othman + */ +//============================================================================= + +#ifndef TAO_UNION_TYPECODE_H +#define TAO_UNION_TYPECODE_H + +#include /**/ "ace/pre.h" + +#include "tao/AnyTypeCode/TypeCode.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/AnyTypeCode/TypeCode_Base_Attributes.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + namespace TypeCode + { + + /** + * @class Union + * + * @brief @c CORBA::TypeCode implementation for an OMG IDL + * @c union. + * + * This class implements a @c CORBA::TypeCode for an OMG IDL + * @c union. + */ + template <typename StringType, + typename TypeCodeType, + class CaseArrayType, + class RefCountPolicy> + class Union + : public CORBA::TypeCode, + private RefCountPolicy + { + public: + + /// @typedef Type of individual case array element, not the + /// array itself. + typedef TAO::TypeCode::Case<StringType, TypeCodeType> case_type; + + /// Constructor. + Union (char const * id, + char const * name, +#if defined (__BORLANDC__) && (__BORLANDC__ < 0x572) + // Borland C++ currently can't handle a reference to + // const pointer to const CORBA::TypeCode_ptr + TypeCodeType discriminant_type, +#else + TypeCodeType const & discriminant_type, +#endif + CaseArrayType const & cases, + CORBA::ULong ncases, + CORBA::Long default_index); + + /// Constructor used for recursive TypeCodes. + Union (CORBA::TCKind kind, + char const * id); + + /** + * @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, + CORBA::ULong offset) const; + virtual void tao_duplicate (void); + virtual void tao_release (void); + //@} + + protected: + + /** + * @name @c TAO CORBA::TypeCode Template Methods + * + * @c tk_union @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::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::Any * member_label_i (CORBA::ULong index + ACE_ENV_ARG_DECL) const; + virtual CORBA::TypeCode_ptr discriminator_type_i ( + ACE_ENV_SINGLE_ARG_DECL) const; + virtual CORBA::Long default_index_i (ACE_ENV_SINGLE_ARG_DECL) const; + //@} + + protected: + + /** + * @c Union Attributes + * + * Attributes representing the structure of an OMG IDL + * @c union. + * + * @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 + /// union type. + Base_Attributes<StringType> base_attributes_; + + /// Type of IDL @c union discriminant. + TypeCodeType discriminant_type_; + + /// Index of the default union case. + /** + * This value will be -1 if no default case is found in the + * union. + */ + CORBA::Long default_index_; + + /// The number of cases in the OMG IDL union, excluding the + /// @c default case. + CORBA::ULong ncases_; + + /// Array of @c TAO::TypeCode::Case representing structure of + /// the OMG IDL defined @c union. + CaseArrayType cases_; + + //@} + + }; + + } // End namespace TypeCode +} // End namespace TAO + +TAO_END_VERSIONED_NAMESPACE_DECL + + +#ifdef __ACE_INLINE__ +# include "tao/AnyTypeCode/Union_TypeCode.inl" +#endif /* __ACE_INLINE__ */ + +#ifdef ACE_TEMPLATES_REQUIRE_SOURCE +# include "tao/AnyTypeCode/Union_TypeCode.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#ifdef ACE_TEMPLATES_REQUIRE_PRAGMA +# pragma implementation ("Union_TypeCode.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + + +#include /**/ "ace/post.h" + +#endif /* TAO_UNION_TYPECODE_H */ diff --git a/TAO/tao/AnyTypeCode/Union_TypeCode.inl b/TAO/tao/AnyTypeCode/Union_TypeCode.inl new file mode 100644 index 00000000000..ab001d57baf --- /dev/null +++ b/TAO/tao/AnyTypeCode/Union_TypeCode.inl @@ -0,0 +1,59 @@ +// -*- C++ -*- +// +// $Id$ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +template <typename StringType, + typename TypeCodeType, + class CaseArrayType, + class RefCountPolicy> +ACE_INLINE +TAO::TypeCode::Union<StringType, + TypeCodeType, + CaseArrayType, + RefCountPolicy>::Union ( + char const * id, + char const * name, +#if defined (__BORLANDC__) && (__BORLANDC__ < 0x572) + // Borland C++ currently can't handle a reference to + // const pointer to const CORBA::TypeCode_ptr + TypeCodeType discriminant_type, +#else + TypeCodeType const & discriminant_type, +#endif + CaseArrayType const & cases, + CORBA::ULong ncases, + CORBA::Long default_index) + : ::CORBA::TypeCode (CORBA::tk_union) + , RefCountPolicy () + , base_attributes_ (id, name) + , discriminant_type_ (discriminant_type) + , default_index_ (default_index) + , ncases_ (ncases) + , cases_ (cases) +{ +} + +template <typename StringType, + typename TypeCodeType, + class CaseArrayType, + class RefCountPolicy> +ACE_INLINE +TAO::TypeCode::Union<StringType, + TypeCodeType, + CaseArrayType, + RefCountPolicy>::Union ( + CORBA::TCKind, + char const * id) + : ::CORBA::TypeCode (CORBA::tk_union) + , RefCountPolicy () + , base_attributes_ (id) + , discriminant_type_ (0) + , default_index_ (-1) + , ncases_ (0) + , cases_ () +{ +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/Union_TypeCode_Static.cpp b/TAO/tao/AnyTypeCode/Union_TypeCode_Static.cpp new file mode 100644 index 00000000000..2d5677d317e --- /dev/null +++ b/TAO/tao/AnyTypeCode/Union_TypeCode_Static.cpp @@ -0,0 +1,422 @@ +// $Id$ + +#include "tao/AnyTypeCode/Union_TypeCode_Static.h" +#include "tao/AnyTypeCode/TypeCode_Case_Base_T.h" +#include "tao/AnyTypeCode/Any.h" + +#ifndef __ACE_INLINE__ +# include "tao/AnyTypeCode/Union_TypeCode_Static.inl" +#endif /* !__ACE_INLINE__ */ + +#include "tao/SystemException.h" + +#include "ace/Value_Ptr.h" + + +ACE_RCSID (AnyTypeCode, + Union_TypeCode_Static, + "$Id$") + + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +bool +TAO::TypeCode::Union<char const *, + CORBA::TypeCode_ptr const *, + TAO::TypeCode::Case<char const *, + CORBA::TypeCode_ptr const *> const * const *, + TAO::Null_RefCount_Policy>::tao_marshal ( + TAO_OutputCDR & cdr, + CORBA::ULong offset) const +{ + // A tk_union 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. + TAO_OutputCDR enc; + + // Account for the encoded CDR encapsulation length and byte order. + // + // Aligning on an octet since the next value after the CDR + // encapsulation length will always be the byte order octet/boolean + // in this case. + offset = ACE_align_binary (offset + 4, + ACE_CDR::OCTET_ALIGN); + + bool const success = + (enc << TAO_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER)) + && (enc << TAO_OutputCDR::from_string (this->base_attributes_.id (), 0)) + && (enc << TAO_OutputCDR::from_string (this->base_attributes_.name (), 0)) + && marshal (enc, + Traits<char const *>::get_typecode (this->discriminant_type_), + offset + enc.total_length ()) + && (enc << this->default_index_) + && (enc << this->ncases_); + + if (!success) + return false; + + offset += enc.total_length (); + + // Note that we handle the default case below, too. + + for (CORBA::ULong i = 0; i < this->ncases_; ++i) + { + TAO_OutputCDR case_enc; + offset = ACE_align_binary (offset, + ACE_CDR::LONG_ALIGN); + case_type const & c = *this->cases_[i]; + + if (!c.marshal (case_enc, offset)) + return false; + + offset += case_enc.total_length (); + + if (!enc.write_octet_array_mb (case_enc.begin ())) + return false; + } + + return + cdr << static_cast<CORBA::ULong> (enc.total_length ()) + && cdr.write_octet_array_mb (enc.begin ()); +} + +void +TAO::TypeCode::Union<char const *, + CORBA::TypeCode_ptr const *, + TAO::TypeCode::Case<char const *, + CORBA::TypeCode_ptr const *> const * const *, + TAO::Null_RefCount_Policy>::tao_duplicate (void) +{ +} + +void +TAO::TypeCode::Union<char const *, + CORBA::TypeCode_ptr const *, + TAO::TypeCode::Case<char const *, + CORBA::TypeCode_ptr const *> const * const *, + TAO::Null_RefCount_Policy>::tao_release (void) +{ +} + +CORBA::Boolean +TAO::TypeCode::Union<char const *, + CORBA::TypeCode_ptr const *, + TAO::TypeCode::Case<char const *, + CORBA::TypeCode_ptr const *> const * const *, + TAO::Null_RefCount_Policy>::equal_i ( + CORBA::TypeCode_ptr tc + ACE_ENV_ARG_DECL) const +{ + // These calls shouldn't throw since CORBA::TypeCode::equal() + // verified that the TCKind is the same as our's prior to invoking + // this method, meaning that the CORBA::tk_union TypeCode methods + // are supported. + + CORBA::ULong const tc_count = + tc->member_count (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + CORBA::Long tc_def = tc->default_index (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + if (tc_count != this->ncases_ + || tc_def != this->default_index_) + return false; + + // Check the discriminator type. + CORBA::TypeCode_var tc_discriminator = + tc->discriminator_type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + CORBA::Boolean const equal_discriminators = + Traits<char const *>::get_typecode (this->discriminant_type_)->equal ( + tc_discriminator.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + if (!equal_discriminators) + return false; + + for (CORBA::ULong i = 0; i < this->ncases_; ++i) + { + if (this->default_index_ > -1 + && static_cast<CORBA::ULong> (this->default_index_) == i) + { + // Don't bother checking equality of default case label. It + // will always be the zero octet (the CDR encoded value is + // ignored). + continue; + } + + case_type const & lhs_case = *this->cases_[i]; + + bool const equal_case = + lhs_case.equal (i, + tc + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + if (!equal_case) + return false; + } + + return true; +} + +CORBA::Boolean +TAO::TypeCode::Union<char const *, + CORBA::TypeCode_ptr const *, + TAO::TypeCode::Case<char const *, + CORBA::TypeCode_ptr const *> const * const *, + TAO::Null_RefCount_Policy>::equivalent_i ( + CORBA::TypeCode_ptr tc + ACE_ENV_ARG_DECL) const +{ + // Perform a structural comparison, excluding the name() and + // member_name() operations. + + CORBA::ULong const tc_count = + tc->member_count (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + CORBA::Long tc_def = tc->default_index (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + if (tc_count != this->ncases_ + || tc_def != this->default_index_) + return false; + + CORBA::TypeCode_var tc_discriminator = + tc->discriminator_type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + CORBA::Boolean const equiv_discriminators = + Traits<char const *>::get_typecode (this->discriminant_type_)->equivalent ( + tc_discriminator.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + if (!equiv_discriminators) + return false; + + for (CORBA::ULong i = 0; i < this->ncases_; ++i) + { + if (this->default_index_ > -1 + && static_cast<CORBA::ULong> (this->default_index_) == i) + { + // Don't bother checking equality/equivalence of default + // case label. It will always be the zero octet (the CDR + // encoded value is ignored). + continue; + } + + case_type const & lhs_case = *this->cases_[i]; + + bool const equivalent_case = + lhs_case.equivalent (i, + tc + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + if (!equivalent_case) + return false; + } + + return true; +} + +CORBA::TypeCode_ptr +TAO::TypeCode::Union<char const *, + CORBA::TypeCode_ptr const *, + TAO::TypeCode::Case<char const *, + CORBA::TypeCode_ptr const *> const * const *, + TAO::Null_RefCount_Policy>::get_compact_typecode_i ( + ACE_ENV_SINGLE_ARG_DECL) const +{ +// typedef ACE::Value_Ptr<TAO::TypeCode::Case<CORBA::String_var, +// CORBA::TypeCode_var> > elem_type; + +// ACE_Array_Base<elem_type> tc_cases (this->ncases_); + +// if (this->ncases_ > 0) +// { +// // Dynamically construct a new array of cases stripped of +// // member names. + +// static char const empty_name[] = ""; + +// for (CORBA::ULong i = 0; i < this->ncases_; ++i) +// { +// // Member names will be stripped, i.e. not embedded within +// // the compact TypeCode. +// tc_cases[i].name = empty_name; +// tc_cases[i].type = +// this->cases_[i]->type ()->get_compact_typecode ( +// ACE_ENV_ARG_PARAMETER); +// ACE_CHECK_RETURN (CORBA::TypeCode::_nil ()); +// } +// } + +// // Create the compact union TypeCode. +// 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 ()); +// } + +// return +// adapter->create_union_tc ( +// this->base_attributes_.id (), +// "", /* empty name */ +// Traits<char const *>::get_typecode (this->discriminant_type_), +// tc_cases, +// this->ncases_, +// this->default_index_, +// "", +// Traits<char const *>::get_typecode (this->default_case_.type) +// ACE_ENV_ARG_PARAMETER); +// ACE_CHECK_RETURN (CORBA::TypeCode::_nil ()); + + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), CORBA::TypeCode::_nil ()); +} + +char const * +TAO::TypeCode::Union<char const *, + CORBA::TypeCode_ptr const *, + TAO::TypeCode::Case<char const *, + CORBA::TypeCode_ptr const *> const * const *, + TAO::Null_RefCount_Policy>::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 (); +} + +char const * +TAO::TypeCode::Union<char const *, + CORBA::TypeCode_ptr const *, + TAO::TypeCode::Case<char const *, + CORBA::TypeCode_ptr const *> const * const *, + TAO::Null_RefCount_Policy>::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 (); +} + +CORBA::ULong +TAO::TypeCode::Union<char const *, + CORBA::TypeCode_ptr const *, + TAO::TypeCode::Case<char const *, + CORBA::TypeCode_ptr const *> const * const *, + TAO::Null_RefCount_Policy>::member_count_i ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const +{ + return this->ncases_; +} + +char const * +TAO::TypeCode::Union<char const *, + CORBA::TypeCode_ptr const *, + TAO::TypeCode::Case<char const *, + CORBA::TypeCode_ptr const *> const * const *, + TAO::Null_RefCount_Policy>::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->ncases_) + ACE_THROW_RETURN (CORBA::TypeCode::Bounds (), 0); + + return this->cases_[index]->name (); +} + +CORBA::TypeCode_ptr +TAO::TypeCode::Union<char const *, + CORBA::TypeCode_ptr const *, + TAO::TypeCode::Case<char const *, + CORBA::TypeCode_ptr const *> const * const *, + TAO::Null_RefCount_Policy>::member_type_i ( + CORBA::ULong index + ACE_ENV_ARG_DECL) const +{ + if (index >= this->ncases_) + ACE_THROW_RETURN (CORBA::TypeCode::Bounds (), + CORBA::TypeCode::_nil ()); + + return CORBA::TypeCode::_duplicate (this->cases_[index]->type ()); +} + +CORBA::Any * +TAO::TypeCode::Union<char const *, + CORBA::TypeCode_ptr const *, + TAO::TypeCode::Case<char const *, + CORBA::TypeCode_ptr const *> const * const *, + TAO::Null_RefCount_Policy>::member_label_i ( + CORBA::ULong index + ACE_ENV_ARG_DECL) const +{ + if (index >= this->ncases_) + ACE_THROW_RETURN (CORBA::TypeCode::Bounds (), + 0); + + // Default case. + if (this->default_index_ > -1 + && static_cast<CORBA::ULong> (this->default_index_) == index) + { + CORBA::Any * any = 0; + ACE_NEW_THROW_EX (any, + CORBA::Any, + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (0); + + CORBA::Any_var safe_any (any); + + // Default case's label is a zero octet. + CORBA::Any::from_octet const zero_octet (0); + + // Default case/member has a zero octet label value. + (*any) <<= zero_octet; + + return safe_any._retn (); + } + + // Non-default cases. + return this->cases_[index]->label (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +CORBA::TypeCode_ptr +TAO::TypeCode::Union<char const *, + CORBA::TypeCode_ptr const *, + TAO::TypeCode::Case<char const *, + CORBA::TypeCode_ptr const *> const * const *, + TAO::Null_RefCount_Policy>::discriminator_type_i ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const +{ + return + CORBA::TypeCode::_duplicate ( + Traits<char const *>::get_typecode (this->discriminant_type_)); +} + +CORBA::Long +TAO::TypeCode::Union<char const *, + CORBA::TypeCode_ptr const *, + TAO::TypeCode::Case<char const *, + CORBA::TypeCode_ptr const *> const * const *, + TAO::Null_RefCount_Policy>::default_index_i ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const +{ + return this->default_index_; +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/Union_TypeCode_Static.h b/TAO/tao/AnyTypeCode/Union_TypeCode_Static.h new file mode 100644 index 00000000000..bf58345e03f --- /dev/null +++ b/TAO/tao/AnyTypeCode/Union_TypeCode_Static.h @@ -0,0 +1,171 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Union_TypeCode_Static.h + * + * $Id$ + * + * Header file for a static @c tk_union CORBA::TypeCode. + * + * @author Ossama Othman + */ +//============================================================================= + +#ifndef TAO_UNION_TYPECODE_STATIC_H +#define TAO_UNION_TYPECODE_STATIC_H + +#include /**/ "ace/pre.h" + +#include "tao/AnyTypeCode/TypeCode.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/AnyTypeCode/TypeCode_Base_Attributes.h" +#include "tao/AnyTypeCode/Null_RefCount_Policy.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + namespace TypeCode + { + template <typename StringType, + typename TypeCodeType, + class CaseArrayType, + class RefCountPolicy> class Union; + template <typename StringType, typename TypeCodeType> class Case; + /** + * @class Union + * + * @brief @c CORBA::TypeCode implementation for an OMG IDL + * @c union. + * + * This class implements a @c CORBA::TypeCode for an OMG IDL + * @c union. + */ + template<> + class TAO_AnyTypeCode_Export Union<char const *, + CORBA::TypeCode_ptr const *, + Case<char const *, + CORBA::TypeCode_ptr const *> const * const *, + TAO::Null_RefCount_Policy> + : public CORBA::TypeCode, + private TAO::Null_RefCount_Policy + { + public: + + /// @typedef Type of individual case array element, not the + /// array itself. + typedef TAO::TypeCode::Case<char const *, + CORBA::TypeCode_ptr const *> case_type; + + /// Constructor. + Union (char const * id, + char const * name, + CORBA::TypeCode_ptr const * discriminant_type, + Case<char const *, + CORBA::TypeCode_ptr const *> const * const * cases, + CORBA::ULong ncases, + CORBA::Long default_index); + + /** + * @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, + CORBA::ULong offset) const; + virtual void tao_duplicate (void); + virtual void tao_release (void); + //@} + + protected: + + /** + * @name @c TAO CORBA::TypeCode Template Methods + * + * @c tk_union @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::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::Any * member_label_i (CORBA::ULong index + ACE_ENV_ARG_DECL) const; + virtual CORBA::TypeCode_ptr discriminator_type_i ( + ACE_ENV_SINGLE_ARG_DECL) const; + virtual CORBA::Long default_index_i (ACE_ENV_SINGLE_ARG_DECL) const; + //@} + + private: + + /** + * @c Union Attributes + * + * Attributes representing the structure of an OMG IDL + * @c union. + * + * @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 + /// union type. + Base_Attributes<char const *> const base_attributes_; + + /// Type of IDL @c union discriminant. + CORBA::TypeCode_ptr const * const discriminant_type_; + + /// Index of the default union case. + /** + * This value will be -1 if no default case is found in the + * union. + */ + CORBA::Long const default_index_; + + /// The number of cases in the OMG IDL union, excluding the + /// @c default case. + CORBA::ULong const ncases_; + + /// Array of @c TAO::TypeCode::Case representing structure of + /// the OMG IDL defined @c union. + Case<char const *, + CORBA::TypeCode_ptr const *> const * const * const cases_; + + //@} + + }; + + } // End namespace TypeCode +} // End namespace TAO + +TAO_END_VERSIONED_NAMESPACE_DECL + +#ifdef __ACE_INLINE__ +# include "tao/AnyTypeCode/Union_TypeCode_Static.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" + +#endif /* TAO_UNION_TYPECODE_STATIC_H */ diff --git a/TAO/tao/AnyTypeCode/Union_TypeCode_Static.inl b/TAO/tao/AnyTypeCode/Union_TypeCode_Static.inl new file mode 100644 index 00000000000..39b9465a2da --- /dev/null +++ b/TAO/tao/AnyTypeCode/Union_TypeCode_Static.inl @@ -0,0 +1,29 @@ +// -*- C++ -*- +// +// $Id$ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE +TAO::TypeCode::Union<char const *, + CORBA::TypeCode_ptr const *, + TAO::TypeCode::Case<char const *, + CORBA::TypeCode_ptr const *> const * const *, + TAO::Null_RefCount_Policy>::Union ( + char const * id, + char const * name, + CORBA::TypeCode_ptr const * discriminant_type, + Case<char const *, CORBA::TypeCode_ptr const *> const * const * cases, + CORBA::ULong ncases, + CORBA::Long default_index) + : ::CORBA::TypeCode (CORBA::tk_union) + , ::TAO::Null_RefCount_Policy () + , base_attributes_ (id, name) + , discriminant_type_ (discriminant_type) + , default_index_ (default_index) + , ncases_ (ncases) + , cases_ (cases) +{ +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/ValueModifier.pidl b/TAO/tao/AnyTypeCode/ValueModifier.pidl new file mode 100644 index 00000000000..794ac4af092 --- /dev/null +++ b/TAO/tao/AnyTypeCode/ValueModifier.pidl @@ -0,0 +1,38 @@ +// -*- IDL -*- + +// ================================================================ +/** + * @file ValueModifier.pidl + * + * $Id$ + * + * This file was used to generate the code in ValueModifierC.* The command + * used to generate code is: + * + * tao_idl + * -o orig -Ge 1 -SS -Sci -St + * -Wb,export_macro=TAO_Export + * -Wb,export_include="tao/TAO_Export.h" + * -Wb,pre_include="ace/pre.h" + * -Wb,post_include="ace/post.h" + * -Wb,versioning_begin=TAO_BEGIN_VERSIONED_NAMESPACE_DECL + * -Wb,versioning_end=TAO_END_VERSIONED_NAMESPACE_DECL + * ValueModifier.pidl + */ +// ================================================================ + +#ifndef TAO_VALUEMODIFIER_PIDL +#define TAO_VALUEMODIFIER_PIDL + +#pragma prefix "omg.org" + +module CORBA +{ + typedef short ValueModifier; + const ValueModifier VM_NONE = 0; + const ValueModifier VM_CUSTOM = 1; + const ValueModifier VM_ABSTRACT = 2; + const ValueModifier VM_TRUNCATABLE = 3; +}; + +#endif /* TAO_VALUEMODIFIER_PIDL */ diff --git a/TAO/tao/AnyTypeCode/Value_TypeCode.cpp b/TAO/tao/AnyTypeCode/Value_TypeCode.cpp new file mode 100644 index 00000000000..8955d4be01b --- /dev/null +++ b/TAO/tao/AnyTypeCode/Value_TypeCode.cpp @@ -0,0 +1,465 @@ +// $Id$ + +#ifndef TAO_VALUE_TYPECODE_CPP +#define TAO_VALUE_TYPECODE_CPP + +#include "tao/AnyTypeCode/Value_TypeCode.h" +#include "tao/AnyTypeCode/TypeCode_Value_Field.h" +#include "tao/CDR.h" + +#include "tao/ORB_Core.h" +#include "tao/TypeCodeFactory_Adapter.h" + +#include "ace/Dynamic_Service.h" + +#ifndef __ACE_INLINE__ +# include "tao/AnyTypeCode/Value_TypeCode.inl" +#endif /* !__ACE_INLINE__ */ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +template <typename StringType, + typename TypeCodeType, + class FieldArrayType, + class RefCountPolicy> +bool +TAO::TypeCode::Value<StringType, + TypeCodeType, + FieldArrayType, + RefCountPolicy>::tao_marshal ( + TAO_OutputCDR & cdr, + CORBA::ULong offset) 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. + TAO_OutputCDR enc; + + // Account for the encoded CDR encapsulation length and byte order. + // + // Aligning on an octet since the next value after the CDR + // encapsulation length will always be the byte order octet/boolean + // in this case. + offset = ACE_align_binary (offset + 4, + ACE_CDR::OCTET_ALIGN); + + bool const success = + (enc << TAO_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER)) + && (enc << TAO_OutputCDR::from_string (this->base_attributes_.id (), 0)) + && (enc << TAO_OutputCDR::from_string (this->base_attributes_.name (), 0)) + && (enc << this->type_modifier_) + && marshal (enc, + Traits<StringType>::get_typecode (this->concrete_base_), + offset + enc.total_length ()) + && (enc << this->nfields_); + + if (!success) + return false; + + Value_Field<StringType, TypeCodeType> const * const begin = + &this->fields_[0]; + Value_Field<StringType, TypeCodeType> const * const end = + begin + this->nfields_; + + for (Value_Field<StringType, TypeCodeType> const * i = begin; i != end; ++i) + { + Value_Field<StringType, TypeCodeType> const & field = *i; + + if (!(enc << Traits<StringType>::get_string (field.name)) + || !marshal (enc, + Traits<StringType>::get_typecode (field.type), + offset + enc.total_length ()) + || !(enc << field.visibility)) + return false; + } + + return + cdr << static_cast<CORBA::ULong> (enc.total_length ()) + && cdr.write_octet_array_mb (enc.begin ()); +} + +template <typename StringType, + typename TypeCodeType, + class FieldArrayType, + class RefCountPolicy> +void +TAO::TypeCode::Value<StringType, + TypeCodeType, + FieldArrayType, + RefCountPolicy>::tao_duplicate (void) +{ + this->RefCountPolicy::add_ref (); +} + +template <typename StringType, + typename TypeCodeType, + class FieldArrayType, + class RefCountPolicy> +void +TAO::TypeCode::Value<StringType, + TypeCodeType, + FieldArrayType, + RefCountPolicy>::tao_release (void) +{ + this->RefCountPolicy::remove_ref (); +} + +template <typename StringType, + typename TypeCodeType, + class FieldArrayType, + class RefCountPolicy> +CORBA::Boolean +TAO::TypeCode::Value<StringType, + TypeCodeType, + FieldArrayType, + RefCountPolicy>::equal_i ( + CORBA::TypeCode_ptr tc + ACE_ENV_ARG_DECL) const +{ + // None of these calls should throw since CORBA::TypeCode::equal() + // verified that the TCKind is the same as our's prior to invoking + // this method. + + CORBA::ValueModifier const tc_type_modifier = + tc->type_modifier (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + if (tc_type_modifier != this->type_modifier_) + return false; + + CORBA::TypeCode_var rhs_concrete_base_type = + tc->concrete_base_type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + CORBA::Boolean const equal_concrete_base_types = + this->equal (rhs_concrete_base_type.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + if (!equal_concrete_base_types) + return false; + + CORBA::ULong const tc_nfields = + tc->member_count (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + if (tc_nfields != this->nfields_) + return false; + + for (CORBA::ULong i = 0; i < this->nfields_; ++i) + { + Value_Field<StringType, TypeCodeType> const & lhs_field = + this->fields_[i]; + + CORBA::Visibility const lhs_visibility = lhs_field.visibility; + CORBA::Visibility const rhs_visibility = + tc->member_visibility (i + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + if (lhs_visibility != rhs_visibility) + return false; + + char const * const lhs_name = + Traits<StringType>::get_string (lhs_field.name);; + char const * const rhs_name = tc->member_name (i + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + if (ACE_OS::strcmp (lhs_name, rhs_name) != 0) + return false; + + CORBA::TypeCode_ptr const lhs_tc = + Traits<StringType>::get_typecode (lhs_field.type); + CORBA::TypeCode_var const rhs_tc = + tc->member_type (i + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + CORBA::Boolean const equal_members = + lhs_tc->equal (rhs_tc.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + if (!equal_members) + return false; + } + + return true; +} + +template <typename StringType, + typename TypeCodeType, + class FieldArrayType, + class RefCountPolicy> +CORBA::Boolean +TAO::TypeCode::Value<StringType, + TypeCodeType, + FieldArrayType, + RefCountPolicy>::equivalent_i ( + CORBA::TypeCode_ptr tc + ACE_ENV_ARG_DECL) const +{ + CORBA::ValueModifier const tc_type_modifier = + tc->type_modifier (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + if (tc_type_modifier != this->type_modifier_) + return false; + + CORBA::TypeCode_var rhs_concrete_base_type = + tc->concrete_base_type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + CORBA::Boolean const equivalent_concrete_base_types = + this->equivalent (rhs_concrete_base_type.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + if (!equivalent_concrete_base_types) + return false; + + // 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 (false); + + if (tc_nfields != this->nfields_) + return false; + + for (CORBA::ULong i = 0; i < this->nfields_; ++i) + { + Value_Field<StringType, TypeCodeType> const & lhs_field = + this->fields_[i]; + + CORBA::Visibility const lhs_visibility = + lhs_field.visibility; + CORBA::Visibility const rhs_visibility = + tc->member_visibility (i + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + if (lhs_visibility != rhs_visibility) + return false; + + CORBA::TypeCode_ptr const lhs_tc = + Traits<StringType>::get_typecode (lhs_field.type); + CORBA::TypeCode_var const rhs_tc = + tc->member_type (i + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + CORBA::Boolean const equiv_types = + lhs_tc->equivalent (rhs_tc.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + if (!equiv_types) + return false; + } + + return true; +} + +template <typename StringType, + typename TypeCodeType, + class FieldArrayType, + class RefCountPolicy> +CORBA::TypeCode_ptr +TAO::TypeCode::Value<StringType, + TypeCodeType, + FieldArrayType, + RefCountPolicy>::get_compact_typecode_i ( + ACE_ENV_SINGLE_ARG_DECL) const +{ + ACE_Array_Base<Value_Field<CORBA::String_var, CORBA::TypeCode_var> > + tc_fields (this->nfields_); + + if (this->nfields_ > 0) + { + // Dynamically construct a new array of fields stripped of + // member names. + + static char 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 = + Traits<StringType>::get_typecode ( + this->fields_[i].type)->get_compact_typecode ( + ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (CORBA::TypeCode::_nil ()); + tc_fields[i].visibility = this->fields_[i].visibility; + } + } + + TAO_TypeCodeFactory_Adapter * const 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 ()); + } + + return + adapter->create_value_event_tc ( + this->kind_, + this->base_attributes_.id (), + "", // empty name + this->type_modifier_, + Traits<StringType>::get_typecode (this->concrete_base_), + tc_fields, + this->nfields_ + ACE_ENV_ARG_PARAMETER); +} + +template <typename StringType, + typename TypeCodeType, + class FieldArrayType, + class RefCountPolicy> +char const * +TAO::TypeCode::Value<StringType, + TypeCodeType, + FieldArrayType, + 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, + typename TypeCodeType, + class FieldArrayType, + class RefCountPolicy> +char const * +TAO::TypeCode::Value<StringType, + TypeCodeType, + FieldArrayType, + 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, + typename TypeCodeType, + class FieldArrayType, + class RefCountPolicy> +CORBA::ULong +TAO::TypeCode::Value<StringType, + TypeCodeType, + FieldArrayType, + RefCountPolicy>::member_count_i ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const +{ + return this->nfields_; +} + +template <typename StringType, + typename TypeCodeType, + class FieldArrayType, + class RefCountPolicy> +char const * +TAO::TypeCode::Value<StringType, + TypeCodeType, + FieldArrayType, + 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 Traits<StringType>::get_string (this->fields_[index].name); +} + +template <typename StringType, + typename TypeCodeType, + class FieldArrayType, + class RefCountPolicy> +CORBA::TypeCode_ptr +TAO::TypeCode::Value<StringType, + TypeCodeType, + FieldArrayType, + 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 ( + Traits<StringType>::get_typecode (this->fields_[index].type)); +} + +template <typename StringType, + typename TypeCodeType, + class FieldArrayType, + class RefCountPolicy> +CORBA::Visibility +TAO::TypeCode::Value<StringType, + TypeCodeType, + FieldArrayType, + RefCountPolicy>::member_visibility_i ( + CORBA::ULong index + ACE_ENV_ARG_DECL) const +{ + if (index >= this->nfields_) + ACE_THROW_RETURN (CORBA::TypeCode::Bounds (), + CORBA::PRIVATE_MEMBER); + + return this->fields_[index].visibility; +} + +template <typename StringType, + typename TypeCodeType, + class FieldArrayType, + class RefCountPolicy> +CORBA::ValueModifier +TAO::TypeCode::Value<StringType, + TypeCodeType, + FieldArrayType, + RefCountPolicy>::type_modifier_i ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const +{ + return this->type_modifier_; +} + +template <typename StringType, + typename TypeCodeType, + class FieldArrayType, + class RefCountPolicy> +CORBA::TypeCode_ptr +TAO::TypeCode::Value<StringType, + TypeCodeType, + FieldArrayType, + RefCountPolicy>::concrete_base_type_i ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const +{ + return + CORBA::TypeCode::_duplicate ( + Traits<StringType>::get_typecode (this->concrete_base_)); +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +#endif /* TAO_VALUE_TYPECODE_CPP */ diff --git a/TAO/tao/AnyTypeCode/Value_TypeCode.h b/TAO/tao/AnyTypeCode/Value_TypeCode.h new file mode 100644 index 00000000000..ffc18532e6f --- /dev/null +++ b/TAO/tao/AnyTypeCode/Value_TypeCode.h @@ -0,0 +1,181 @@ +// -*- 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> + */ +//============================================================================= + +#ifndef TAO_VALUE_TYPECODE_H +#define TAO_VALUE_TYPECODE_H + +#include /**/ "ace/pre.h" + +#include "tao/AnyTypeCode/TypeCode.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/AnyTypeCode/TypeCode_Base_Attributes.h" +#include "tao/AnyTypeCode/ValueModifierC.h" +#include "tao/AnyTypeCode/VisibilityC.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + namespace TypeCode + { + template<typename StringType, typename TypeCodeType> struct Value_Field; + + /** + * @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, + typename TypeCodeType, + class FieldArrayType, + class RefCountPolicy> + class Value + : public CORBA::TypeCode, + private RefCountPolicy + { + public: + + /// Constructor. + Value (CORBA::TCKind kind, + char const * id, + char const * name, + CORBA::ValueModifier modifier, +#if defined (__BORLANDC__) && (__BORLANDC__ < 0x572) + // Borland C++ currently can't handle a reference to + // const pointer to const CORBA::TypeCode_ptr + TypeCodeType concrete_base, +#else + TypeCodeType const & concrete_base, +#endif + FieldArrayType const & fields, + CORBA::ULong nfields); + + /// Constructor used for recursive TypeCodes. + Value (CORBA::TCKind kind, + char const * id); + + /** + * @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, + CORBA::ULong offset) 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::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 (CORBA::ULong index + ACE_ENV_ARG_DECL) const; + virtual CORBA::ValueModifier type_modifier_i ( + ACE_ENV_SINGLE_ARG_DECL) const; + virtual CORBA::TypeCode_ptr concrete_base_type_i ( + ACE_ENV_SINGLE_ARG_DECL) const; + //@} + + protected: + + /** + * @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> base_attributes_; + + /// The @c ValueModifier of the @c valuetype of @c eventtype + /// represented by this @c TypeCode. + CORBA::ValueModifier type_modifier_; + + /// The @c TypeCode corresponding to the concrete base + /// @c valuetype or @c eventtype. + TypeCodeType concrete_base_; + + /// The number of fields in the OMG IDL value. + CORBA::ULong nfields_; + + /// Array of @c TAO::TypeCode fields representing structure of the + /// OMG IDL defined @c value. + FieldArrayType fields_; + + //@} + + }; + + } // End namespace TypeCode +} // End namespace TAO + +TAO_END_VERSIONED_NAMESPACE_DECL + +#ifdef __ACE_INLINE__ +# include "tao/AnyTypeCode/Value_TypeCode.inl" +#endif /* __ACE_INLINE__ */ + +#ifdef ACE_TEMPLATES_REQUIRE_SOURCE +# include "tao/AnyTypeCode/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/AnyTypeCode/Value_TypeCode.inl b/TAO/tao/AnyTypeCode/Value_TypeCode.inl new file mode 100644 index 00000000000..e5b0b3ab2f1 --- /dev/null +++ b/TAO/tao/AnyTypeCode/Value_TypeCode.inl @@ -0,0 +1,60 @@ +// -*- C++ -*- +// +// $Id$ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +template <typename StringType, + typename TypeCodeType, + class FieldArrayType, + class RefCountPolicy> +ACE_INLINE +TAO::TypeCode::Value<StringType, + TypeCodeType, + FieldArrayType, + RefCountPolicy>::Value ( + CORBA::TCKind kind, + char const * id, + char const * name, + CORBA::ValueModifier modifier, +#if defined (__BORLANDC__) && (__BORLANDC__ < 0x572) + // Borland C++ currently can't handle a reference to + // const pointer to const CORBA::TypeCode_ptr + TypeCodeType concrete_base, +#else + TypeCodeType const & concrete_base, +#endif + FieldArrayType const & fields, + CORBA::ULong nfields) + : ::CORBA::TypeCode (kind) + , RefCountPolicy () + , base_attributes_ (id, name) + , type_modifier_ (modifier) + , concrete_base_ (concrete_base) + , nfields_ (nfields) + , fields_ (fields) +{ +} + +template <typename StringType, + typename TypeCodeType, + class FieldArrayType, + class RefCountPolicy> +ACE_INLINE +TAO::TypeCode::Value<StringType, + TypeCodeType, + FieldArrayType, + RefCountPolicy>::Value ( + CORBA::TCKind kind, + char const * id) + : ::CORBA::TypeCode (kind) + , RefCountPolicy () + , base_attributes_ (id) + , type_modifier_ (CORBA::VM_NONE) + , concrete_base_ () + , nfields_ (0) + , fields_ () +{ +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/Value_TypeCode_Static.cpp b/TAO/tao/AnyTypeCode/Value_TypeCode_Static.cpp new file mode 100644 index 00000000000..f8f661e4bdc --- /dev/null +++ b/TAO/tao/AnyTypeCode/Value_TypeCode_Static.cpp @@ -0,0 +1,425 @@ +// $Id$ + +#include "tao/AnyTypeCode/Value_TypeCode_Static.h" +#include "tao/AnyTypeCode/TypeCode_Value_Field.h" +#include "tao/CDR.h" + +#include "tao/ORB_Core.h" +#include "tao/TypeCodeFactory_Adapter.h" + +#include "ace/Dynamic_Service.h" + +#ifndef __ACE_INLINE__ +# include "tao/AnyTypeCode/Value_TypeCode_Static.inl" +#endif /* !__ACE_INLINE__ */ + + +ACE_RCSID (AnyTypeCode, + Value_TypeCode_Static, + "$Id$") + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +bool +TAO::TypeCode::Value<char const *, + CORBA::TypeCode_ptr const *, + TAO::TypeCode::Value_Field<char const *, + CORBA::TypeCode_ptr const *> const *, + TAO::Null_RefCount_Policy>::tao_marshal ( + TAO_OutputCDR & cdr, + CORBA::ULong offset) 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. + TAO_OutputCDR enc; + + // Account for the encoded CDR encapsulation length and byte order. + // + // Aligning on an octet since the next value after the CDR + // encapsulation length will always be the byte order octet/boolean + // in this case. + offset = ACE_align_binary (offset + 4, + ACE_CDR::OCTET_ALIGN); + + bool const success = + (enc << TAO_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER)) + && (enc << TAO_OutputCDR::from_string (this->base_attributes_.id (), 0)) + && (enc << TAO_OutputCDR::from_string (this->base_attributes_.name (), 0)) + && (enc << this->type_modifier_) + && marshal (enc, + Traits<char const *>::get_typecode (this->concrete_base_), + offset + enc.total_length ()) + && (enc << this->nfields_); + + if (!success) + return false; + + Value_Field<char const *, CORBA::TypeCode_ptr const *> const * const begin = + &this->fields_[0]; + Value_Field<char const *, CORBA::TypeCode_ptr const *> const * const end = + begin + this->nfields_; + + for (Value_Field<char const *, CORBA::TypeCode_ptr const *> const * i = + begin; + i != end; + ++i) + { + Value_Field<char const *, CORBA::TypeCode_ptr const *> const & field = *i; + + if (!(enc << Traits<char const *>::get_string (field.name)) + || !marshal (enc, + Traits<char const *>::get_typecode (field.type), + offset + enc.total_length ()) + || !(enc << field.visibility)) + return false; + } + + return + cdr << static_cast<CORBA::ULong> (enc.total_length ()) + && cdr.write_octet_array_mb (enc.begin ()); +} + +void +TAO::TypeCode::Value<char const *, + CORBA::TypeCode_ptr const *, + TAO::TypeCode::Value_Field<char const *, + CORBA::TypeCode_ptr const *> const *, + TAO::Null_RefCount_Policy>::tao_duplicate (void) +{ +} + +void +TAO::TypeCode::Value<char const *, + CORBA::TypeCode_ptr const *, + TAO::TypeCode::Value_Field<char const *, + CORBA::TypeCode_ptr const *> const *, + TAO::Null_RefCount_Policy>::tao_release (void) +{ +} + +CORBA::Boolean +TAO::TypeCode::Value<char const *, + CORBA::TypeCode_ptr const *, + TAO::TypeCode::Value_Field<char const *, + CORBA::TypeCode_ptr const *> const *, + TAO::Null_RefCount_Policy>::equal_i ( + CORBA::TypeCode_ptr tc + ACE_ENV_ARG_DECL) const +{ + // None of these calls should throw since CORBA::TypeCode::equal() + // verified that the TCKind is the same as our's prior to invoking + // this method. + + CORBA::ValueModifier const tc_type_modifier = + tc->type_modifier (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + if (tc_type_modifier != this->type_modifier_) + return false; + + CORBA::TypeCode_var rhs_concrete_base_type = + tc->concrete_base_type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + CORBA::Boolean const equal_concrete_base_types = + this->equal (rhs_concrete_base_type.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + if (!equal_concrete_base_types) + return false; + + CORBA::ULong const tc_nfields = + tc->member_count (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + if (tc_nfields != this->nfields_) + return false; + + for (CORBA::ULong i = 0; i < this->nfields_; ++i) + { + Value_Field<char const *, CORBA::TypeCode_ptr const *> const & lhs_field = + this->fields_[i]; + + CORBA::Visibility const lhs_visibility = lhs_field.visibility; + CORBA::Visibility const rhs_visibility = + tc->member_visibility (i + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + if (lhs_visibility != rhs_visibility) + return false; + + char const * const lhs_name = + Traits<char const *>::get_string (lhs_field.name);; + char const * const rhs_name = tc->member_name (i + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + if (ACE_OS::strcmp (lhs_name, rhs_name) != 0) + return false; + + CORBA::TypeCode_ptr const lhs_tc = + Traits<char const *>::get_typecode (lhs_field.type); + CORBA::TypeCode_var const rhs_tc = + tc->member_type (i + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + CORBA::Boolean const equal_members = + lhs_tc->equal (rhs_tc.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + if (!equal_members) + return false; + } + + return true; +} + +CORBA::Boolean +TAO::TypeCode::Value<char const *, + CORBA::TypeCode_ptr const *, + TAO::TypeCode::Value_Field<char const *, + CORBA::TypeCode_ptr const *> const *, + TAO::Null_RefCount_Policy>::equivalent_i ( + CORBA::TypeCode_ptr tc + ACE_ENV_ARG_DECL) const +{ + CORBA::ValueModifier const tc_type_modifier = + tc->type_modifier (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + if (tc_type_modifier != this->type_modifier_) + return false; + + CORBA::TypeCode_var rhs_concrete_base_type = + tc->concrete_base_type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + CORBA::Boolean const equivalent_concrete_base_types = + this->equivalent (rhs_concrete_base_type.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + if (!equivalent_concrete_base_types) + return false; + + // 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 (false); + + if (tc_nfields != this->nfields_) + return false; + + for (CORBA::ULong i = 0; i < this->nfields_; ++i) + { + Value_Field<char const *, + CORBA::TypeCode_ptr const *> const & lhs_field = + this->fields_[i]; + + CORBA::Visibility const lhs_visibility = + lhs_field.visibility; + CORBA::Visibility const rhs_visibility = + tc->member_visibility (i + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + if (lhs_visibility != rhs_visibility) + return false; + + CORBA::TypeCode_ptr const lhs_tc = + Traits<char const *>::get_typecode (lhs_field.type); + CORBA::TypeCode_var const rhs_tc = + tc->member_type (i + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + CORBA::Boolean const equiv_types = + lhs_tc->equivalent (rhs_tc.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (false); + + if (!equiv_types) + return false; + } + + return true; +} + +CORBA::TypeCode_ptr +TAO::TypeCode::Value<char const *, + CORBA::TypeCode_ptr const *, + TAO::TypeCode::Value_Field<char const *, + CORBA::TypeCode_ptr const *> const *, + TAO::Null_RefCount_Policy>::get_compact_typecode_i ( + ACE_ENV_SINGLE_ARG_DECL) const +{ + ACE_Array_Base<Value_Field<CORBA::String_var, CORBA::TypeCode_var> > + tc_fields (this->nfields_); + + if (this->nfields_ > 0) + { + // Dynamically construct a new array of fields stripped of + // member names. + + static char 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 = + Traits<char const *>::get_typecode ( + this->fields_[i].type)->get_compact_typecode ( + ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (CORBA::TypeCode::_nil ()); + tc_fields[i].visibility = this->fields_[i].visibility; + } + } + + TAO_TypeCodeFactory_Adapter * const 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 ()); + } + + return + adapter->create_value_event_tc ( + this->kind_, + this->base_attributes_.id (), + "", // empty name + this->type_modifier_, + Traits<char const *>::get_typecode (this->concrete_base_), + tc_fields, + this->nfields_ + ACE_ENV_ARG_PARAMETER); +} + +char const * +TAO::TypeCode::Value<char const *, + CORBA::TypeCode_ptr const *, + TAO::TypeCode::Value_Field<char const *, + CORBA::TypeCode_ptr const *> const *, + TAO::Null_RefCount_Policy>::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 (); +} + +char const * +TAO::TypeCode::Value<char const *, + CORBA::TypeCode_ptr const *, + TAO::TypeCode::Value_Field<char const *, + CORBA::TypeCode_ptr const *> const *, + TAO::Null_RefCount_Policy>::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 (); +} + +CORBA::ULong +TAO::TypeCode::Value<char const *, + CORBA::TypeCode_ptr const *, + TAO::TypeCode::Value_Field<char const *, + CORBA::TypeCode_ptr const *> const *, + TAO::Null_RefCount_Policy>::member_count_i ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const +{ + return this->nfields_; +} + +char const * +TAO::TypeCode::Value<char const *, + CORBA::TypeCode_ptr const *, + TAO::TypeCode::Value_Field<char const *, + CORBA::TypeCode_ptr const *> const *, + TAO::Null_RefCount_Policy>::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 Traits<char const *>::get_string (this->fields_[index].name); +} + +CORBA::TypeCode_ptr +TAO::TypeCode::Value<char const *, + CORBA::TypeCode_ptr const *, + TAO::TypeCode::Value_Field<char const *, + CORBA::TypeCode_ptr const *> const *, + TAO::Null_RefCount_Policy>::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 ( + Traits<char const *>::get_typecode (this->fields_[index].type)); +} + +CORBA::Visibility +TAO::TypeCode::Value<char const *, + CORBA::TypeCode_ptr const *, + TAO::TypeCode::Value_Field<char const *, + CORBA::TypeCode_ptr const *> const *, + TAO::Null_RefCount_Policy>::member_visibility_i ( + CORBA::ULong index + ACE_ENV_ARG_DECL) const +{ + if (index >= this->nfields_) + ACE_THROW_RETURN (CORBA::TypeCode::Bounds (), + CORBA::PRIVATE_MEMBER); + + return this->fields_[index].visibility; +} + +CORBA::ValueModifier +TAO::TypeCode::Value<char const *, + CORBA::TypeCode_ptr const *, + TAO::TypeCode::Value_Field<char const *, + CORBA::TypeCode_ptr const *> const *, + TAO::Null_RefCount_Policy>::type_modifier_i ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const +{ + return this->type_modifier_; +} + +CORBA::TypeCode_ptr +TAO::TypeCode::Value<char const *, + CORBA::TypeCode_ptr const *, + TAO::TypeCode::Value_Field<char const *, + CORBA::TypeCode_ptr const *> const *, + TAO::Null_RefCount_Policy>::concrete_base_type_i ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) const +{ + return + CORBA::TypeCode::_duplicate ( + Traits<char const *>::get_typecode (this->concrete_base_)); +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/Value_TypeCode_Static.h b/TAO/tao/AnyTypeCode/Value_TypeCode_Static.h new file mode 100644 index 00000000000..57ba318ab03 --- /dev/null +++ b/TAO/tao/AnyTypeCode/Value_TypeCode_Static.h @@ -0,0 +1,170 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Value_TypeCode_Static.h + * + * $Id$ + * + * Header file for static @c tk_value and @c tk_event + * @c CORBA::TypeCodes. + * + * @author Ossama Othman <ossama@dre.vanderbilt.edu> + */ +//============================================================================= + +#ifndef TAO_VALUE_TYPECODE_STATIC_H +#define TAO_VALUE_TYPECODE_STATIC_H + +#include /**/ "ace/pre.h" + +#include "tao/AnyTypeCode/TypeCode.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/AnyTypeCode/TypeCode_Base_Attributes.h" +#include "tao/AnyTypeCode/ValueModifierC.h" +#include "tao/AnyTypeCode/VisibilityC.h" +#include "tao/AnyTypeCode/Null_RefCount_Policy.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + namespace TypeCode + { + template<typename StringType, typename TypeCodeType> struct Value_Field; + template <typename StringType, + typename TypeCodeType, + class FieldArrayType, + class RefCountPolicy> class Value; + + /** + * @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<> + class TAO_AnyTypeCode_Export Value<char const *, + CORBA::TypeCode_ptr const *, + Value_Field<char const *, + CORBA::TypeCode_ptr const *> const *, + TAO::Null_RefCount_Policy> + : public CORBA::TypeCode, + private TAO::Null_RefCount_Policy + { + public: + + /// Constructor. + Value (CORBA::TCKind kind, + char const * id, + char const * name, + CORBA::ValueModifier modifier, + CORBA::TypeCode_ptr const * concrete_base, + Value_Field<char const *, + CORBA::TypeCode_ptr const *> 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, + CORBA::ULong offset) 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::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 (CORBA::ULong index + ACE_ENV_ARG_DECL) const; + virtual CORBA::ValueModifier type_modifier_i ( + ACE_ENV_SINGLE_ARG_DECL) const; + virtual CORBA::TypeCode_ptr concrete_base_type_i ( + ACE_ENV_SINGLE_ARG_DECL) 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<char const *> const base_attributes_; + + /// The @c ValueModifier of the @c valuetype of @c eventtype + /// represented by this @c TypeCode. + CORBA::ValueModifier const type_modifier_; + + /// The @c TypeCode corresponding to the concrete base + /// @c valuetype or @c eventtype. + CORBA::TypeCode_ptr const * 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. + Value_Field<char const *, + CORBA::TypeCode_ptr const *> const * const fields_; + + //@} + + }; + + } // End namespace TypeCode +} // End namespace TAO + +TAO_END_VERSIONED_NAMESPACE_DECL + +#ifdef __ACE_INLINE__ +# include "tao/AnyTypeCode/Value_TypeCode_Static.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" + +#endif /* TAO_VALUE_TYPECODE_STATIC_H */ diff --git a/TAO/tao/AnyTypeCode/Value_TypeCode_Static.inl b/TAO/tao/AnyTypeCode/Value_TypeCode_Static.inl new file mode 100644 index 00000000000..c35fbce0b42 --- /dev/null +++ b/TAO/tao/AnyTypeCode/Value_TypeCode_Static.inl @@ -0,0 +1,30 @@ +// -*- C++ -*- +// +// $Id$ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE +TAO::TypeCode::Value<char const *, + CORBA::TypeCode_ptr const *, + TAO::TypeCode::Value_Field<char const *, + CORBA::TypeCode_ptr const *> const *, + TAO::Null_RefCount_Policy>::Value ( + CORBA::TCKind kind, + char const * id, + char const * name, + CORBA::ValueModifier modifier, + CORBA::TypeCode_ptr const * concrete_base, + Value_Field<char const *, CORBA::TypeCode_ptr const *> const * fields, + CORBA::ULong nfields) + : ::CORBA::TypeCode (kind) + , ::TAO::Null_RefCount_Policy () + , base_attributes_ (id, name) + , type_modifier_ (modifier) + , concrete_base_ (concrete_base) + , nfields_ (nfields) + , fields_ (fields) +{ +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/Visibility.pidl b/TAO/tao/AnyTypeCode/Visibility.pidl new file mode 100644 index 00000000000..27f4f755c8b --- /dev/null +++ b/TAO/tao/AnyTypeCode/Visibility.pidl @@ -0,0 +1,36 @@ +// -*- IDL -*- + +// ================================================================ +/** + * @file Visibility.pidl + * + * $Id$ + * + * This file was used to generate the code in VisibiltyC.* The command + * used to generate code is: + * + * tao_idl + * -o orig -SS -Ge 1 -Sci + * -Wb,export_macro=TAO_Export + * -Wb,export_include="tao/TAO_Export.h" + * -Wb,pre_include="ace/pre.h" + * -Wb,post_include="ace/post.h" + * -Wb,versioning_begin=TAO_BEGIN_VERSIONED_NAMESPACE_DECL + * -Wb,versioning_end=TAO_END_VERSIONED_NAMESPACE_DECL + * Visibilty.pidl + */ +// ================================================================ + +#ifndef TAO_VISIBILITY_PIDL +#define TAO_VISIBILITY_PIDL + +#pragma prefix "omg.org" + +module CORBA +{ + typedef short Visibility; + const Visibility PRIVATE_MEMBER = 0; + const Visibility PUBLIC_MEMBER = 1; +}; + +#endif /* TAO_VISIBILITY_PIDL */ diff --git a/TAO/tao/AnyTypeCode/WrongTransactionA.cpp b/TAO/tao/AnyTypeCode/WrongTransactionA.cpp new file mode 100644 index 00000000000..9c6fd0a62f2 --- /dev/null +++ b/TAO/tao/AnyTypeCode/WrongTransactionA.cpp @@ -0,0 +1,151 @@ +// -*- C++ -*- +// +// $Id$ + +// **** Code generated by the The ACE ORB (TAO) IDL Compiler **** +// TAO and the TAO IDL Compiler have been developed by: +// Center for Distributed Object Computing +// Washington University +// St. Louis, MO +// USA +// http://www.cs.wustl.edu/~schmidt/doc-center.html +// and +// Distributed Object Computing Laboratory +// University of California at Irvine +// Irvine, CA +// USA +// http://doc.ece.uci.edu/ +// and +// Institute for Software Integrated Systems +// Vanderbilt University +// Nashville, TN +// USA +// http://www.isis.vanderbilt.edu/ +// +// Information about TAO is available at: +// http://www.cs.wustl.edu/~schmidt/TAO.html + +#include "tao/AnyTypeCode/WrongTransactionA.h" +#include "tao/AnyTypeCode/Null_RefCount_Policy.h" +#include "tao/AnyTypeCode/TypeCode_Constants.h" +#include "tao/AnyTypeCode/Alias_TypeCode_Static.h" +#include "tao/AnyTypeCode/Struct_TypeCode_Static.h" +#include "tao/AnyTypeCode/TypeCode_Struct_Field.h" +#include "tao/CDR.h" +#include "tao/AnyTypeCode/Any.h" +#include "tao/AnyTypeCode/Any_Dual_Impl_T.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +// TAO_IDL - Generated from +// be\be_visitor_typecode/struct_typecode.cpp:87 + +static TAO::TypeCode::Struct_Field<char const *, CORBA::TypeCode_ptr const *> const * const _tao_fields_CORBA_WrongTransaction = 0; +static TAO::TypeCode::Struct<char const *, + CORBA::TypeCode_ptr const *, + TAO::TypeCode::Struct_Field<char const *, CORBA::TypeCode_ptr const *> const *, + TAO::Null_RefCount_Policy> + _tao_tc_CORBA_WrongTransaction ( + CORBA::tk_except, + "IDL:omg.org/CORBA/WrongTransaction:1.0", + "WrongTransaction", + _tao_fields_CORBA_WrongTransaction, + 0); + +namespace CORBA +{ + ::CORBA::TypeCode_ptr const _tc_WrongTransaction = + &_tao_tc_CORBA_WrongTransaction; +} + + + +// TAO_IDL - Generated from +// be\be_visitor_exception/any_op_cs.cpp:50 + +namespace TAO +{ + template<> + CORBA::Boolean + Any_Dual_Impl_T<CORBA::WrongTransaction>::demarshal_value ( + TAO_InputCDR & cdr + ) + { + CORBA::String_var id; + + if (!(cdr >> id.out ())) + { + return false; + } + + ACE_TRY_NEW_ENV + { + this->value_->_tao_decode (cdr ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + return false; + } + ACE_ENDTRY; + + return true; + } +} + +// Copying insertion. +void operator<<= ( + CORBA::Any &_tao_any, + const CORBA::WrongTransaction &_tao_elem + ) +{ + TAO::Any_Dual_Impl_T<CORBA::WrongTransaction>::insert_copy ( + _tao_any, + CORBA::WrongTransaction::_tao_any_destructor, + CORBA::_tc_WrongTransaction, + _tao_elem + ); +} + +// Non-copying insertion. +void operator<<= ( + CORBA::Any &_tao_any, + CORBA::WrongTransaction *_tao_elem + ) +{ + TAO::Any_Dual_Impl_T<CORBA::WrongTransaction>::insert ( + _tao_any, + CORBA::WrongTransaction::_tao_any_destructor, + CORBA::_tc_WrongTransaction, + _tao_elem + ); +} + +// Extraction to non-const pointer (deprecated). +CORBA::Boolean operator>>= ( + const CORBA::Any &_tao_any, + CORBA::WrongTransaction *&_tao_elem + ) +{ + return _tao_any >>= const_cast< + const CORBA::WrongTransaction *&> ( + _tao_elem + ); +} + +// Extraction to const pointer. +CORBA::Boolean operator>>= ( + const CORBA::Any &_tao_any, + const CORBA::WrongTransaction *&_tao_elem + ) +{ + return + TAO::Any_Dual_Impl_T<CORBA::WrongTransaction>::extract ( + _tao_any, + CORBA::WrongTransaction::_tao_any_destructor, + CORBA::_tc_WrongTransaction, + _tao_elem + ); +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/WrongTransactionA.h b/TAO/tao/AnyTypeCode/WrongTransactionA.h new file mode 100644 index 00000000000..745c0aa5f39 --- /dev/null +++ b/TAO/tao/AnyTypeCode/WrongTransactionA.h @@ -0,0 +1,112 @@ +// -*- C++ -*- +// +// $Id$ + +// **** Code generated by the The ACE ORB (TAO) IDL Compiler **** +// TAO and the TAO IDL Compiler have been developed by: +// Center for Distributed Object Computing +// Washington University +// St. Louis, MO +// USA +// http://www.cs.wustl.edu/~schmidt/doc-center.html +// and +// Distributed Object Computing Laboratory +// University of California at Irvine +// Irvine, CA +// USA +// http://doc.ece.uci.edu/ +// and +// Institute for Software Integrated Systems +// Vanderbilt University +// Nashville, TN +// USA +// http://www.isis.vanderbilt.edu/ +// +// Information about TAO is available at: +// http://www.cs.wustl.edu/~schmidt/TAO.html + +// TAO_IDL - Generated from +// be\be_codegen.cpp:153 + +#ifndef _TAO_IDL_ORIG_WRONGTRANSACTIONA_H_ +#define _TAO_IDL_ORIG_WRONGTRANSACTIONA_H_ + +#include /**/ "ace/pre.h" + + +#include "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/AnyTypeCode/TAO_AnyTypeCode_Export.h" +#include "tao/AnyTypeCode/AnyTypeCode_methods.h" +#include "tao/WrongTransactionC.h" + +#if defined (TAO_EXPORT_MACRO) +#undef TAO_EXPORT_MACRO +#endif +#define TAO_EXPORT_MACRO TAO_AnyTypeCode_Export + +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +#if defined (__BORLANDC__) +#pragma option push -w-rvl -w-rch -w-ccc -w-inl +#endif /* __BORLANDC__ */ + +// TAO_IDL - Generated from +// be\be_visitor_module/module_ch.cpp:48 + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace CORBA +{ + + // TAO_IDL - Generated from + // be\be_visitor_typecode/typecode_decl.cpp:44 + + extern TAO_AnyTypeCode_Export ::CORBA::TypeCode_ptr const _tc_WrongTransaction; + +// TAO_IDL - Generated from +// be\be_visitor_module/module_ch.cpp:66 + +} // module CORBA + +// TAO_IDL - Generated from +// be\be_visitor_traits.cpp:61 + +// Traits specializations. +namespace TAO +{ +} + +// TAO_IDL - Generated from +// be\be_visitor_exception/any_op_ch.cpp:52 + +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, const CORBA::WrongTransaction &); // copying version +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, CORBA::WrongTransaction*); // noncopying version +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any &, CORBA::WrongTransaction *&); // deprecated +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any &, const CORBA::WrongTransaction *&); + +// TAO_IDL - Generated from +// be\be_codegen.cpp:955 + +TAO_END_VERSIONED_NAMESPACE_DECL + +#if defined(_MSC_VER) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#if defined (__BORLANDC__) +#pragma option pop +#endif /* __BORLANDC__ */ + +#include /**/ "ace/post.h" + +#endif /* ifndef */ + + diff --git a/TAO/tao/AnyTypeCode/append.cpp b/TAO/tao/AnyTypeCode/append.cpp new file mode 100644 index 00000000000..618c273141a --- /dev/null +++ b/TAO/tao/AnyTypeCode/append.cpp @@ -0,0 +1,1329 @@ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO +// +// = FILENAME +// append.cpp +// +// = DESCRIPTION +// Appends a CDR stream to another CDR stream. Due to the +// stringent alignment requirements, it is not possible to simply +// append or memcpy. Instead we go thru the same CDR encoding rules +// +// = AUTHOR +// Copyright 1994-1995 by Sun Microsystems Inc. +// and Aniruddha Gokhale +// +// ============================================================================ + +#include "tao/AnyTypeCode/TypeCode.h" +#include "tao/AnyTypeCode/Marshal.h" +#include "tao/AnyTypeCode/Any_Unknown_IDL_Type.h" +#include "tao/AnyTypeCode/TypeCode_Constants.h" +#include "tao/AnyTypeCode/OctetSeqA.h" +#include "tao/AnyTypeCode/Any.h" +#include "tao/Environment.h" +#include "tao/debug.h" +#include "tao/Valuetype_Adapter.h" +#include "tao/ORB_Core.h" +#include "tao/CDR.h" +#include "tao/SystemException.h" + +#include "ace/Dynamic_Service.h" + +ACE_RCSID (AnyTypeCode, + append, + "$Id$") + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +// Encode instances of arbitrary data types based only on typecode. +// "data" points to the data type; if it's not a primitve data type, +// the TypeCode interpreter is used to recursively encode its +// components. "context" is the marshaling stream on which to encode +// the data value. + +TAO::traverse_status +TAO_Marshal_Primitive::append (CORBA::TypeCode_ptr tc, + TAO_InputCDR *src, + TAO_OutputCDR *dest + ACE_ENV_ARG_DECL) +{ + CORBA::Boolean continue_append = 1; + TAO::traverse_status retval = + TAO::TRAVERSE_CONTINUE; // status of encode operation + + CORBA::TCKind const k = tc->kind (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + + switch (k) + { + case CORBA::tk_null: + case CORBA::tk_void: + break; + case CORBA::tk_short: + case CORBA::tk_ushort: + continue_append = dest->append_short (*src); + break; + case CORBA::tk_long: + case CORBA::tk_ulong: + case CORBA::tk_float: + case CORBA::tk_enum: + continue_append = dest->append_long (*src); + break; + case CORBA::tk_double: + case CORBA::tk_longlong: + case CORBA::tk_ulonglong: + continue_append = dest->append_double (*src); + break; + case CORBA::tk_boolean: + continue_append = dest->append_boolean (*src); + break; + case CORBA::tk_char: + case CORBA::tk_octet: + continue_append = dest->append_octet (*src); + break; + case CORBA::tk_longdouble: + continue_append = dest->append_longdouble (*src); + break; + case CORBA::tk_wchar: + continue_append = dest->append_wchar (*src); + break; + default: + retval = TAO::TRAVERSE_STOP; + // we are not a primitive type + } + + if (retval == TAO::TRAVERSE_CONTINUE + && continue_append == 1) + return TAO::TRAVERSE_CONTINUE; + + if (TAO_debug_level > 0) + ACE_DEBUG (( + LM_DEBUG, + ACE_TEXT ("TAO_Marshal_Primitive::append detected error\n") + )); + + ACE_THROW_RETURN (CORBA::MARSHAL (0, + CORBA::COMPLETED_MAYBE), + TAO::TRAVERSE_STOP); +} + +TAO::traverse_status +TAO_Marshal_Any::append (CORBA::TypeCode_ptr, + TAO_InputCDR *src, + TAO_OutputCDR *dest + ACE_ENV_ARG_DECL) +{ + // Typecode of the element that makes the Any. + CORBA::TypeCode_var elem_tc; + + if (!(*src >> elem_tc.inout ())) + ACE_THROW_RETURN (CORBA::MARSHAL (0, + CORBA::COMPLETED_MAYBE), + TAO::TRAVERSE_STOP); + + if (!(*dest << elem_tc.in ())) + ACE_THROW_RETURN (CORBA::MARSHAL (0, + CORBA::COMPLETED_MAYBE), + TAO::TRAVERSE_STOP); + + // append the data + TAO::traverse_status retval = + TAO_Marshal_Object::perform_append (elem_tc.in (), + src, + dest + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + + if (retval != TAO::TRAVERSE_CONTINUE) + { + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("TAO_Marshal_Any::append detected error\n"))); + + ACE_THROW_RETURN (CORBA::MARSHAL (0, + CORBA::COMPLETED_MAYBE), + TAO::TRAVERSE_STOP); + } + + return retval; +} + +TAO::traverse_status +TAO_Marshal_TypeCode::append (CORBA::TypeCode_ptr, + TAO_InputCDR *src, + TAO_OutputCDR *dest + ACE_ENV_ARG_DECL) +{ + CORBA::Boolean continue_append = 1; + TAO::traverse_status retval = + TAO::TRAVERSE_CONTINUE; + CORBA::ULong kind; + + // Decode the "kind" field of the typecode from the src for further + // use. However, also write it back into the destination + continue_append = (CORBA::Boolean) (src->read_ulong (kind) + ? dest->write_ulong (kind) + : 0); + + if (continue_append == 1) + { + // Typecodes with empty parameter lists all have preallocated + // constants. We use those to reduce memory consumption and + // heap access ... also, to speed things up! + if ((kind < CORBA::TAO_TC_KIND_COUNT) + || (kind == ~0u)) + { + // Either a non-constant typecode or an indirected typecode. + switch (kind) + { + // Need special handling for all kinds of typecodes that + // have nonempty parameter lists ... + default: + // nothing to de done + break; + case CORBA::tk_string: + case CORBA::tk_wstring: + { + // read and write the bounds + retval = + TAO_Marshal_Object::perform_append (CORBA::_tc_long, + src, + dest + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + } + break; + + // Indirected typecodes, illegal at "top level" + case ~0u: + { + // read and write the negative offset + retval = + TAO_Marshal_Object::perform_append (CORBA::_tc_long, + src, + dest + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + } + break; + + // The rest have "complex" parameter lists that are + // encoded as bulk octets ... + case CORBA::tk_objref: + case CORBA::tk_struct: + case CORBA::tk_union: + case CORBA::tk_enum: + case CORBA::tk_sequence: + case CORBA::tk_array: + case CORBA::tk_alias: + case CORBA::tk_except: + case CORBA::tk_value: + case CORBA::tk_value_box: + case CORBA::tk_native: + case CORBA::tk_abstract_interface: + case CORBA::tk_local_interface: + case CORBA::tk_component: + case CORBA::tk_home: + case CORBA::tk_event: + { + // write the encapsulation i.e., octet sequence + retval = + TAO_Marshal_Object::perform_append (CORBA::_tc_OctetSeq, + src, + dest + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + } + } // end of switch + } + else // bad kind_ value to be decoded + { + if (TAO_debug_level > 0) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("TAO_Marshal_TypeCode: ") + ACE_TEXT ("Bad kind_ value in CDR stream\n"))); + } + + ACE_THROW_RETURN (CORBA::BAD_TYPECODE (), + TAO::TRAVERSE_STOP); + } + } + + if (continue_append == 1 && retval == TAO::TRAVERSE_CONTINUE) + { + return TAO::TRAVERSE_CONTINUE; + } + + if (TAO_debug_level > 0) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("TAO_Marshal_TypeCode::append detected error\n"))); + } + + ACE_THROW_RETURN (CORBA::MARSHAL (0, + CORBA::COMPLETED_MAYBE), + TAO::TRAVERSE_STOP); +} + +TAO::traverse_status +TAO_Marshal_Principal::append (CORBA::TypeCode_ptr, + TAO_InputCDR *src, + TAO_OutputCDR *dest + ACE_ENV_ARG_DECL) +{ + // write the octet sequence representing the Principal + return TAO_Marshal_Object::perform_append (CORBA::_tc_OctetSeq, + src, + dest + ACE_ENV_ARG_PARAMETER); +} + +TAO::traverse_status +TAO_Marshal_ObjRef::append (CORBA::TypeCode_ptr, + TAO_InputCDR *src, + TAO_OutputCDR *dest + ACE_ENV_ARG_DECL) +{ + CORBA::Boolean continue_append = 1; + + // First, append the type hint. This will be the type_id encoded in an + // object reference. + dest->append_string (*src); + + // Read the profiles, discarding all until an IIOP profile comes by. + // Once we see an IIOP profile, ignore any further ones. + // + // XXX this will need to change someday to let different protocol + // code be accessed, not just IIOP. Protocol modules will be + // dynamically loaded from shared libraries via ORB_init (), and we + // just need to be able to access such preloaded libraries here as + // we unmarshal objrefs. + + CORBA::ULong profiles = 0; + + // get the count of profiles that follow. This will tell us the + // length of the sequence + continue_append = (CORBA::Boolean) (src->read_ulong (profiles) + ? dest->write_ulong (profiles) + : 0); + + // No profiles means a NIL objref. + while (profiles-- != 0 && continue_append) + { + CORBA::ULong tag = 0; + + // get the profile ID tag + if ((continue_append = (CORBA::Boolean) (src->read_ulong (tag) + ? dest->write_ulong (tag) + : 0)) == 0) + continue; + + CORBA::ULong length = 0; + if ((continue_append = (CORBA::Boolean) (src->read_ulong (length) + ? dest->write_ulong (length) + : 0)) == 0) + continue; + + // @@ This can be optimized! Pre-allocating on the destination + // and then copying directly into that. + CORBA::Octet* body = 0; + ACE_NEW_RETURN (body, + CORBA::Octet[length], + TAO::TRAVERSE_STOP); + continue_append = + (CORBA::Boolean) (src->read_octet_array (body, length) + ? dest->write_octet_array (body, length) + : 0); + delete [] body; + } + + if (continue_append == 1) + return TAO::TRAVERSE_CONTINUE; + + if (TAO_debug_level > 0) + ACE_DEBUG (( + LM_DEBUG, + ACE_TEXT ("TAO_Marshal_ObjRef::append detected error\n") + )); + + ACE_THROW_RETURN (CORBA::MARSHAL (0, + CORBA::COMPLETED_MAYBE), + TAO::TRAVERSE_STOP); +} + +TAO::traverse_status +TAO_Marshal_Struct::append (CORBA::TypeCode_ptr tc, + TAO_InputCDR *src, + TAO_OutputCDR *dest + ACE_ENV_ARG_DECL) +{ + TAO::traverse_status retval = + TAO::TRAVERSE_CONTINUE; + CORBA::TypeCode_var param; + + // Number of fields in the struct. + const CORBA::ULong member_count = + tc->member_count (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + + for (CORBA::ULong i = 0; + i < member_count && retval == TAO::TRAVERSE_CONTINUE; + ++i) + { + // get member type + param = tc->member_type (i ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + + retval = + TAO_Marshal_Object::perform_append (param.in (), + src, + dest + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + } + + if (retval == TAO::TRAVERSE_CONTINUE) + return TAO::TRAVERSE_CONTINUE; + + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("TAO_Marshal_Struct::append detected error\n"))); + + ACE_THROW_RETURN (CORBA::MARSHAL (0, + CORBA::COMPLETED_MAYBE), + TAO::TRAVERSE_STOP); +} + +TAO::traverse_status +TAO_Marshal_Union::append (CORBA::TypeCode_ptr tc, + TAO_InputCDR *src, + TAO_OutputCDR *dest + ACE_ENV_ARG_DECL) +{ + CORBA::TypeCode_var discrim_tc = + tc->discriminator_type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + + CORBA::ULong kind = + discrim_tc->kind (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + + // Save the discriminator value in a temporary variable... + CORBA::Short short_v = CORBA::Short(); + CORBA::UShort ushort_v = CORBA::UShort(); + CORBA::Long long_v = CORBA::Long(); + CORBA::ULong ulong_v = CORBA::ULong(); + CORBA::ULong enum_v = CORBA::ULong(); + CORBA::Char char_v = CORBA::Char(); + CORBA::WChar wchar_v = CORBA::WChar(); + CORBA::Boolean boolean_v = false; + + switch (kind) + { + case CORBA::tk_short: + { + if (!src->read_short (short_v) + || !dest->write_short (short_v)) + return TAO::TRAVERSE_STOP; + } + break; + + case CORBA::tk_ushort: + { + if (!src->read_ushort (ushort_v) + || !dest->write_ushort (ushort_v)) + return TAO::TRAVERSE_STOP; + } + break; + + case CORBA::tk_long: + { + if (!src->read_long (long_v) + || !dest->write_long (long_v)) + return TAO::TRAVERSE_STOP; + } + break; + + case CORBA::tk_ulong: + { + if (!src->read_ulong (ulong_v) + || !dest->write_ulong (ulong_v)) + return TAO::TRAVERSE_STOP; + } + break; + + case CORBA::tk_enum: + { + if (!src->read_ulong (enum_v) + || !dest->write_ulong (enum_v)) + return TAO::TRAVERSE_STOP; + } + break; + + case CORBA::tk_char: + { + if (!src->read_char (char_v) + || !dest->write_char (char_v)) + return TAO::TRAVERSE_STOP; + } + break; + + case CORBA::tk_wchar: + { + if (!src->read_wchar (wchar_v) + || !dest->write_wchar (wchar_v)) + return TAO::TRAVERSE_STOP; + } + break; + + case CORBA::tk_boolean: + { + if (!src->read_boolean (boolean_v) + || !dest->write_boolean (boolean_v)) + return TAO::TRAVERSE_STOP; + } + break; + + default: + return TAO::TRAVERSE_STOP; + } + + const CORBA::ULong member_count = + tc->member_count (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + + const CORBA::ULong null_member = ~static_cast<CORBA::ULong> (0U); + + CORBA::ULong current_member = null_member; + CORBA::ULong default_member = null_member; + + for (CORBA::ULong i = 0; + i < member_count && current_member == null_member; + ++i) + { + CORBA::Any_var any = tc->member_label (i + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + + CORBA::Octet o; + + if ((any >>= CORBA::Any::to_octet (o)) && o == 0) + { + CORBA::ULong default_index = + tc->default_index (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + + if (i != default_index) + ACE_THROW_RETURN (CORBA::BAD_TYPECODE (), + TAO::TRAVERSE_STOP); + // Found the default branch, save its position and continue + // trying to find the current value... + default_member = i; + continue; + } + + switch (kind) + { + case CORBA::tk_short: + { + CORBA::Short d; + if ((any >>= d) && d == short_v) + current_member = i; + } + break; + + case CORBA::tk_ushort: + { + CORBA::UShort d; + if ((any >>= d) && d == ushort_v) + current_member = i; + } + break; + + case CORBA::tk_long: + { + CORBA::Long d; + if ((any >>= d) && d == long_v) + current_member = i; + } + break; + + case CORBA::tk_ulong: + { + CORBA::ULong d; + if ((any >>= d) && d == ulong_v) + current_member = i; + } + break; + + case CORBA::tk_enum: + { + CORBA::ULong d; + TAO::Any_Impl *impl = any->impl (); + + if (impl->encoded ()) + { + TAO::Unknown_IDL_Type *unk = + dynamic_cast<TAO::Unknown_IDL_Type *> (impl); + + // We don't want unk's rd_ptr to move, in case + // we are shared by another Any, so we use this + // to copy the state, not the buffer. + TAO_InputCDR for_reading (unk->_tao_get_cdr ()); + + for_reading.read_ulong (d); + } + else + { + TAO_OutputCDR out; + impl->marshal_value (out); + TAO_InputCDR cdr (out); + cdr.read_ulong (d); + } + + if (d == enum_v) + { + current_member = i; + } + } + break; + + case CORBA::tk_char: + { + CORBA::Char d; + if ((any >>= CORBA::Any::to_char (d)) && d == char_v) + current_member = i; + } + break; + + case CORBA::tk_wchar: + { + CORBA::WChar d; + if ((any >>= CORBA::Any::to_wchar (d)) && d == wchar_v) + current_member = i; + } + break; + + case CORBA::tk_boolean: + { + CORBA::Boolean d; + if ((any >>= CORBA::Any::to_boolean (d)) && d == boolean_v) + current_member = i; + } + break; + + default: + return TAO::TRAVERSE_STOP; + } + } + + if (current_member == null_member) + { + // Cannot find the current member, check if there is a + // default... + if (default_member != null_member) + { + // Good, use the default to append... + CORBA::TypeCode_var member_tc = + tc->member_type (default_member ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + return TAO_Marshal_Object::perform_append (member_tc.in (), + src, + dest + ACE_ENV_ARG_PARAMETER); + } + + // If we're here, we have an implicit default case, and we + // should just return without appending anything, since no + // union member was marshaled in the first place. + return TAO::TRAVERSE_CONTINUE; + } + + // If we found the member successfully then just use that one... + CORBA::TypeCode_var member_tc = + tc->member_type (current_member ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + return TAO_Marshal_Object::perform_append (member_tc.in (), + src, + dest + ACE_ENV_ARG_PARAMETER); +} + +TAO::traverse_status +TAO_Marshal_String::append (CORBA::TypeCode_ptr, + TAO_InputCDR *src, + TAO_OutputCDR *dest + ACE_ENV_ARG_DECL) +{ + CORBA::Boolean continue_append = 1; + + // On decode, omit the check against specified string bounds, and + // cope with illegal "zero length" strings (all lengths on the wire + // must include a NUL). + // + // This is on the principle of being gracious in what we accept; we + // don't generate messages that fail to comply with protocol specs, + // but we will accept them when it's clear how to do so. + + continue_append = dest->append_string (*src); + if (continue_append == 1) + return TAO::TRAVERSE_CONTINUE; + + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("TAO_Marshal_TypeCode::append detected error\n"))); + + ACE_THROW_RETURN (CORBA::MARSHAL (0, + CORBA::COMPLETED_MAYBE), + TAO::TRAVERSE_STOP); +} + +TAO::traverse_status +TAO_Marshal_Sequence::append (CORBA::TypeCode_ptr tc, + TAO_InputCDR *src, + TAO_OutputCDR *dest + ACE_ENV_ARG_DECL) +{ + // Size of element. + CORBA::ULong bounds; + + // First unmarshal the sequence length ... we trust it to be right + // here, on the "be gracious in what you accept" principle. We + // don't generate illegal sequences (i.e. length > bounds). + + CORBA::Boolean continue_append = + (CORBA::Boolean) (src->read_ulong (bounds) + ? dest->write_ulong (bounds) + : 0); + + if (!continue_append) + { + ACE_DEBUG (( + LM_DEBUG, + ACE_TEXT ("TAO_Marshal_Sequence::append detected error\n") + )); + ACE_THROW_RETURN (CORBA::MARSHAL (), + TAO::TRAVERSE_STOP); + } + + if (bounds == 0) + { + return TAO::TRAVERSE_CONTINUE; + } + + if (continue_append) + { + // Get element typecode. + CORBA::TypeCode_var tc2 = + tc->content_type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + + TAO::traverse_status retval = + TAO::TRAVERSE_CONTINUE; + + CORBA::TCKind kind = tc2->kind (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + + switch (kind) + { + case CORBA::tk_octet: + { + char* buf; + if (dest->adjust (ACE_CDR::OCTET_SIZE * bounds, + ACE_CDR::OCTET_ALIGN, buf) == 0) + { + if (src->read_octet_array ((ACE_CDR::Octet*)buf, bounds) == 0) + retval = TAO::TRAVERSE_STOP; + } + } + break; + case CORBA::tk_boolean: + { + char* buf; + if (dest->adjust (ACE_CDR::OCTET_SIZE * bounds, + ACE_CDR::OCTET_ALIGN, buf) == 0) + { + if (src->read_boolean_array ((ACE_CDR::Boolean*)buf, bounds) == 0) + retval = TAO::TRAVERSE_STOP; + } + } + break; + case CORBA::tk_char: + { + char* buf; + if (dest->adjust (ACE_CDR::OCTET_SIZE * bounds, + ACE_CDR::OCTET_ALIGN, buf) == 0) + { + if (src->read_char_array ((ACE_CDR::Char*)buf, bounds) == 0) + retval = TAO::TRAVERSE_STOP; + } + } + break; + case CORBA::tk_short: + { + char* buf; + if (dest->adjust (ACE_CDR::SHORT_SIZE * bounds, + ACE_CDR::SHORT_ALIGN, buf) == 0) + { + if (src->read_short_array ((ACE_CDR::Short*)buf, bounds) == 0) + retval = TAO::TRAVERSE_STOP; + } + } + break; + case CORBA::tk_ushort: + { + char* buf; + if (dest->adjust (ACE_CDR::SHORT_SIZE * bounds, + ACE_CDR::SHORT_ALIGN, buf) == 0) + { + if (src->read_ushort_array ((ACE_CDR::UShort*)buf, bounds) == 0) + retval = TAO::TRAVERSE_STOP; + } + } + break; + case CORBA::tk_wchar: + { + char* buf; + if (dest->adjust (ACE_CDR::SHORT_SIZE * bounds, + ACE_CDR::SHORT_ALIGN, buf) == 0) + { + if (src->read_wchar_array ((ACE_CDR::WChar*)buf, bounds) == 0) + retval = TAO::TRAVERSE_STOP; + } + } + break; + case CORBA::tk_long: + { + char* buf; + if (dest->adjust (ACE_CDR::LONG_SIZE * bounds, + ACE_CDR::LONG_ALIGN, buf) == 0) + { + if (src->read_long_array ((ACE_CDR::Long*)buf, bounds) == 0) + retval = TAO::TRAVERSE_STOP; + } + } + break; + case CORBA::tk_ulong: + { + char* buf; + if (dest->adjust (ACE_CDR::LONG_SIZE * bounds, + ACE_CDR::LONG_ALIGN, buf) == 0) + { + if (src->read_ulong_array ((ACE_CDR::ULong*)buf, bounds) == 0) + retval = TAO::TRAVERSE_STOP; + } + } + break; + case CORBA::tk_float: + { + char* buf; + if (dest->adjust (ACE_CDR::LONG_SIZE * bounds, + ACE_CDR::LONG_ALIGN, buf) == 0) + { + if (src->read_float_array ((ACE_CDR::Float*)buf, bounds) == 0) + retval = TAO::TRAVERSE_STOP; + } + } + break; + case CORBA::tk_double: + { + char* buf; + if (dest->adjust (ACE_CDR::LONGLONG_SIZE * bounds, + ACE_CDR::LONGLONG_ALIGN, buf) == 0) + { + if (src->read_double_array ((ACE_CDR::Double*)buf, bounds) == 0) + retval = TAO::TRAVERSE_STOP; + } + } + break; + case CORBA::tk_longlong: + { + char* buf; + if (dest->adjust (ACE_CDR::LONGLONG_SIZE * bounds, + ACE_CDR::LONGLONG_ALIGN, buf) == 0) + { + if (src->read_longlong_array ((ACE_CDR::LongLong*)buf, bounds) == 0) + retval = TAO::TRAVERSE_STOP; + } + } + break; + case CORBA::tk_ulonglong: + { + char* buf; + if (dest->adjust (ACE_CDR::LONGLONG_SIZE * bounds, + ACE_CDR::LONGLONG_ALIGN, buf) == 0) + { + if (src->read_ulonglong_array ((ACE_CDR::ULongLong*)buf, bounds) == 0) + retval = TAO::TRAVERSE_STOP; + } + } + break; + case CORBA::tk_longdouble: + { + char* buf; + if (dest->adjust (ACE_CDR::LONGDOUBLE_SIZE * bounds, + ACE_CDR::LONGDOUBLE_ALIGN, buf) == 0) + { + if (src->read_longdouble_array ((ACE_CDR::LongDouble*)buf, bounds) == 0) + retval = TAO::TRAVERSE_STOP; + } + } + break; + + default: + while (bounds-- && retval == TAO::TRAVERSE_CONTINUE) + { + retval = TAO_Marshal_Object::perform_append (tc2.in (), + src, + dest + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + } + break; + }// end of switch + + if (retval == TAO::TRAVERSE_CONTINUE) + return TAO::TRAVERSE_CONTINUE; + } + // error exit + if (TAO_debug_level > 0) + ACE_DEBUG (( + LM_DEBUG, + ACE_TEXT ("marshaling TAO_Marshal_Sequence::append detected error\n") + )); + + ACE_THROW_RETURN (CORBA::MARSHAL (), + TAO::TRAVERSE_STOP); +} + +TAO::traverse_status +TAO_Marshal_Array::append (CORBA::TypeCode_ptr tc, + TAO_InputCDR *src, + TAO_OutputCDR *dest + ACE_ENV_ARG_DECL) +{ + // retrieve the bounds of the array + CORBA::ULong bounds = tc->length (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + + // get element typecode + CORBA::TypeCode_var tc2 = tc->content_type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + + // For CORBA basic types, the copy can be optimized + CORBA::TCKind kind = tc2->kind (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + + // Return status. + TAO::traverse_status retval = + TAO::TRAVERSE_CONTINUE; + + switch (kind) + { + case CORBA::tk_octet: + { + char* buf; + if (dest->adjust (ACE_CDR::OCTET_SIZE * bounds, + ACE_CDR::OCTET_ALIGN, buf) == 0) + { + if (src->read_octet_array ((ACE_CDR::Octet*)buf, bounds) == 0) + retval = TAO::TRAVERSE_STOP; + } + } + break; + case CORBA::tk_boolean: + { + char* buf; + if (dest->adjust (ACE_CDR::OCTET_SIZE * bounds, + ACE_CDR::OCTET_ALIGN, buf) == 0) + { + if (src->read_boolean_array ((ACE_CDR::Boolean*)buf, bounds) == 0) + retval = TAO::TRAVERSE_STOP; + } + } + break; + case CORBA::tk_char: + { + char* buf; + if (dest->adjust (ACE_CDR::OCTET_SIZE * bounds, + ACE_CDR::OCTET_ALIGN, buf) == 0) + { + if (src->read_char_array ((ACE_CDR::Char*)buf, bounds) == 0) + retval = TAO::TRAVERSE_STOP; + } + } + break; + case CORBA::tk_short: + { + char* buf; + if (dest->adjust (ACE_CDR::SHORT_SIZE * bounds, + ACE_CDR::SHORT_ALIGN, buf) == 0) + { + if (src->read_short_array ((ACE_CDR::Short*)buf, bounds) == 0) + retval = TAO::TRAVERSE_STOP; + } + } + break; + case CORBA::tk_ushort: + { + char* buf; + if (dest->adjust (ACE_CDR::SHORT_SIZE * bounds, + ACE_CDR::SHORT_ALIGN, buf) == 0) + { + if (src->read_ushort_array ((ACE_CDR::UShort*)buf, bounds) == 0) + retval = TAO::TRAVERSE_STOP; + } + } + break; + case CORBA::tk_wchar: + { + char* buf; + if (dest->adjust (ACE_CDR::SHORT_SIZE * bounds, + ACE_CDR::SHORT_ALIGN, buf) == 0) + { + if (src->read_wchar_array ((ACE_CDR::WChar*)buf, bounds) == 0) + retval = TAO::TRAVERSE_STOP; + } + } + break; + case CORBA::tk_long: + { + char* buf; + if (dest->adjust (ACE_CDR::LONG_SIZE * bounds, + ACE_CDR::LONG_ALIGN, buf) == 0) + { + if (src->read_long_array ((ACE_CDR::Long*)buf, bounds) == 0) + retval = TAO::TRAVERSE_STOP; + } + } + break; + case CORBA::tk_ulong: + { + char* buf; + if (dest->adjust (ACE_CDR::LONG_SIZE * bounds, + ACE_CDR::LONG_ALIGN, buf) == 0) + { + if (src->read_ulong_array ((ACE_CDR::ULong*)buf, bounds) == 0) + retval = TAO::TRAVERSE_STOP; + } + } + break; + case CORBA::tk_float: + { + char* buf; + if (dest->adjust (ACE_CDR::LONG_SIZE * bounds, + ACE_CDR::LONG_ALIGN, buf) == 0) + { + if (src->read_float_array ((ACE_CDR::Float*)buf, bounds) == 0) + retval = TAO::TRAVERSE_STOP; + } + } + break; + case CORBA::tk_double: + { + char* buf; + if (dest->adjust (ACE_CDR::LONGLONG_SIZE * bounds, + ACE_CDR::LONGLONG_ALIGN, buf) == 0) + { + if (src->read_double_array ((ACE_CDR::Double*)buf, bounds) == 0) + retval = TAO::TRAVERSE_STOP; + } + } + break; + case CORBA::tk_longlong: + { + char* buf; + if (dest->adjust (ACE_CDR::LONGLONG_SIZE * bounds, + ACE_CDR::LONGLONG_ALIGN, buf) == 0) + { + if (src->read_longlong_array ((ACE_CDR::LongLong*)buf, bounds) == 0) + retval = TAO::TRAVERSE_STOP; + } + } + break; + case CORBA::tk_ulonglong: + { + char* buf; + if (dest->adjust (ACE_CDR::LONGLONG_SIZE * bounds, + ACE_CDR::LONGLONG_ALIGN, buf) == 0) + { + if (src->read_ulonglong_array ((ACE_CDR::ULongLong*)buf, bounds) == 0) + retval = TAO::TRAVERSE_STOP; + } + } + break; + case CORBA::tk_longdouble: + { + char* buf; + if (dest->adjust (ACE_CDR::LONGDOUBLE_SIZE * bounds, + ACE_CDR::LONGDOUBLE_ALIGN, buf) == 0) + { + if (src->read_longdouble_array ((ACE_CDR::LongDouble*)buf, bounds) == 0) + retval = TAO::TRAVERSE_STOP; + } + } + break; + default: + while (bounds-- && retval == TAO::TRAVERSE_CONTINUE) + { + retval = TAO_Marshal_Object::perform_append (tc2.in (), + src, + dest + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + } + break; + }// end of switch + + if (retval == TAO::TRAVERSE_CONTINUE) + return retval; + + // error exit + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("TAO_Marshal_Sequence::append detected error\n"))); + + ACE_THROW_RETURN (CORBA::MARSHAL (), + TAO::TRAVERSE_STOP); +} + +TAO::traverse_status +TAO_Marshal_Alias::append (CORBA::TypeCode_ptr tc, + TAO_InputCDR *src, + TAO_OutputCDR *dest + ACE_ENV_ARG_DECL) +{ + // Typecode of the aliased type. + CORBA::TypeCode_var tc2; + CORBA::Boolean continue_append = 1; + + // Status of decode operation. + TAO::traverse_status retval = + TAO::TRAVERSE_CONTINUE; + + tc2 = tc->content_type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + + retval = TAO_Marshal_Object::perform_append (tc2.in (), + src, + dest + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + + if (retval == TAO::TRAVERSE_CONTINUE + && continue_append == 1) + return TAO::TRAVERSE_CONTINUE; + + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("TAO_Marshal_Alias::append detected error\n"))); + ACE_THROW_RETURN (CORBA::MARSHAL (0, + CORBA::COMPLETED_MAYBE), + TAO::TRAVERSE_STOP); +} + +// Decode exception For exceptions, the "hidden" type ID near the +// front of the on-wire representation was previously unmarshaled and +// mapped to the "tc" typcode we're using to traverse the memory ... +// at the same time its vtable, refcount, and other state was +// established. +// +// NOTE: This is asymmetric with respect to encoding exceptions. +TAO::traverse_status +TAO_Marshal_Except::append (CORBA::TypeCode_ptr tc, + TAO_InputCDR *src, + TAO_OutputCDR *dest + ACE_ENV_ARG_DECL) +{ + TAO::traverse_status retval = + TAO::TRAVERSE_CONTINUE; + CORBA::Boolean continue_append = 1; + CORBA::TypeCode_var param; + + // first append the RepositoryID + continue_append = dest->append_string (*src); + + // Number of fields in the struct. + const CORBA::ULong member_count = + tc->member_count (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + + for (CORBA::ULong i = 0; + i < member_count + && retval == TAO::TRAVERSE_CONTINUE + && continue_append == 1; + ++i) + { + param = tc->member_type (i ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + + retval = TAO_Marshal_Object::perform_append (param.in (), + src, + dest + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + } + + if (retval == TAO::TRAVERSE_CONTINUE + && continue_append == 1) + return TAO::TRAVERSE_CONTINUE; + + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("TAO_Marshal_Except::append detected error\n"))); + + ACE_THROW_RETURN (CORBA::MARSHAL (0, + CORBA::COMPLETED_MAYBE), + TAO::TRAVERSE_STOP); +} + +TAO::traverse_status +TAO_Marshal_WString::append (CORBA::TypeCode_ptr, + TAO_InputCDR *src, + TAO_OutputCDR *dest + ACE_ENV_ARG_DECL) +{ + CORBA::Boolean continue_append = 1; + + // On decode, omit the check against specified wstring bounds, and + // cope with illegal "zero length" strings (all lengths on the wire + // must include a NUL). + // + // This is on the principle of being gracious in what we accept; we + // don't generate messages that fail to comply with protocol specs, + // but we will accept them when it's clear how to do so. + + continue_append = dest->append_wstring (*src); + + if (continue_append == 1) + return TAO::TRAVERSE_CONTINUE; + + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("TAO_Marshal_WString::append detected error\n"))); + + ACE_THROW_RETURN (CORBA::MARSHAL (0, + CORBA::COMPLETED_MAYBE), + TAO::TRAVERSE_STOP); +} + +TAO::traverse_status +TAO_Marshal_Value::append (CORBA::TypeCode_ptr tc, + TAO_InputCDR *src, + TAO_OutputCDR *dest + ACE_ENV_ARG_DECL) +{ + TAO::traverse_status retval = + TAO::TRAVERSE_CONTINUE; + + // Use the same method to append our base valuetype. + // To achive this we'll need to distinguish between + // first-time/nested appends so that we won't attempt to + // append rep_id several times. + // + if (this->nested_processing_ == 0) + { + this->nested_processing_ = 1; + + CORBA::ULong value_tag; + + if (!src->read_ulong (value_tag) || + !dest->write_ulong (value_tag)) + { + return TAO::TRAVERSE_STOP; + } + + TAO_ORB_Core *orb_core = src->orb_core (); + if (orb_core == 0) + { + orb_core = TAO_ORB_Core_instance (); + + if (TAO_debug_level > 0) + { + ACE_DEBUG ((LM_WARNING, + "TAO (%P|%t) WARNING: extracting " + "valuetype using default ORB_Core\n")); + } + } + + TAO_Valuetype_Adapter *adapter = orb_core->valuetype_adapter(); + + if (value_tag == 0) // Null value type pointer. + { + //We are done. + return retval; + } + else if (value_tag & adapter->type_info_single ()) + { + // Append repository id which is of type string. + dest->append_string (*src); + } + else + { + //@@ boris: VT CDR + return TAO::TRAVERSE_STOP; + } + } + + // Handle our base valuetype if any. + CORBA::TypeCode_var param = + tc->concrete_base_type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + + CORBA::TCKind const param_kind = param->kind (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + + if (param_kind != CORBA::tk_null) + { + retval = this->append (param.in (), + src, + dest + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + + if (retval != TAO::TRAVERSE_CONTINUE) + { + return retval; + } + } + + // Number of fields in the struct. + const CORBA::ULong member_count = + tc->member_count (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + + for (CORBA::ULong i = 0; + i < member_count && retval == TAO::TRAVERSE_CONTINUE; + ++i) + { + // get member type + param = tc->member_type (i ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + + retval = + TAO_Marshal_Object::perform_append (param.in (), + src, + dest + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + } + + if (retval == TAO::TRAVERSE_CONTINUE) + return TAO::TRAVERSE_CONTINUE; + + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("TAO_Marshal_Value::append detected error\n"))); + + ACE_THROW_RETURN (CORBA::MARSHAL (0, + CORBA::COMPLETED_MAYBE), + TAO::TRAVERSE_STOP); +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/skip.cpp b/TAO/tao/AnyTypeCode/skip.cpp new file mode 100644 index 00000000000..f8c486bc6a2 --- /dev/null +++ b/TAO/tao/AnyTypeCode/skip.cpp @@ -0,0 +1,1078 @@ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO +// +// = FILENAME +// skip.cpp +// +// = DESCRIPTION +// Code for skipping different data types +// +// Data types encoded as CDR streams need to be skipped when they +// are part of an Any. +// +// = AUTHOR +// Aniruddha Gokhale +// +// ============================================================================ + +#include "tao/AnyTypeCode/Marshal.h" +#include "tao/AnyTypeCode/TypeCode.h" +#include "tao/AnyTypeCode/Any_Unknown_IDL_Type.h" +#include "tao/AnyTypeCode/Any.h" + +#include "tao/debug.h" +#include "tao/Valuetype_Adapter.h" +#include "tao/ORB_Core.h" +#include "tao/CDR.h" +#include "tao/SystemException.h" + +#include "ace/Dynamic_Service.h" + +ACE_RCSID (AnyTypeCode, + skip, + "$Id$") + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +TAO::traverse_status +TAO_Marshal_Primitive::skip (CORBA::TypeCode_ptr tc, + TAO_InputCDR *stream + ACE_ENV_ARG_DECL) +{ + CORBA::Boolean continue_skipping = true; + + // Status of skip operation. + TAO::traverse_status retval = TAO::TRAVERSE_CONTINUE; + + CORBA::TCKind const k = tc->kind (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + + switch (k) + { + case CORBA::tk_null: + case CORBA::tk_void: + break; + case CORBA::tk_short: + case CORBA::tk_ushort: + continue_skipping = stream->skip_short (); + break; + case CORBA::tk_long: + case CORBA::tk_ulong: + case CORBA::tk_float: + case CORBA::tk_enum: + continue_skipping = stream->skip_long (); + break; + case CORBA::tk_double: + case CORBA::tk_longlong: + case CORBA::tk_ulonglong: + continue_skipping = stream->skip_longlong (); + break; + case CORBA::tk_boolean: + continue_skipping = stream->skip_boolean (); + break; + case CORBA::tk_char: + case CORBA::tk_octet: + continue_skipping = stream->skip_char (); + break; + case CORBA::tk_longdouble: + continue_skipping = stream->skip_longdouble (); + break; + case CORBA::tk_wchar: + continue_skipping = stream->skip_wchar (); + break; + default: + retval = TAO::TRAVERSE_STOP; + // we are not a primitive type + } + if (retval == TAO::TRAVERSE_CONTINUE && continue_skipping) + return TAO::TRAVERSE_CONTINUE; + else + { + if (TAO_debug_level > 0) + ACE_DEBUG (( + LM_DEBUG, + ACE_TEXT ("TAO_Marshal_Primitive::skip detected error\n") + )); + ACE_THROW_RETURN (CORBA::MARSHAL (0, + CORBA::COMPLETED_MAYBE), + TAO::TRAVERSE_STOP); + } +} + +TAO::traverse_status +TAO_Marshal_Any::skip (CORBA::TypeCode_ptr, + TAO_InputCDR *stream + ACE_ENV_ARG_DECL) +{ + // Typecode of the element that makes the Any. + CORBA::TypeCode_var elem_tc; + + // Status of encode operation. + if (!(*stream >> elem_tc.inout ())) + return TAO::TRAVERSE_STOP; + + return TAO_Marshal_Object::perform_skip (elem_tc.in (), + stream + ACE_ENV_ARG_PARAMETER); +} + +TAO::traverse_status +TAO_Marshal_TypeCode::skip (CORBA::TypeCode_ptr, + TAO_InputCDR *stream + ACE_ENV_ARG_DECL) +{ + CORBA::Boolean continue_skipping = true; + + // Typecode kind. + CORBA::ULong kind; + + // Decode the "kind" field of the typecode from the stream. + continue_skipping = stream->read_ulong (kind); + + if (continue_skipping) + { + // Typecodes with empty parameter lists all have preallocated + // constants. We use those to reduce memory consumption and + // heap access ... also, to speed things up! + if ((kind < CORBA::TAO_TC_KIND_COUNT) || + (kind == ~0u)) + { + // Either a non-constant typecode or an indirected typecode. + switch (kind) + { + // Need special handling for all kinds of typecodes that + // have nonempty parameter lists ... + default: + // simple typecodes, nothing to do + break; + case CORBA::tk_string: + case CORBA::tk_wstring: + { + // skip the bounds + continue_skipping = stream->skip_ulong (); + } + break; + + // Indirected typecodes, illegal at "top level". + case ~0u: + { + // skip the long indicating the encapsulation offset, + continue_skipping = stream->skip_long (); + } + break; + + // The rest have "complex" parameter lists that are + // encoded as bulk octets ... + case CORBA::tk_objref: + case CORBA::tk_struct: + case CORBA::tk_union: + case CORBA::tk_enum: + case CORBA::tk_sequence: + case CORBA::tk_array: + case CORBA::tk_alias: + case CORBA::tk_except: + case CORBA::tk_value: + case CORBA::tk_value_box: + case CORBA::tk_native: + case CORBA::tk_abstract_interface: + case CORBA::tk_local_interface: + case CORBA::tk_component: + case CORBA::tk_home: + case CORBA::tk_event: + { + CORBA::ULong length; + + // get the encapsulation length + continue_skipping = stream->read_ulong (length); + if (!continue_skipping) + break; + // skip the encapsulation + continue_skipping = stream->skip_bytes (length); + } + } // end of switch + } + else // bad kind_ value to be decoded + { + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("TAO_Marshal_TypeCode::skip: ") + ACE_TEXT ("Bad kind_ value in CDR stream\n"))); + ACE_THROW_RETURN (CORBA::BAD_TYPECODE (), + TAO::TRAVERSE_STOP); + } + } + + if (continue_skipping) + return TAO::TRAVERSE_CONTINUE; + else + { + if (TAO_debug_level > 0) + ACE_DEBUG (( + LM_DEBUG, + ACE_TEXT ("TAO_Marshal_TypeCode::skip detected error\n") + )); + ACE_THROW_RETURN (CORBA::MARSHAL (0, + CORBA::COMPLETED_MAYBE), + TAO::TRAVERSE_STOP); + } +} + +TAO::traverse_status +TAO_Marshal_Principal::skip (CORBA::TypeCode_ptr, + TAO_InputCDR *stream + ACE_ENV_ARG_DECL) +{ + CORBA::Boolean continue_skipping = true; + + // specifies the number of bytes in the Principal + CORBA::ULong len; + + continue_skipping = stream->read_ulong (len); + if (len > 0 && continue_skipping) + { + continue_skipping = stream->skip_bytes (len); + } + + if (continue_skipping) + return TAO::TRAVERSE_CONTINUE; + else + { + if (TAO_debug_level > 0) + ACE_DEBUG (( + LM_DEBUG, + ACE_TEXT ("TAO_Marshal_Principal::skip detected error\n") + )); + ACE_THROW_RETURN (CORBA::MARSHAL (0, + CORBA::COMPLETED_MAYBE), + TAO::TRAVERSE_STOP); + } +} + +TAO::traverse_status +TAO_Marshal_ObjRef::skip (CORBA::TypeCode_ptr, + TAO_InputCDR *stream + ACE_ENV_ARG_DECL) +{ + CORBA::Boolean continue_skipping = true; + + // return status + TAO::traverse_status retval = + TAO::TRAVERSE_CONTINUE; + + // First, skip the type hint. This will be the type_id encoded in an + // object reference. + stream->skip_string (); + + // Read the profiles, discarding all until an IIOP profile comes by. + // Once we see an IIOP profile, ignore any further ones. + // + // XXX this will need to change someday to let different protocol + // code be accessed, not just IIOP. Protocol modules will be + // dynamically loaded from shared libraries via ORB_init (), and we + // just need to be able to access such preloaded libraries here as + // we unmarshal objrefs. + CORBA::ULong profiles = 0; + + // get the count of profiles that follow + continue_skipping = stream->read_ulong (profiles); + + while (profiles-- != 0 && continue_skipping) + { + CORBA::ULong tag; + + // get the profile ID tag + if ( (continue_skipping = stream->read_ulong (tag)) == 0) + continue; + + CORBA::ULong encap_len; + // ProfileData is encoded as a sequence of octet. So first get + // the length of the sequence. + // Create the decoding stream from the encapsulation in the + // buffer, and skip the encapsulation. + if ( (continue_skipping = stream->read_ulong (encap_len)) == 0) + continue; + + continue_skipping = stream->skip_bytes (encap_len); + } + + if (retval == TAO::TRAVERSE_CONTINUE && continue_skipping) + return TAO::TRAVERSE_CONTINUE; + else + { + if (TAO_debug_level > 0) + ACE_DEBUG (( + LM_DEBUG, + ACE_TEXT ("TAO_Marshal_ObjRef::skip detected error\n") + )); + ACE_THROW_RETURN (CORBA::MARSHAL (0, + CORBA::COMPLETED_MAYBE), + TAO::TRAVERSE_STOP); + } +} + +TAO::traverse_status +TAO_Marshal_Struct::skip (CORBA::TypeCode_ptr tc, + TAO_InputCDR *stream + ACE_ENV_ARG_DECL) +{ + TAO::traverse_status retval = TAO::TRAVERSE_CONTINUE; + CORBA::TypeCode_var param; + + // Number of fields in the struct. + CORBA::ULong const member_count = + tc->member_count (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + + for (CORBA::ULong i = 0; + i < member_count && retval == TAO::TRAVERSE_CONTINUE; + ++i) + { + param = tc->member_type (i ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + + retval = TAO_Marshal_Object::perform_skip (param.in (), + stream + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + } + + if (retval == TAO::TRAVERSE_CONTINUE) + return TAO::TRAVERSE_CONTINUE; + + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("TAO_Marshal_Struct::skip detected error\n"))); + + ACE_THROW_RETURN (CORBA::MARSHAL (0, + CORBA::COMPLETED_MAYBE), + TAO::TRAVERSE_STOP); +} + +TAO::traverse_status +TAO_Marshal_Union::skip (CORBA::TypeCode_ptr tc, + TAO_InputCDR *src + ACE_ENV_ARG_DECL) +{ + CORBA::TypeCode_var discrim_tc = + tc->discriminator_type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + + CORBA::ULong const kind = + discrim_tc->kind (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + + // Save the discriminator value in a temporary variable... + CORBA::Short short_v = CORBA::Short(); + CORBA::UShort ushort_v = CORBA::UShort(); + CORBA::Long long_v = CORBA::Long(); + CORBA::ULong ulong_v = CORBA::ULong(); + CORBA::ULong enum_v = CORBA::ULong(); + CORBA::Char char_v = CORBA::Char(); + CORBA::WChar wchar_v = CORBA::WChar(); + CORBA::Boolean boolean_v = false; + + switch (kind) + { + case CORBA::tk_short: + { + if (!src->read_short (short_v)) + return TAO::TRAVERSE_STOP; + } + break; + + case CORBA::tk_ushort: + { + if (!src->read_ushort (ushort_v)) + return TAO::TRAVERSE_STOP; + } + break; + + case CORBA::tk_long: + { + if (!src->read_long (long_v)) + return TAO::TRAVERSE_STOP; + } + break; + + case CORBA::tk_ulong: + { + if (!src->read_ulong (ulong_v)) + return TAO::TRAVERSE_STOP; + } + break; + + case CORBA::tk_enum: + { + if (!src->read_ulong (enum_v)) + return TAO::TRAVERSE_STOP; + } + break; + + case CORBA::tk_char: + { + if (!src->read_char (char_v)) + return TAO::TRAVERSE_STOP; + } + break; + + case CORBA::tk_wchar: + { + if (!src->read_wchar (wchar_v)) + return TAO::TRAVERSE_STOP; + } + break; + + case CORBA::tk_boolean: + { + if (!src->read_boolean (boolean_v)) + return TAO::TRAVERSE_STOP; + } + break; + + default: + return TAO::TRAVERSE_STOP; + } + + const CORBA::ULong member_count = + tc->member_count (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + + const CORBA::ULong null_member = ~static_cast<CORBA::ULong> (0U); + + CORBA::ULong current_member = null_member; + CORBA::ULong default_member = null_member; + + for (CORBA::ULong i = 0; + i < member_count && current_member == null_member; + ++i) + { + CORBA::Any_var any = tc->member_label (i ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + + CORBA::Octet o; + if ((any >>= CORBA::Any::to_octet (o)) && o == 0) + { + CORBA::ULong default_index = + tc->default_index (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + + if (i != default_index) + ACE_THROW_RETURN (CORBA::BAD_TYPECODE (), + TAO::TRAVERSE_STOP); + // Found the default branch, save its position and continue + // trying to find the current value... + default_member = i; + continue; + } + + switch (kind) + { + case CORBA::tk_short: + { + CORBA::Short d; + if ((any >>= d) && d == short_v) + current_member = i; + } + break; + + case CORBA::tk_ushort: + { + CORBA::UShort d; + if ((any >>= d) && d == ushort_v) + current_member = i; + } + break; + + case CORBA::tk_long: + { + CORBA::Long d; + if ((any >>= d) && d == long_v) + current_member = i; + } + break; + + case CORBA::tk_ulong: + { + CORBA::ULong d; + if ((any >>= d) && d == ulong_v) + current_member = i; + } + break; + + case CORBA::tk_enum: + { + CORBA::ULong d; + TAO::Any_Impl *impl = any->impl (); + + if (impl->encoded ()) + { + TAO::Unknown_IDL_Type *unk = + dynamic_cast<TAO::Unknown_IDL_Type *> (impl); + + // We don't want unk's rd_ptr to move, in case + // we are shared by another Any, so we use this + // to copy the state, not the buffer. + TAO_InputCDR for_reading (unk->_tao_get_cdr ()); + + for_reading.read_ulong (d); + } + else + { + TAO_OutputCDR out; + impl->marshal_value (out); + TAO_InputCDR cdr (out); + cdr.read_ulong (d); + } + + if (d == enum_v) + { + current_member = i; + } + } + break; + + case CORBA::tk_char: + { + CORBA::Char d; + if ((any >>= CORBA::Any::to_char (d)) && d == char_v) + current_member = i; + } + break; + + case CORBA::tk_wchar: + { + CORBA::WChar d; + if ((any >>= CORBA::Any::to_wchar (d)) && d == wchar_v) + current_member = i; + } + break; + + case CORBA::tk_boolean: + { + CORBA::Boolean d; + if ((any >>= CORBA::Any::to_boolean (d)) && d == boolean_v) + current_member = i; + } + break; + + default: + return TAO::TRAVERSE_STOP; + } + } + + if (current_member == null_member) + { + // Cannot find the current member, check if there is a + // default... + if (default_member != null_member) + { + // Good, use the default to append... + CORBA::TypeCode_var member_tc = + tc->member_type (default_member ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + return TAO_Marshal_Object::perform_skip (member_tc.in (), + src + ACE_ENV_ARG_PARAMETER); + } + + // If we're here, we have an implicit default case, and we + // should just return without skipping anything, since no + // union member was marshaled in the first place. + return TAO::TRAVERSE_CONTINUE; + } + + // If we found the member successfully then just use that one... + CORBA::TypeCode_var member_tc = + tc->member_type (current_member ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + + return TAO_Marshal_Object::perform_skip (member_tc.in (), + src + ACE_ENV_ARG_PARAMETER); +} + +TAO::traverse_status +TAO_Marshal_String::skip (CORBA::TypeCode_ptr, + TAO_InputCDR *stream + ACE_ENV_ARG_DECL) +{ + CORBA::Boolean continue_skipping = true; + + // On decode, omit the check against specified string bounds, and + // cope with illegal "zero length" strings (all lengths on the wire + // must include a NUL). + // + // This is on the principle of being gracious in what we accept; we + // don't generate messages that fail to comply with protocol specs, + // but we will accept them when it's clear how to do so. + + continue_skipping = stream->skip_string (); + if (continue_skipping) + return TAO::TRAVERSE_CONTINUE; + else + { + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("TAO_Marshal_String::skip detected error\n"))); + ACE_THROW_RETURN (CORBA::MARSHAL (0, + CORBA::COMPLETED_MAYBE), + TAO::TRAVERSE_STOP); + } +} + +TAO::traverse_status +TAO_Marshal_Sequence::skip (CORBA::TypeCode_ptr tc, + TAO_InputCDR *stream + ACE_ENV_ARG_DECL) +{ + // Size of element. + CORBA::ULong bounds; + + // First unmarshal the sequence length ... we trust it to be right + // here, on the "be gracious in what you accept" principle. We + // don't generate illegal sequences (i.e. length > bounds). + + CORBA::Boolean continue_skipping = + stream->read_ulong (bounds); + + if (!continue_skipping) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("TAO_Marshal_Sequence::skip detected error\n"))); + ACE_THROW_RETURN (CORBA::MARSHAL (), + TAO::TRAVERSE_STOP); + } + + // No point decoding an empty sequence. + if (bounds == 0) + return TAO::TRAVERSE_CONTINUE; + + // Get element typecode. + CORBA::TypeCode_var tc2 = + tc->content_type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + + // For CORBA basic types, the skip can be optimized + CORBA::TCKind const kind = tc2->kind (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + + char *dummy; + switch (kind) + { + case CORBA::tk_octet: + case CORBA::tk_boolean: + case CORBA::tk_char: + { + stream->adjust (0, ACE_CDR::OCTET_ALIGN, dummy); + continue_skipping = + stream->skip_bytes (ACE_CDR::OCTET_SIZE * bounds); + } + break; + case CORBA::tk_short: + case CORBA::tk_ushort: + case CORBA::tk_wchar: + { + stream->adjust (0, ACE_CDR::SHORT_ALIGN, dummy); + continue_skipping = + stream->skip_bytes (ACE_CDR::SHORT_SIZE * bounds); + } + break; + case CORBA::tk_long: + case CORBA::tk_ulong: + case CORBA::tk_float: + { + stream->adjust (0, ACE_CDR::LONG_ALIGN, dummy); + continue_skipping = + stream->skip_bytes (ACE_CDR::LONG_SIZE * bounds); + } + break; + case CORBA::tk_double: + case CORBA::tk_longlong: + case CORBA::tk_ulonglong: + { + stream->adjust (0, ACE_CDR::LONGLONG_ALIGN, dummy); + continue_skipping = + stream->skip_bytes (ACE_CDR::LONGLONG_SIZE * bounds); + } + break; + case CORBA::tk_longdouble: + { + stream->adjust (0, ACE_CDR::LONGDOUBLE_ALIGN, dummy); + continue_skipping = + stream->skip_bytes (ACE_CDR::LONGDOUBLE_SIZE * bounds); + } + break; + + default: + while (bounds-- && continue_skipping) + { + continue_skipping = + TAO_Marshal_Object::perform_skip (tc2.in (), + stream + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + } + break; + }// end of switch + + if (continue_skipping) + return TAO::TRAVERSE_CONTINUE; + + // error exit + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("TAO_Marshal_Sequence::skip detected error\n"))); + + ACE_THROW_RETURN (CORBA::MARSHAL (), + TAO::TRAVERSE_STOP); +} + +TAO::traverse_status +TAO_Marshal_Array::skip (CORBA::TypeCode_ptr tc, + TAO_InputCDR *stream + ACE_ENV_ARG_DECL) +{ + CORBA::Boolean continue_skipping = true; + + // retrieve the bounds of the array + CORBA::ULong bounds = tc->length (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + + // get element typecode + // Typecode of the element. + CORBA::TypeCode_var tc2 = tc->content_type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + + // For CORBA basic types, the skip can be optimized + CORBA::TCKind const kind = tc2->kind (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + + char *dummy; + switch (kind) + { + case CORBA::tk_octet: + case CORBA::tk_boolean: + case CORBA::tk_char: + { + stream->adjust (0, ACE_CDR::OCTET_ALIGN, dummy); + continue_skipping = + stream->skip_bytes (ACE_CDR::OCTET_SIZE * bounds); + } + break; + case CORBA::tk_short: + case CORBA::tk_ushort: + case CORBA::tk_wchar: + { + stream->adjust (0, ACE_CDR::SHORT_ALIGN, dummy); + continue_skipping = + stream->skip_bytes (ACE_CDR::SHORT_SIZE * bounds); + } + break; + case CORBA::tk_long: + case CORBA::tk_ulong: + case CORBA::tk_float: + { + stream->adjust (0, ACE_CDR::LONG_ALIGN, dummy); + continue_skipping = + stream->skip_bytes (ACE_CDR::LONG_SIZE * bounds); + } + break; + case CORBA::tk_double: + case CORBA::tk_longlong: + case CORBA::tk_ulonglong: + { + stream->adjust (0, ACE_CDR::LONGLONG_ALIGN, dummy); + continue_skipping = + stream->skip_bytes (ACE_CDR::LONGLONG_SIZE * bounds); + } + break; + case CORBA::tk_longdouble: + { + stream->adjust (0, ACE_CDR::LONGDOUBLE_ALIGN, dummy); + continue_skipping = + stream->skip_bytes (ACE_CDR::LONGDOUBLE_SIZE * bounds); + } + break; + + default: + while (bounds-- && continue_skipping) + { + int stop = + TAO_Marshal_Object::perform_skip (tc2.in (), + stream + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + if (stop == TAO::TRAVERSE_STOP) + continue_skipping = false; + } + break; + }// end of switch + + if (continue_skipping) + return TAO::TRAVERSE_CONTINUE; + + // error exit + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("TAO_Marshal_Sequence::skip detected error\n"))); + + ACE_THROW_RETURN (CORBA::MARSHAL (), + TAO::TRAVERSE_STOP); +} + +TAO::traverse_status +TAO_Marshal_Alias::skip (CORBA::TypeCode_ptr tc, + TAO_InputCDR *stream + ACE_ENV_ARG_DECL) +{ + // Typecode of the aliased type. + CORBA::TypeCode_var tc2; + CORBA::Boolean continue_skipping = true; + + // Status of decode operation. + TAO::traverse_status retval = + TAO::TRAVERSE_CONTINUE; + + tc2 = tc->content_type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + + retval = TAO_Marshal_Object::perform_skip (tc2.in (), + stream + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + + // tc2->_decr_refcnt (); + if (retval == TAO::TRAVERSE_CONTINUE + && continue_skipping) + return TAO::TRAVERSE_CONTINUE; + + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("TAO_Marshal_Alias::skip detected error\n"))); + + ACE_THROW_RETURN (CORBA::MARSHAL (0, + CORBA::COMPLETED_MAYBE), + TAO::TRAVERSE_STOP); +} + +// Decode exception For exceptions, the "hidden" type ID near the +// front of the on-wire representation was previously unmarshaled and +// mapped to the "tc" typcode we're using to traverse the memory ... +// at the same time its vtable, refcount, and other state was +// established. +// +// NOTE: This is asymmetric with respect to encoding exceptions. +TAO::traverse_status +TAO_Marshal_Except::skip (CORBA::TypeCode_ptr tc, + TAO_InputCDR *stream + ACE_ENV_ARG_DECL) +{ + TAO::traverse_status retval = + TAO::TRAVERSE_CONTINUE; + CORBA::TypeCode_var param; + + // skip the Repository ID + if (!stream->skip_string ()) + return TAO::TRAVERSE_STOP; + + // Number of fields in the exception + const CORBA::ULong member_count = + tc->member_count (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + + for (CORBA::ULong i = 0; + i < member_count && retval == TAO::TRAVERSE_CONTINUE; + ++i) + { + param = tc->member_type (i ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + + retval = TAO_Marshal_Object::perform_skip (param.in (), + stream + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + } + + if (retval == TAO::TRAVERSE_CONTINUE) + return TAO::TRAVERSE_CONTINUE; + + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("TAO_Marshal_Except::skip detected error\n"))); + + ACE_THROW_RETURN (CORBA::MARSHAL (0, + CORBA::COMPLETED_MAYBE), + TAO::TRAVERSE_STOP); +} + +// decode wstring +TAO::traverse_status +TAO_Marshal_WString::skip (CORBA::TypeCode_ptr, + TAO_InputCDR *stream + ACE_ENV_ARG_DECL) +{ + CORBA::Boolean continue_skipping = true; + + // On decode, omit the check against specified wstring bounds, and + // cope with illegal "zero length" strings (all lengths on the wire + // must include a NUL). + // + // This is on the principle of being gracious in what we accept; we + // don't generate messages that fail to comply with protocol specs, + // but we will accept them when it's clear how to do so. + + // "zero length" wstrings are legal in GIOP 1.2. + + continue_skipping = stream->skip_wstring (); + + if (continue_skipping) + return TAO::TRAVERSE_CONTINUE; + + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("TAO_Marshal_WString::skip detected error\n"))); + ACE_THROW_RETURN (CORBA::MARSHAL (0, + CORBA::COMPLETED_MAYBE), + TAO::TRAVERSE_STOP); +} + +TAO::traverse_status +TAO_Marshal_Value::skip (CORBA::TypeCode_ptr tc, + TAO_InputCDR *stream + ACE_ENV_ARG_DECL) +{ + TAO::traverse_status retval = TAO::TRAVERSE_CONTINUE; + CORBA::TypeCode_var param; + + // Use the same method to skip over our base valuetype. + // To achive this we'll need to distinguish between + // first-time/nested skips so that we won't attempt to + // skip rep_id several times. + // + if (this->nested_processing_ == false) + { + this->nested_processing_ = true; + + CORBA::Long value_tag; + + if (!stream->read_long (value_tag)) + { + return TAO::TRAVERSE_STOP; + } + + TAO_ORB_Core *orb_core = stream->orb_core (); + if (orb_core == 0) + { + orb_core = TAO_ORB_Core_instance (); + + if (TAO_debug_level > 0) + { + ACE_DEBUG ((LM_WARNING, + "TAO (%P|%t) WARNING: extracting " + "valuetype using default ORB_Core\n")); + } + } + + TAO_Valuetype_Adapter *adapter = orb_core->valuetype_adapter(); + + if (value_tag == 0) // Null value type pointer. + { + // We are done. + return retval; + } + else if (adapter->is_type_info_single(value_tag)) + { + // Skip a single repository id which is of type string. + stream->skip_string (); + } + else if (adapter->is_type_info_list(value_tag)) + { + CORBA::Long num_types; + if (!stream->read_long (num_types)) + { + return TAO::TRAVERSE_STOP; + } + while (num_types > 0) + { + stream->skip_string(); + num_types--; + } + } + else if (!adapter->is_type_info_implied (value_tag)) + { + //@@ boris: VT CDR + return TAO::TRAVERSE_STOP; + } + + if (adapter->is_value_chunked (value_tag)) + { + CORBA::Long chunk_tag = 0; + while (chunk_tag != -1) + { + if (!stream->read_long (chunk_tag)) + return TAO::TRAVERSE_STOP; + + if (chunk_tag > 0) + { + if (!stream->skip_bytes(chunk_tag)) + return TAO::TRAVERSE_STOP; + } + } + return TAO::TRAVERSE_CONTINUE; + } + + } + + // Handle our base valuetype if any. + param = tc->concrete_base_type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + + CORBA::TCKind const k = param->kind (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + + if (k != CORBA::tk_null) + { + retval = this->skip (param.in (), stream ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + + if (retval != TAO::TRAVERSE_CONTINUE) + { + return retval; + } + } + + // Number of fields in the valuetype. + CORBA::ULong const member_count = + tc->member_count (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + + for (CORBA::ULong i = 0; + i < member_count && retval == TAO::TRAVERSE_CONTINUE; + ++i) + { + param = tc->member_type (i ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + + retval = TAO_Marshal_Object::perform_skip (param.in (), + stream + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO::TRAVERSE_STOP); + } + + if (retval == TAO::TRAVERSE_CONTINUE) + return TAO::TRAVERSE_CONTINUE; + + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("TAO_Marshal_Value::skip detected error\n"))); + + ACE_THROW_RETURN (CORBA::MARSHAL (0, + CORBA::COMPLETED_MAYBE), + TAO::TRAVERSE_STOP); +} + +TAO_END_VERSIONED_NAMESPACE_DECL |