Sequence_TypeCode.cpp

Go to the documentation of this file.
00001 // $Id: Sequence_TypeCode.cpp 76551 2007-01-24 13:42:44Z johnnyw $
00002 
00003 #ifndef TAO_SEQUENCE_TYPECODE_CPP
00004 #define TAO_SEQUENCE_TYPECODE_CPP
00005 
00006 #include "tao/AnyTypeCode/Sequence_TypeCode.h"
00007 #include "tao/CDR.h"
00008 #include "tao/AnyTypeCode/TypeCode_Traits.h"
00009 
00010 #ifndef __ACE_INLINE__
00011 # include "tao/AnyTypeCode/Sequence_TypeCode.inl"
00012 #endif  /* !__ACE_INLINE__ */
00013 
00014 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00015 
00016 template <typename TypeCodeType, class RefCountPolicy>
00017 bool
00018 TAO::TypeCode::Sequence<TypeCodeType, RefCountPolicy>::tao_marshal (
00019   TAO_OutputCDR & cdr,
00020   CORBA::ULong offset) const
00021 {
00022   // A tk_array or tk_sequence TypeCode has a "complex" parameter list
00023   // type (see Table 15-2 in Section 15.3.5.1 "TypeCode" in the CDR
00024   // section of the CORBA specification), meaning that it must be
00025   // marshaled into a CDR encapsulation.
00026 
00027   // Create a CDR encapsulation.
00028   TAO_OutputCDR enc;
00029 
00030   // Account for the encoded CDR encapsulation length and byte order.
00031   //
00032   // Aligning on an octet since the next value after the CDR
00033   // encapsulation length will always be the byte order octet/boolean
00034   // in this case.
00035   offset = ACE_align_binary (offset + 4,
00036                              ACE_CDR::OCTET_ALIGN);
00037 
00038   return
00039     enc << TAO_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER)
00040     && marshal (enc,
00041                 Traits<TypeCodeType>::get_typecode (this->content_type_),
00042                 offset + enc.total_length ())
00043     && enc << this->length_
00044     && cdr << static_cast<CORBA::ULong> (enc.total_length ())
00045     && cdr.write_octet_array_mb (enc.begin ());
00046 }
00047 
00048 template <typename TypeCodeType, class RefCountPolicy>
00049 void
00050 TAO::TypeCode::Sequence<TypeCodeType, RefCountPolicy>::tao_duplicate (void)
00051 {
00052   this->RefCountPolicy::add_ref ();
00053 }
00054 
00055 template <typename TypeCodeType, class RefCountPolicy>
00056 void
00057 TAO::TypeCode::Sequence<TypeCodeType, RefCountPolicy>::tao_release (void)
00058 {
00059   this->RefCountPolicy::remove_ref ();
00060 }
00061 
00062 template <typename TypeCodeType, class RefCountPolicy>
00063 CORBA::Boolean
00064 TAO::TypeCode::Sequence<TypeCodeType,
00065                         RefCountPolicy>::equal_i (CORBA::TypeCode_ptr tc
00066                                                   ) const
00067 {
00068   // The following calls won't throw since CORBA::TypeCode::equal()
00069   // has already established the kind of tc is the same as our kind.
00070   CORBA::ULong const tc_length = tc->length ();
00071 
00072   if (this->length_ != tc_length)
00073     return 0;
00074 
00075   CORBA::TypeCode_var rhs_content_type =
00076     tc->content_type ();
00077 
00078   return
00079     Traits<TypeCodeType>::get_typecode (this->content_type_)->equal (
00080       rhs_content_type.in ()
00081      );
00082 }
00083 
00084 template <typename TypeCodeType, class RefCountPolicy>
00085 CORBA::Boolean
00086 TAO::TypeCode::Sequence<TypeCodeType,
00087                         RefCountPolicy>::equivalent_i (CORBA::TypeCode_ptr tc
00088                                                        ) const
00089 {
00090   // The following calls won't throw since CORBA::TypeCode::equal()
00091   // has already established the kind of tc is the same as our kind.
00092   CORBA::ULong const tc_length = tc->length ();
00093 
00094   if (this->length_ != tc_length)
00095     return 0;
00096 
00097   CORBA::TypeCode_var rhs_content_type =
00098     tc->content_type ();
00099 
00100   return
00101     Traits<TypeCodeType>::get_typecode (this->content_type_)->equivalent (
00102       rhs_content_type.in ()
00103      );
00104 }
00105 
00106 template <typename TypeCodeType, class RefCountPolicy>
00107 CORBA::TypeCode_ptr
00108 TAO::TypeCode::Sequence<TypeCodeType, RefCountPolicy>::get_compact_typecode_i (
00109   void) const
00110 {
00111   // Already compact since tk_sequence and tk_array TypeCodes have no
00112   // name or member names, meaning that we can simply call
00113   // _duplicate() on this TypeCode.
00114 
00115   // @@ There is a potential problem here if this TypeCode is a static
00116   //    and const since it may have been placed in read-only memory by
00117   //    the compiler.  A const_cast<> can return undefined results in
00118   //    that case.
00119 
00120   CORBA::TypeCode_ptr mutable_tc =
00121     const_cast<TAO::TypeCode::Sequence<TypeCodeType, RefCountPolicy> *> (this);
00122 
00123   return CORBA::TypeCode::_duplicate (mutable_tc);
00124 }
00125 
00126 template <typename TypeCodeType, class RefCountPolicy>
00127 CORBA::ULong
00128 TAO::TypeCode::Sequence<TypeCodeType, RefCountPolicy>::length_i (
00129   void) const
00130 {
00131   return this->length_;
00132 }
00133 
00134 template <typename TypeCodeType, class RefCountPolicy>
00135 CORBA::TypeCode_ptr
00136 TAO::TypeCode::Sequence<TypeCodeType, RefCountPolicy>::content_type_i (
00137   void) const
00138 {
00139   return
00140     CORBA::TypeCode::_duplicate (
00141       Traits<TypeCodeType>::get_typecode (this->content_type_));
00142 }
00143 
00144 TAO_END_VERSIONED_NAMESPACE_DECL
00145 
00146 #endif  /* TAO_SEQUENCE_TYPECODE_CPP */

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