00001 // Tagged_Profile.cpp,v 1.9 2005/11/02 11:03:27 ossama Exp 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.i" 00014 #endif /* ! __ACE_INLINE__ */ 00015 00016 ACE_RCSID (tao, 00017 Tagged_Profile, 00018 "Tagged_Profile.cpp,v 1.9 2005/11/02 11:03:27 ossama Exp") 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 = 00031 acceptor_registry.get_acceptor (profile.tag); 00032 00033 if (acceptor) 00034 { 00035 // Get the object key 00036 int retval = 00037 acceptor->object_key (profile, 00038 this->object_key_); 00039 if (retval == -1) 00040 { 00041 return 0; 00042 } 00043 } 00044 else 00045 { 00046 if (TAO_debug_level) 00047 { 00048 ACE_ERROR ((LM_ERROR, 00049 ACE_TEXT ("(%P|%t)TAO_Tagged_Profile \n"))); 00050 } 00051 00052 return 0; 00053 } 00054 00055 return 1; 00056 } 00057 00058 CORBA::Boolean 00059 TAO_Tagged_Profile::unmarshall_target_address (TAO_InputCDR &cdr) 00060 { 00061 CORBA::Boolean hdr_status = cdr.read_short (this->discriminator_); 00062 00063 if (hdr_status) 00064 { 00065 switch (this->discriminator_) 00066 { 00067 case TAO_Target_Specification::Key_Addr: 00068 hdr_status = this->unmarshall_object_key_i (cdr); 00069 break; 00070 00071 case TAO_Target_Specification::Profile_Addr: 00072 hdr_status = this->unmarshall_iop_profile_i (cdr); 00073 break; 00074 00075 case TAO_Target_Specification::Reference_Addr: 00076 hdr_status = this->unmarshall_ref_addr_i (cdr); 00077 break; 00078 00079 default: 00080 hdr_status = 0; 00081 break; 00082 } 00083 } 00084 00085 return hdr_status; 00086 } 00087 00088 CORBA::Boolean 00089 TAO_Tagged_Profile::unmarshall_object_key ( 00090 TAO_InputCDR &input) 00091 { 00092 this->discriminator_ = TAO_Target_Specification::Key_Addr; 00093 00094 return this->unmarshall_object_key_i (input); 00095 } 00096 00097 00098 CORBA::Boolean 00099 TAO_Tagged_Profile::unmarshall_object_key_i ( 00100 TAO_InputCDR &input) 00101 { 00102 CORBA::Boolean hdr_status = 00103 (CORBA::Boolean) input.good_bit (); 00104 00105 CORBA::Long key_length = 0; 00106 hdr_status = hdr_status && input.read_long (key_length); 00107 00108 if (hdr_status) 00109 { 00110 this->object_key_.replace (key_length, 00111 key_length, 00112 (CORBA::Octet*)input.rd_ptr (), 00113 0); 00114 input.skip_bytes (key_length); 00115 00116 this->object_key_extracted_ = 1; 00117 } 00118 00119 return hdr_status; 00120 } 00121 00122 00123 CORBA::Boolean 00124 TAO_Tagged_Profile::unmarshall_iop_profile_i ( 00125 TAO_InputCDR &input) 00126 { 00127 CORBA::Boolean hdr_status = 00128 (CORBA::Boolean) input.good_bit (); 00129 00130 // Extract into the IOP::Tagged profile. 00131 hdr_status &= input >> this->profile_; 00132 00133 return hdr_status; 00134 } 00135 00136 CORBA::Boolean 00137 TAO_Tagged_Profile::unmarshall_ref_addr_i ( 00138 TAO_InputCDR &input) 00139 { 00140 CORBA::Boolean hdr_status = 00141 (CORBA::Boolean) input.good_bit (); 00142 00143 /* 00144 * The GIOP::IORAddressingInfo is defined as follows 00145 * struct IORAddressingInfo 00146 * { 00147 * unsigned long selected_profile_index; 00148 * IOP::IOR ior; 00149 * }; 00150 * 00151 * and the IOP::IOR is defined to be 00152 * struct IOR 00153 * { 00154 * string type_id; 00155 * sequence<TaggedProfile> profiles; 00156 * }; 00157 */ 00158 00159 // First read the profile index 00160 CORBA::ULong prof_index = 0; 00161 00162 hdr_status = 00163 hdr_status && input.read_ulong (prof_index); 00164 00165 // Set the value in TAO_Tagged_Profile 00166 if (hdr_status) 00167 { 00168 this->profile_index_ = prof_index; 00169 } 00170 00171 // Get the length of the type_id 00172 CORBA::Long id_length = 0; 00173 hdr_status = hdr_status && input.read_long (id_length); 00174 00175 if (hdr_status) 00176 { 00177 // Set the type_id 00178 this->type_id_.set (input.rd_ptr (), 00179 0); 00180 00181 input.skip_bytes (id_length); 00182 } 00183 00184 // Unmarshall the sequnce of TaggedProfiles 00185 IOP::TaggedProfileSeq ior_profiles; 00186 00187 hdr_status &= input >> ior_profiles; 00188 00189 // Get the right TaggedProfile from the <ior_profiles> 00190 if (hdr_status) 00191 { 00192 this->profile_ = ior_profiles [prof_index]; 00193 } 00194 00195 return hdr_status; 00196 } 00197 00198 TAO_END_VERSIONED_NAMESPACE_DECL