00001 // $Id: Tagged_Profile.cpp 78305 2007-05-11 14:07:59Z johnnyw $ 00002 00003 #include "tao/Tagged_Profile.h" 00004 #include "tao/ORB_Core.h" 00005 #include "tao/Acceptor_Registry.h" 00006 #include "tao/Transport_Acceptor.h" 00007 #include "tao/Thread_Lane_Resources.h" 00008 #include "tao/debug.h" 00009 #include "tao/target_specification.h" 00010 #include "tao/CDR.h" 00011 00012 #if !defined (__ACE_INLINE__) 00013 # include "tao/Tagged_Profile.inl" 00014 #endif /* ! __ACE_INLINE__ */ 00015 00016 ACE_RCSID (tao, 00017 Tagged_Profile, 00018 "$Id: Tagged_Profile.cpp 78305 2007-05-11 14:07:59Z johnnyw $") 00019 00020 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00021 00022 CORBA::Boolean 00023 TAO_Tagged_Profile::extract_object_key (IOP::TaggedProfile &profile) 00024 { 00025 // Get our Acceptor registry 00026 TAO_Acceptor_Registry &acceptor_registry = 00027 this->orb_core_->lane_resources ().acceptor_registry (); 00028 00029 // Get the right acceptor for the tag in the TaggedProfile 00030 TAO_Acceptor *acceptor = acceptor_registry.get_acceptor (profile.tag); 00031 00032 if (acceptor) 00033 { 00034 // Get the object key 00035 if (acceptor->object_key (profile, this->object_key_) == -1) 00036 { 00037 return false; 00038 } 00039 } 00040 else 00041 { 00042 if (TAO_debug_level) 00043 { 00044 ACE_ERROR ((LM_ERROR, 00045 ACE_TEXT ("(%P|%t)TAO_Tagged_Profile \n"))); 00046 } 00047 00048 return false; 00049 } 00050 00051 return true; 00052 } 00053 00054 CORBA::Boolean 00055 TAO_Tagged_Profile::unmarshall_target_address (TAO_InputCDR &cdr) 00056 { 00057 CORBA::Boolean hdr_status = cdr.read_short (this->discriminator_); 00058 00059 if (hdr_status) 00060 { 00061 switch (this->discriminator_) 00062 { 00063 case TAO_Target_Specification::Key_Addr: 00064 hdr_status = this->unmarshall_object_key_i (cdr); 00065 break; 00066 00067 case TAO_Target_Specification::Profile_Addr: 00068 hdr_status = this->unmarshall_iop_profile_i (cdr); 00069 break; 00070 00071 case TAO_Target_Specification::Reference_Addr: 00072 hdr_status = this->unmarshall_ref_addr_i (cdr); 00073 break; 00074 00075 default: 00076 hdr_status = false; 00077 break; 00078 } 00079 } 00080 00081 return hdr_status; 00082 } 00083 00084 CORBA::Boolean 00085 TAO_Tagged_Profile::unmarshall_object_key (TAO_InputCDR &input) 00086 { 00087 this->discriminator_ = TAO_Target_Specification::Key_Addr; 00088 00089 return this->unmarshall_object_key_i (input); 00090 } 00091 00092 00093 CORBA::Boolean 00094 TAO_Tagged_Profile::unmarshall_object_key_i (TAO_InputCDR &input) 00095 { 00096 CORBA::Boolean hdr_status = (CORBA::Boolean) input.good_bit (); 00097 00098 CORBA::Long key_length = 0; 00099 hdr_status = hdr_status && input.read_long (key_length); 00100 00101 if (hdr_status) 00102 { 00103 this->object_key_.replace (key_length, 00104 key_length, 00105 (CORBA::Octet*)input.rd_ptr (), 00106 0); 00107 input.skip_bytes (key_length); 00108 00109 this->object_key_extracted_ = true; 00110 } 00111 00112 return hdr_status; 00113 } 00114 00115 00116 CORBA::Boolean 00117 TAO_Tagged_Profile::unmarshall_iop_profile_i (TAO_InputCDR &input) 00118 { 00119 CORBA::Boolean hdr_status = (CORBA::Boolean) input.good_bit (); 00120 00121 // Extract into the IOP::Tagged profile. 00122 hdr_status &= input >> this->profile_; 00123 00124 return hdr_status; 00125 } 00126 00127 CORBA::Boolean 00128 TAO_Tagged_Profile::unmarshall_ref_addr_i (TAO_InputCDR &input) 00129 { 00130 CORBA::Boolean hdr_status = (CORBA::Boolean) input.good_bit (); 00131 00132 /* 00133 * The GIOP::IORAddressingInfo is defined as follows 00134 * struct IORAddressingInfo 00135 * { 00136 * unsigned long selected_profile_index; 00137 * IOP::IOR ior; 00138 * }; 00139 * 00140 * and the IOP::IOR is defined to be 00141 * struct IOR 00142 * { 00143 * string type_id; 00144 * sequence<TaggedProfile> profiles; 00145 * }; 00146 */ 00147 00148 // First read the profile index 00149 CORBA::ULong prof_index = 0; 00150 00151 hdr_status = hdr_status && input.read_ulong (prof_index); 00152 00153 // Set the value in TAO_Tagged_Profile 00154 if (hdr_status) 00155 { 00156 this->profile_index_ = prof_index; 00157 } 00158 00159 // Get the length of the type_id 00160 CORBA::Long id_length = 0; 00161 hdr_status = hdr_status && input.read_long (id_length); 00162 00163 if (hdr_status) 00164 { 00165 // Set the type_id (it is not owned by this object) 00166 this->type_id_ = input.rd_ptr (); 00167 00168 input.skip_bytes (id_length); 00169 } 00170 00171 // Unmarshall the sequnce of TaggedProfiles 00172 IOP::TaggedProfileSeq ior_profiles; 00173 00174 hdr_status &= input >> ior_profiles; 00175 00176 // Get the right TaggedProfile from the <ior_profiles> 00177 if (hdr_status) 00178 { 00179 this->profile_ = ior_profiles [prof_index]; 00180 } 00181 00182 return hdr_status; 00183 } 00184 00185 TAO_END_VERSIONED_NAMESPACE_DECL