diff options
author | Johnny Willemsen <jwillemsen@remedy.nl> | 2005-08-19 08:28:35 +0000 |
---|---|---|
committer | Johnny Willemsen <jwillemsen@remedy.nl> | 2005-08-19 08:28:35 +0000 |
commit | 7c9c3741e02d1569824dd6d024bd81e03febb2c7 (patch) | |
tree | 279233684289a024587c0885378eeee4079b9f01 /TAO/tao/AnyTypeCode/Recursive_Type_TypeCode.cpp | |
parent | 7f61ed4f18c496890fbdf75300b1135d6911d9aa (diff) | |
download | ATCD-7c9c3741e02d1569824dd6d024bd81e03febb2c7.tar.gz |
ChangeLogTag Fri Aug 19 07:56:12 UTC 2005 Johnny Willemsen <jwillemsen@remedy.nl>
Diffstat (limited to 'TAO/tao/AnyTypeCode/Recursive_Type_TypeCode.cpp')
-rw-r--r-- | TAO/tao/AnyTypeCode/Recursive_Type_TypeCode.cpp | 138 |
1 files changed, 138 insertions, 0 deletions
diff --git a/TAO/tao/AnyTypeCode/Recursive_Type_TypeCode.cpp b/TAO/tao/AnyTypeCode/Recursive_Type_TypeCode.cpp new file mode 100644 index 00000000000..a96abe13a0b --- /dev/null +++ b/TAO/tao/AnyTypeCode/Recursive_Type_TypeCode.cpp @@ -0,0 +1,138 @@ +// $Id$ + + +#include "tao/CDR.h" + +#ifndef __ACE_INLINE__ +# include "tao/AnyTypeCode/Recursive_Type_TypeCode.inl" +#endif /* __ACE_INLINE__ */ + +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->ACE_NESTED_CLASS (CORBA, TypeCode)::tao_marshal_kind (cdr); + + // Recursive/indirected TypeCode case. + CORBA::ULong const indirection_kind = 0xffffffff; + + return (cdr << indirection_kind); +} |