Revert "Minor modernization of DynamicAny code"
[ACE_TAO.git] / TAO / tao / Tagged_Profile.cpp
blob2731ea66fb469f804f4245df446f66fdfd8d036d
1 #include "tao/Tagged_Profile.h"
2 #include "tao/ORB_Core.h"
3 #include "tao/Acceptor_Registry.h"
4 #include "tao/Transport_Acceptor.h"
5 #include "tao/Thread_Lane_Resources.h"
6 #include "tao/debug.h"
7 #include "tao/target_specification.h"
8 #include "tao/CDR.h"
10 #if !defined (__ACE_INLINE__)
11 # include "tao/Tagged_Profile.inl"
12 #endif /* ! __ACE_INLINE__ */
14 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
16 CORBA::Boolean
17 TAO_Tagged_Profile::extract_object_key (IOP::TaggedProfile &profile)
19 // Get our Acceptor registry
20 TAO_Acceptor_Registry &acceptor_registry =
21 this->orb_core_->lane_resources ().acceptor_registry ();
23 // Get the right acceptor for the tag in the TaggedProfile
24 TAO_Acceptor *acceptor = acceptor_registry.get_acceptor (profile.tag);
26 if (acceptor)
28 // Get the object key
29 if (acceptor->object_key (profile, this->object_key_) == -1)
31 return false;
34 else
36 if (TAO_debug_level)
38 TAOLIB_ERROR ((LM_ERROR,
39 ACE_TEXT ("(%P|%t)TAO_Tagged_Profile\n")));
42 return false;
45 return true;
48 CORBA::Boolean
49 TAO_Tagged_Profile::unmarshall_target_address (TAO_InputCDR &cdr)
51 CORBA::Boolean hdr_status = cdr.read_short (this->discriminator_);
53 if (hdr_status)
55 switch (this->discriminator_)
57 case TAO_Target_Specification::Key_Addr:
58 hdr_status = this->unmarshall_object_key_i (cdr);
59 break;
61 case TAO_Target_Specification::Profile_Addr:
62 hdr_status = this->unmarshall_iop_profile_i (cdr);
63 break;
65 case TAO_Target_Specification::Reference_Addr:
66 hdr_status = this->unmarshall_ref_addr_i (cdr);
67 break;
69 default:
70 hdr_status = false;
71 break;
75 return hdr_status;
78 CORBA::Boolean
79 TAO_Tagged_Profile::unmarshall_object_key (TAO_InputCDR &input)
81 this->discriminator_ = TAO_Target_Specification::Key_Addr;
83 return this->unmarshall_object_key_i (input);
87 CORBA::Boolean
88 TAO_Tagged_Profile::unmarshall_object_key_i (TAO_InputCDR &input)
90 CORBA::Boolean hdr_status = input.good_bit ();
92 CORBA::Long key_length = 0;
93 hdr_status = hdr_status && input.read_long (key_length);
95 if (hdr_status)
97 this->object_key_.replace (key_length,
98 key_length,
99 (CORBA::Octet*)input.rd_ptr (),
101 input.skip_bytes (key_length);
103 this->object_key_extracted_ = true;
106 return hdr_status;
110 CORBA::Boolean
111 TAO_Tagged_Profile::unmarshall_iop_profile_i (TAO_InputCDR &input)
113 CORBA::Boolean hdr_status = input.good_bit ();
115 // Extract into the IOP::Tagged profile.
116 hdr_status &= input >> this->profile_;
118 return hdr_status;
121 CORBA::Boolean
122 TAO_Tagged_Profile::unmarshall_ref_addr_i (TAO_InputCDR &input)
124 CORBA::Boolean hdr_status = input.good_bit ();
127 * The GIOP::IORAddressingInfo is defined as follows
128 * struct IORAddressingInfo
130 * unsigned long selected_profile_index;
131 * IOP::IOR ior;
132 * };
134 * and the IOP::IOR is defined to be
135 * struct IOR
137 * string type_id;
138 * sequence<TaggedProfile> profiles;
139 * };
142 // First read the profile index
143 CORBA::ULong prof_index = 0;
145 hdr_status = hdr_status && input.read_ulong (prof_index);
147 // Set the value in TAO_Tagged_Profile
148 if (hdr_status)
150 this->profile_index_ = prof_index;
153 // Get the length of the type_id
154 CORBA::Long id_length = 0;
155 hdr_status = hdr_status && input.read_long (id_length);
157 if (hdr_status)
159 // Set the type_id (it is not owned by this object)
160 this->type_id_ = input.rd_ptr ();
162 input.skip_bytes (id_length);
165 // Unmarshall the sequence of TaggedProfiles
166 IOP::TaggedProfileSeq ior_profiles;
168 hdr_status &= input >> ior_profiles;
170 // Get the right TaggedProfile from the <ior_profiles>
171 if (hdr_status)
173 this->profile_ = ior_profiles [prof_index];
176 return hdr_status;
179 TAO_END_VERSIONED_NAMESPACE_DECL