Objref_TypeCode.cpp

Go to the documentation of this file.
00001 // $Id: Objref_TypeCode.cpp 76874 2007-02-02 14:12:41Z johnnyw $
00002 
00003 #ifndef TAO_OBJREF_TYPECODE_CPP
00004 #define TAO_OBJREF_TYPECODE_CPP
00005 
00006 #include "tao/AnyTypeCode/Objref_TypeCode.h"
00007 
00008 #ifndef __ACE_INLINE__
00009 # include "tao/AnyTypeCode/Objref_TypeCode.inl"
00010 #endif  /* !__ACE_INLINE__ */
00011 
00012 #include "tao/CDR.h"
00013 #include "tao/ORB_Core.h"
00014 
00015 #include "ace/OS_NS_string.h"
00016 
00017 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00018 
00019 template <typename StringType, class RefCountPolicy>
00020 bool
00021 TAO::TypeCode::Objref<StringType, RefCountPolicy>::tao_marshal (
00022   TAO_OutputCDR & cdr,
00023   CORBA::ULong) const
00024 {
00025   // A tk_objref TypeCode has a "complex" parameter list type (see
00026   // Table 15-2 in Section 15.3.5.1 "TypeCode" in the CDR section of
00027   // the CORBA specification), meaning that it must be marshaled into
00028   // a CDR encapsulation.
00029 
00030   // Create a CDR encapsulation.
00031   TAO_OutputCDR enc;
00032 
00033   return
00034     enc << TAO_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER)
00035     && enc << TAO_OutputCDR::from_string (this->attributes_.id (), 0)
00036     && enc << TAO_OutputCDR::from_string (this->attributes_.name (), 0)
00037     && cdr << static_cast<CORBA::ULong> (enc.total_length ())
00038     && cdr.write_octet_array_mb (enc.begin ());
00039 }
00040 
00041 template <typename StringType, class RefCountPolicy>
00042 void
00043 TAO::TypeCode::Objref<StringType, RefCountPolicy>::tao_duplicate (void)
00044 {
00045   this->RefCountPolicy::add_ref ();
00046 }
00047 
00048 template <typename StringType, class RefCountPolicy>
00049 void
00050 TAO::TypeCode::Objref<StringType, RefCountPolicy>::tao_release (void)
00051 {
00052   this->RefCountPolicy::remove_ref ();
00053 }
00054 
00055 template <typename StringType, class RefCountPolicy>
00056 CORBA::Boolean
00057 TAO::TypeCode::Objref<StringType, RefCountPolicy>::equal_i (
00058   CORBA::TypeCode_ptr /* tc */) const
00059 {
00060   // Equality has already been established in the
00061   // CORBA::TypeCode base class.
00062 
00063   return true;
00064 }
00065 
00066 template <typename StringType, class RefCountPolicy>
00067 CORBA::Boolean
00068 TAO::TypeCode::Objref<StringType, RefCountPolicy>::equivalent_i (
00069   CORBA::TypeCode_ptr) const
00070 {
00071   // Equivalence already verified in the base class
00072   // CORBA::TypeCode::equivalent() method.
00073 
00074   return true;
00075 }
00076 
00077 template <typename StringType, class RefCountPolicy>
00078 CORBA::TypeCode_ptr
00079 TAO::TypeCode::Objref<StringType,
00080                       RefCountPolicy>::get_compact_typecode_i (void) const
00081 {
00082   TAO_TypeCodeFactory_Adapter * const adapter =
00083     ACE_Dynamic_Service<TAO_TypeCodeFactory_Adapter>::instance (
00084         TAO_ORB_Core::typecodefactory_adapter_name ()
00085       );
00086 
00087   if (adapter == 0)
00088     {
00089       throw ::CORBA::INTERNAL ();
00090     }
00091 
00092   if (this->kind_ == CORBA::tk_abstract_interface)
00093     {
00094       return adapter->create_abstract_interface_tc (this->attributes_.id (),
00095                                                     ""  /* empty name */);
00096     }
00097   else if (this->kind_ == CORBA::tk_component)
00098     {
00099       return adapter->create_component_tc (this->attributes_.id (),
00100                                            ""  /* empty name */);
00101     }
00102   else if (this->kind_ == CORBA::tk_home)
00103     {
00104       return adapter->create_home_tc (this->attributes_.id (),
00105                                       ""  /* empty name */);
00106     }
00107   else if (this->kind_ == CORBA::tk_local_interface)
00108     {
00109       return adapter->create_local_interface_tc (this->attributes_.id (),
00110                                                  ""  /* empty name */);
00111 
00112     }
00113   else if (this->kind_ == CORBA::tk_native)
00114     {
00115       return adapter->create_native_tc (this->attributes_.id (),
00116                                         ""  /* empty name */);
00117     }
00118   else // CORBA::tk_objref
00119     {
00120       return adapter->create_interface_tc (this->attributes_.id (),
00121                                            ""  /* empty name */);
00122     }
00123 }
00124 
00125 template <typename StringType, class RefCountPolicy>
00126 char const *
00127 TAO::TypeCode::Objref<StringType, RefCountPolicy>::id_i (void) const
00128 {
00129   // Ownership is retained by the TypeCode, as required by the C++
00130   // mapping.
00131   return this->attributes_.id ();
00132 }
00133 
00134 template <typename StringType, class RefCountPolicy>
00135 char const *
00136 TAO::TypeCode::Objref<StringType, RefCountPolicy>::name_i (void) const
00137 {
00138   // Ownership is retained by the TypeCode, as required by the C++
00139   // mapping.
00140   return this->attributes_.name ();
00141 }
00142 
00143 TAO_END_VERSIONED_NAMESPACE_DECL
00144 
00145 #endif  /*  TAO_OBJREF_TYPECODE_CPP */

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