Alias_TypeCode_Static.cpp

Go to the documentation of this file.
00001 // $Id: Alias_TypeCode_Static.cpp 76995 2007-02-11 12:51:42Z johnnyw $
00002 
00003 #include "tao/AnyTypeCode/Alias_TypeCode_Static.h"
00004 
00005 #ifndef __ACE_INLINE__
00006 # include "tao/AnyTypeCode/Alias_TypeCode_Static.inl"
00007 #endif  /* !__ACE_INLINE__ */
00008 
00009 #include "tao/AnyTypeCode/TypeCode_Traits.h"
00010 
00011 #include "tao/ORB_Core.h"
00012 #include "tao/CDR.h"
00013 #include "tao/TypeCodeFactory_Adapter.h"
00014 #include "tao/SystemException.h"
00015 
00016 #include "ace/Dynamic_Service.h"
00017 
00018 ACE_RCSID (AnyTypeCode,
00019            Alias_TypeCode_Static,
00020            "$Id: Alias_TypeCode_Static.cpp 76995 2007-02-11 12:51:42Z johnnyw $")
00021 
00022 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00023 
00024 bool
00025 TAO::TypeCode::Alias<char const *,
00026                      CORBA::TypeCode_ptr const *,
00027                      TAO::Null_RefCount_Policy>::tao_marshal (
00028   TAO_OutputCDR & cdr,
00029   CORBA::ULong offset) const
00030 {
00031   // A tk_alias TypeCode has a "complex" parameter list type (see
00032   // Table 15-2 in Section 15.3.5.1 "TypeCode" in the CDR section of
00033   // the CORBA specification), meaning that it must be marshaled into
00034   // a CDR encapsulation.
00035 
00036   // Create a CDR encapsulation.
00037 
00038   TAO_OutputCDR enc;
00039 
00040   // Account for the encoded CDR encapsulation length and byte order.
00041   //
00042   // Aligning on an octet since the next value after the CDR
00043   // encapsulation length will always be the byte order octet/boolean
00044   // in this case.
00045   offset = ACE_align_binary (offset + 4,
00046                              ACE_CDR::OCTET_ALIGN);
00047 
00048   return
00049     enc << TAO_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER)
00050     && enc << TAO_OutputCDR::from_string (this->attributes_.id (), 0)
00051     && enc << TAO_OutputCDR::from_string (this->attributes_.name (), 0)
00052     && marshal (enc,
00053                 Traits<char const *>::get_typecode (this->content_type_),
00054                 offset + enc.total_length ())
00055     && cdr << static_cast<CORBA::ULong> (enc.total_length ())
00056     && cdr.write_octet_array_mb (enc.begin ());
00057 }
00058 
00059 void
00060 TAO::TypeCode::Alias<char const *,
00061                      CORBA::TypeCode_ptr const *,
00062                      TAO::Null_RefCount_Policy>::tao_duplicate (void)
00063 {
00064 }
00065 
00066 void
00067 TAO::TypeCode::Alias<char const *,
00068                      CORBA::TypeCode_ptr const *,
00069                      TAO::Null_RefCount_Policy>::tao_release (void)
00070 {
00071 }
00072 
00073 CORBA::Boolean
00074 TAO::TypeCode::Alias<char const *,
00075                      CORBA::TypeCode_ptr const *,
00076                      TAO::Null_RefCount_Policy>::equal_i (
00077   CORBA::TypeCode_ptr tc) const
00078 {
00079   // The CORBA::TypeCode base class already verified equality of the
00080   // base attributes (id and name).  Perform an equality comparison of
00081   // the content.
00082 
00083   CORBA::TypeCode_var rhs_content_type = tc->content_type ();
00084 
00085   return
00086     Traits<char const *>::get_typecode (this->content_type_)->equal (
00087       rhs_content_type.in ());
00088 }
00089 
00090 CORBA::Boolean
00091 TAO::TypeCode::Alias<char const *,
00092                      CORBA::TypeCode_ptr const *,
00093                      TAO::Null_RefCount_Policy>::equivalent_i (
00094   CORBA::TypeCode_ptr) const
00095 {
00096   // Equivalence already verified in the base class
00097   // CORBA::TypeCode::equivalent() method.
00098 
00099   return true;
00100 }
00101 
00102 CORBA::TypeCode_ptr
00103 TAO::TypeCode::Alias<char const *,
00104                      CORBA::TypeCode_ptr const *,
00105                      TAO::Null_RefCount_Policy>::get_compact_typecode_i (
00106   void) const
00107 {
00108   TAO_TypeCodeFactory_Adapter * const adapter =
00109     ACE_Dynamic_Service<TAO_TypeCodeFactory_Adapter>::instance (
00110         TAO_ORB_Core::typecodefactory_adapter_name ()
00111       );
00112 
00113   if (adapter == 0)
00114     {
00115       throw ::CORBA::INITIALIZE ();
00116     }
00117 
00118   CORBA::TypeCode_var compact_content_type =
00119     Traits<char const *>::get_typecode (
00120       this->content_type_)->get_compact_typecode ();
00121 
00122   if (this->kind_ == CORBA::tk_alias)
00123     {
00124       return adapter->create_alias_tc (this->attributes_.id (),
00125                                        "",  /* empty name */
00126                                        compact_content_type.in ());
00127     }
00128   else
00129     {
00130       return adapter->create_value_box_tc (this->attributes_.id (),
00131                                            "",  /* empty name */
00132                                            compact_content_type.in ());
00133     }
00134 }
00135 
00136 char const *
00137 TAO::TypeCode::Alias<char const *,
00138                      CORBA::TypeCode_ptr const *,
00139                      TAO::Null_RefCount_Policy>::id_i (void) const
00140 {
00141   // Ownership is retained by the TypeCode, as required by the C++
00142   // mapping.
00143   return this->attributes_.id ();
00144 }
00145 
00146 char const *
00147 TAO::TypeCode::Alias<char const *,
00148                      CORBA::TypeCode_ptr const *,
00149                      TAO::Null_RefCount_Policy>::name_i (void) const
00150 {
00151   // Ownership is retained by the TypeCode, as required by the C++
00152   // mapping.
00153   return this->attributes_.name ();
00154 }
00155 
00156 CORBA::TypeCode_ptr
00157 TAO::TypeCode::Alias<char const *,
00158                      CORBA::TypeCode_ptr const *,
00159                      TAO::Null_RefCount_Policy>::content_type_i (void) const
00160 {
00161   return
00162      CORBA::TypeCode::_duplicate (
00163        Traits<char const *>::get_typecode (this->content_type_));
00164 }
00165 
00166 TAO_END_VERSIONED_NAMESPACE_DECL

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