Sequence_TypeCode_Static.cpp

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

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