Recursive_Type_TypeCode.cpp

Go to the documentation of this file.
00001 // $Id: Recursive_Type_TypeCode.cpp 77528 2007-03-05 11:11:05Z johnnyw $
00002 
00003 #include "tao/CDR.h"
00004 
00005 #ifndef __ACE_INLINE__
00006 # include "tao/AnyTypeCode/Recursive_Type_TypeCode.inl"
00007 #endif  /* __ACE_INLINE__ */
00008 
00009 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00010 
00011 template <class TypeCodeBase, typename TypeCodeType, typename MemberArrayType>
00012 bool
00013 TAO::TypeCode::Recursive_Type<TypeCodeBase,
00014                               TypeCodeType,
00015                               MemberArrayType>::tao_marshal (
00016   TAO_OutputCDR & cdr,
00017   CORBA::ULong offset) const
00018 {
00019   ACE_GUARD_RETURN (TAO_SYNCH_RECURSIVE_MUTEX,
00020                     guard,
00021                     this->lock_,
00022                     false);
00023 
00024   // Top-level TypeCode case.
00025   if (!(this->in_recursion_))
00026     {
00027       this->in_recursion_ = true;
00028 
00029       // Starting offset should point to the CORBA::TCKind value.
00030 
00031       // Note that this doesn't need to take into account alignment
00032       // padding since CORBA::TCKind (encoded as a CORBA::ULong) is
00033       // already aligned on the appropriate boundary, and since the
00034       // CORBA::TCKind was the last thing marshaled into the CDR
00035       // stream before getting here.
00036       offset = sizeof (CORBA::ULong);
00037 
00038       // Reset recursion flag to false in an exception-safe manner once
00039       // marshaling is done.
00040       //
00041       // Only reset the recursion flag at the top-level.
00042       Reset flag (this->in_recursion_);
00043 
00044       return this->TypeCodeBase::tao_marshal (cdr, offset);
00045     }
00046 
00047   // Recursive/indirected TypeCode case.
00048 
00049 //   ACE_ASSERT (offset > 4
00050 //               && offset < static_cast<CORBA::ULong> (ACE_INT32_MAX));
00051 
00052   return (cdr << -static_cast<CORBA::Long> (offset));
00053 }
00054 
00055 template <class TypeCodeBase, typename TypeCodeType, typename MemberArrayType>
00056 CORBA::Boolean
00057 TAO::TypeCode::Recursive_Type<TypeCodeBase,
00058                               TypeCodeType,
00059                               MemberArrayType>::equal_i (
00060   CORBA::TypeCode_ptr tc) const
00061 {
00062   ACE_GUARD_RETURN (TAO_SYNCH_RECURSIVE_MUTEX,
00063                     guard,
00064                     this->lock_,
00065                     false);
00066 
00067   // Top-level TypeCode case.
00068   if (!(this->in_recursion_))
00069     {
00070       this->in_recursion_ = true;
00071 
00072       // Reset recursion flag to false in an exception-safe manner once
00073       // equality determination is done.
00074       //
00075       // Only reset the recursion flag at the top-level.
00076       Reset flag (this->in_recursion_);
00077 
00078       return this->TypeCodeBase::equal_i (tc);
00079     }
00080 
00081   // Nothing else to do.
00082   return true;
00083 }
00084 
00085 template <class TypeCodeBase, typename TypeCodeType, typename MemberArrayType>
00086 CORBA::Boolean
00087 TAO::TypeCode::Recursive_Type<TypeCodeBase,
00088                               TypeCodeType,
00089                               MemberArrayType>::equivalent_i (
00090   CORBA::TypeCode_ptr tc) const
00091 {
00092   ACE_GUARD_RETURN (TAO_SYNCH_RECURSIVE_MUTEX,
00093                     guard,
00094                     this->lock_,
00095                     false);
00096 
00097   // Top-level TypeCode case.
00098   if (!(this->in_recursion_))
00099     {
00100       this->in_recursion_ = true;
00101 
00102       // Reset recursion flag to false in an exception-safe manner once
00103       // equivalence determination is done.
00104       //
00105       // Only reset the recursion flag at the top-level.
00106       Reset flag (this->in_recursion_);
00107 
00108       return this->TypeCodeBase::equivalent_i (tc);
00109     }
00110 
00111   // Nothing else to do.
00112   return true;
00113 }
00114 
00115 template <class TypeCodeBase, typename TypeCodeType, typename MemberArrayType>
00116 bool
00117 TAO::TypeCode::Recursive_Type<TypeCodeBase,
00118                               TypeCodeType,
00119                               MemberArrayType>::tao_marshal_kind (
00120   TAO_OutputCDR & cdr) const
00121 {
00122   ACE_GUARD_RETURN (TAO_SYNCH_RECURSIVE_MUTEX,
00123                     guard,
00124                     this->lock_,
00125                     false);
00126 
00127   // Top-level TypeCode case.
00128   if (!(this->in_recursion_))
00129     return this->::CORBA::TypeCode::tao_marshal_kind (cdr);
00130 
00131   // Recursive/indirected TypeCode case.
00132   CORBA::ULong const indirection_kind = 0xffffffff;
00133 
00134   return (cdr << indirection_kind);
00135 }
00136 
00137 TAO_END_VERSIONED_NAMESPACE_DECL

Generated on Sun Jan 27 13:21:06 2008 for TAO_AnyTypeCode by doxygen 1.3.6