#include <IORManipulation.h>
Inheritance diagram for TAO_IOR_Manipulation_impl:
Definition at line 38 of file IORManipulation.h.
TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_IOR_Manipulation_impl::TAO_IOR_Manipulation_impl | ( | void | ) |
TAO_IOR_Manipulation_impl::~TAO_IOR_Manipulation_impl | ( | void | ) | [protected] |
CORBA::Object_ptr TAO_IOR_Manipulation_impl::add_profiles | ( | CORBA::Object_ptr | ior1, | |
CORBA::Object_ptr | ior2 | |||
) | [virtual] |
Definition at line 118 of file IORManipulation.cpp.
References merge_iors().
00121 { 00122 00123 // Get an estimate of the number of profiles 00124 CORBA::Object_ptr buffer [2]; 00125 buffer [0] = ior1; 00126 buffer [1] = ior2; 00127 TAO_IOP::TAO_IOR_Manipulation::IORList iors (2, 2, buffer, 0); 00128 return this->merge_iors (iors); 00129 }
CORBA::Object_ptr TAO_IOR_Manipulation_impl::get_primary | ( | TAO_IOP::TAO_IOR_Property_ptr | prop, | |
CORBA::Object_ptr | group | |||
) | [virtual] |
Definition at line 246 of file IORManipulation.cpp.
References CORBA::Object::_stubobj(), TAO_Stub::base_profiles(), and TAO_MProfile::profile_count().
00249 { 00250 // make sure we have some profiles in IOR 00251 if (group->_stubobj ()->base_profiles ().profile_count () == 0) 00252 throw TAO_IOP::NotFound (); 00253 // @@ Bala: this was throwing TAO_IOP::Invalid_IOR, but it was not 00254 // in the throw spec, that will result in a CORBA::UNKNOWN at 00255 // run-time (if it does not crash). Any idea about what is going on 00256 // here? 00257 00258 return prop->get_primary (group); 00259 }
CORBA::ULong TAO_IOR_Manipulation_impl::get_profile_count | ( | CORBA::Object_ptr | group | ) | [virtual] |
Definition at line 305 of file IORManipulation.cpp.
References CORBA::Object::_stubobj(), TAO_Stub::base_profiles(), and TAO_MProfile::profile_count().
00306 { 00307 CORBA::ULong const count = group->_stubobj ()->base_profiles ().profile_count (); 00308 00309 if (count == 0) 00310 throw TAO_IOP::EmptyProfileList (); 00311 00312 return count; 00313 }
CORBA::ULong TAO_IOR_Manipulation_impl::is_in_ior | ( | CORBA::Object_ptr | ior1, | |
CORBA::Object_ptr | ior2 | |||
) | [virtual] |
Definition at line 278 of file IORManipulation.cpp.
References CORBA::Object::_stubobj(), TAO_Profile::is_equivalent(), and TAO_Stub::make_profiles().
00281 { 00282 CORBA::ULong count = 0; 00283 TAO_Profile *pfile1 = 0, *pfile2 = 0; 00284 auto_ptr<TAO_MProfile> tmp_pfiles1 (ior1->_stubobj ()->make_profiles ()); 00285 auto_ptr<TAO_MProfile> tmp_pfiles2 (ior2->_stubobj ()->make_profiles ()); 00286 00287 tmp_pfiles1->rewind (); 00288 while ((pfile1 = tmp_pfiles1->get_next ()) > 0) 00289 { 00290 tmp_pfiles2->rewind (); 00291 while ((pfile2 = tmp_pfiles2->get_next ()) > 0) 00292 { 00293 if (pfile1->is_equivalent (pfile2)) 00294 ++count; 00295 } 00296 } 00297 00298 if (count == 0) 00299 throw TAO_IOP::NotFound (); 00300 00301 return count; 00302 }
CORBA::Boolean TAO_IOR_Manipulation_impl::is_primary_set | ( | TAO_IOP::TAO_IOR_Property_ptr | prop, | |
CORBA::Object_ptr | group | |||
) | [virtual] |
CORBA::Object_ptr TAO_IOR_Manipulation_impl::merge_iors | ( | const TAO_IOP::TAO_IOR_Manipulation::IORList & | iors | ) | [virtual] |
Definition at line 27 of file IORManipulation.cpp.
References CORBA::Object::_nil(), CORBA::Object::_stubobj(), ACE_AUTO_PTR_RESET, ACE_NEW_THROW_EX, TAO_MProfile::add_profiles(), TAO_Stub::base_profiles(), TAO_ORB_Core::create_stub(), TAO_Stub_Auto_Ptr::get(), ACE_Auto_Basic_Ptr< X >::get(), TAO_MProfile::is_equivalent(), CORBA::is_nil(), CORBA::Object::orb_core(), TAO_MProfile::profile_count(), TAO_Stub_Auto_Ptr::release(), ACE_OS::strcmp(), CORBA::string_dup(), and TAO_ORB_Core_instance().
Referenced by add_profiles().
00029 { 00030 // we need to create a new CORBA::Object which has the union of the 00031 // two profile lists. However, if any profiles are duplicates (i.e. in 00032 // bott lisis) then an exception is raised. 00033 00034 // Deterinine how many profiles we have 00035 // Get an estimate of the size - pfile count could change since we 00036 // neither lock nor get a copy in this loop. 00037 CORBA::ULong i, count=0; 00038 for (i = 0; i < iors.length (); i++) 00039 { 00040 count += iors[i]->_stubobj ()->base_profiles ().profile_count (); 00041 } 00042 00043 // make sure we have some profiles 00044 if (count == 0) 00045 throw TAO_IOP::EmptyProfileList (); 00046 00047 // initialize with estimated pfile count. 00048 TAO_MProfile Merged_Profiles (count); 00049 00050 // get the profile lists, start by initialize the composite reference 00051 // by using the first Object. Then for each subsequent Object verify 00052 // they are the same type and they do not have duplicate profiles. 00053 auto_ptr<TAO_MProfile> tmp_pfiles (iors[0]->_stubobj ()->make_profiles ()); 00054 if (Merged_Profiles.add_profiles (tmp_pfiles.get ())< 0) 00055 throw TAO_IOP::Invalid_IOR (); 00056 CORBA::String_var id = 00057 CORBA::string_dup (iors[0]->_stubobj ()->type_id.in ()); 00058 00059 for (i = 1; i < iors.length () ; i++) 00060 { 00061 // this gets a copy of the MProfile, hense the auto_ptr; 00062 00063 ACE_AUTO_PTR_RESET (tmp_pfiles, 00064 iors[i]->_stubobj ()->make_profiles (), 00065 TAO_MProfile); 00066 00067 // check to see if any of the profile in tmp_pfiles are already 00068 // in Merged_Profiles. If so raise exception. 00069 if (Merged_Profiles.is_equivalent (tmp_pfiles.get ())) 00070 throw TAO_IOP::Duplicate (); 00071 00072 // If the object type_id's differ then raise an exception. 00073 if (id.in () && iors[i]->_stubobj ()->type_id.in () && 00074 ACE_OS::strcmp (id.in (), iors[i]->_stubobj ()->type_id.in ())) 00075 throw TAO_IOP::Invalid_IOR (); 00076 00077 // append profiles 00078 if (Merged_Profiles.add_profiles (tmp_pfiles.get ()) < 0) 00079 throw TAO_IOP::Invalid_IOR (); 00080 00081 } 00082 00083 // MS C++ knows nothing about reset! 00084 // tmp_pfiles.reset (0); // get rid of last MProfile 00085 00086 TAO_ORB_Core *orb_core = TAO_ORB_Core_instance (); 00087 00088 TAO_Stub *stub = orb_core->create_stub (id.in (), // give the id string 00089 Merged_Profiles); 00090 00091 // Make the stub memory allocation exception safe for the duration 00092 // of this method. 00093 TAO_Stub_Auto_Ptr safe_stub (stub); 00094 00095 // Create the CORBA level proxy 00096 CORBA::Object_ptr temp_obj = CORBA::Object::_nil (); 00097 ACE_NEW_THROW_EX (temp_obj, 00098 CORBA::Object (safe_stub.get ()), 00099 CORBA::NO_MEMORY ()); 00100 00101 CORBA::Object_var new_obj = temp_obj; 00102 00103 00104 // Clean up in case of errors. 00105 if (CORBA::is_nil (new_obj.in ())) 00106 { 00107 throw TAO_IOP::Invalid_IOR (); 00108 } 00109 00110 // Release ownership of the pointers protected by the auto_ptrs since they 00111 // no longer need to be protected by this point. 00112 stub = safe_stub.release (); 00113 00114 return new_obj._retn (); 00115 }
CORBA::Boolean TAO_IOR_Manipulation_impl::remove_primary_tag | ( | TAO_IOP::TAO_IOR_Property_ptr | prop, | |
CORBA::Object_ptr | iogr | |||
) | [virtual] |
CORBA::Object_ptr TAO_IOR_Manipulation_impl::remove_profiles | ( | CORBA::Object_ptr | group, | |
CORBA::Object_ptr | ior2 | |||
) | [virtual] |
Definition at line 132 of file IORManipulation.cpp.
References CORBA::Object::_nil(), CORBA::Object::_stubobj(), ACE_AUTO_PTR_RESET, ACE_NEW_THROW_EX, TAO_MProfile::add_profiles(), TAO_Stub::base_profiles(), TAO_ORB_Core::create_stub(), TAO_Stub_Auto_Ptr::get(), CORBA::is_nil(), TAO_Stub::make_profiles(), CORBA::Object::orb_core(), TAO_MProfile::profile_count(), TAO_Stub_Auto_Ptr::release(), ACE_OS::strcmp(), CORBA::string_dup(), TAO_ORB_Core_instance(), and TAO_Stub::type_id.
00136 { 00137 // First verify they are the same type! 00138 CORBA::String_var id = 00139 CORBA::string_dup (group->_stubobj ()->type_id.in ()); 00140 if (id.in () && ior2->_stubobj ()->type_id.in () && 00141 ACE_OS::strcmp (id.in (), ior2->_stubobj ()->type_id.in ())) 00142 throw TAO_IOP::Invalid_IOR (); 00143 00144 // Since we are removing from group ... 00145 CORBA::ULong count = group->_stubobj ()->base_profiles ().profile_count (); 00146 00147 // make sure we have some profiles 00148 if (count == 0 || 00149 ior2->_stubobj ()->base_profiles ().profile_count () == 0) 00150 throw TAO_IOP::EmptyProfileList (); 00151 00152 // initialize with estimated pfile count. 00153 TAO_MProfile Diff_Profiles (count); 00154 00155 auto_ptr<TAO_MProfile> tmp_pfiles (group->_stubobj ()->make_profiles ()); 00156 if (Diff_Profiles.add_profiles (tmp_pfiles.get ()) < 0) 00157 throw TAO_IOP::Invalid_IOR (); 00158 00159 // We are done with add_profiles. 00160 // At this point, we don't do remove_profiles() 00161 // immediately like before, 00162 // because it could result in an 00163 // Object Reference with 0 profile. And it would not pass 00164 // the ::CORBA::is_nil() evaluation. 00165 // Instead, we create the Object Reference right here, which is 00166 // earlier than before.(Actually, I just moved some code 00167 // from below up to here). 00168 TAO_ORB_Core *orb_core = TAO_ORB_Core_instance (); 00169 00170 TAO_Stub *stub = orb_core->create_stub (id.in (), // give the id string 00171 Diff_Profiles 00172 ); 00173 00174 // Make the stub memory allocation exception safe for the duration 00175 // of this method. 00176 TAO_Stub_Auto_Ptr safe_stub (stub); 00177 00178 // Create the CORBA level proxy 00179 CORBA::Object_ptr temp_obj = CORBA::Object::_nil (); 00180 ACE_NEW_THROW_EX (temp_obj, 00181 CORBA::Object (safe_stub.get ()), 00182 CORBA::NO_MEMORY ()); 00183 00184 CORBA::Object_var new_obj = temp_obj; 00185 00186 // Exception safety is no longer an issue by this point so release 00187 // the TAO_Stub from the TAO_Stub_Auto_Ptr. 00188 stub = safe_stub.release (); 00189 00190 // Clean up in case of errors. 00191 if (CORBA::is_nil (new_obj.in ())) 00192 { 00193 throw TAO_IOP::Invalid_IOR (); 00194 } 00195 00196 // Now we can remove the profiles which we want to elimitate from 00197 // the Object. 00198 ACE_AUTO_PTR_RESET (tmp_pfiles, 00199 ior2->_stubobj ()->make_profiles (), 00200 TAO_MProfile); 00201 00202 TAO_MProfile& mp = stub -> base_profiles(); 00203 if (mp.remove_profiles (tmp_pfiles.get ()) < 0) 00204 throw TAO_IOP::NotFound (); 00205 00206 // MS C++ knows nothing about reset! 00207 // tmp_pfiles.reset (0); // get rid of last MProfile 00208 00209 return new_obj._retn (); 00210 }
CORBA::Boolean TAO_IOR_Manipulation_impl::set_primary | ( | TAO_IOP::TAO_IOR_Property_ptr | prop, | |
CORBA::Object_ptr | new_primary, | |||
CORBA::Object_ptr | group | |||
) | [virtual] |
Definition at line 227 of file IORManipulation.cpp.
References CORBA::Object::_stubobj(), TAO_Stub::base_profiles(), and TAO_MProfile::profile_count().
00231 { 00232 // make sure we have some profiles in GROUP 00233 if (group->_stubobj ()->base_profiles ().profile_count () == 0) 00234 throw TAO_IOP::Invalid_IOR (); 00235 00236 // Make sure we have only one profile in new_primary 00237 // @@ Will fail if the object has been 00238 /*if (new_primary->_stubobj ()->base_profiles ().profile_count () > 1) 00239 throw TAO_IOP::MultiProfileList ();*/ 00240 00241 // Call the callback object to do the rest of the processing. 00242 return prop->set_primary (new_primary, group); 00243 }
CORBA::Boolean TAO_IOR_Manipulation_impl::set_property | ( | TAO_IOP::TAO_IOR_Property_ptr | prop, | |
CORBA::Object_ptr | group | |||
) | [virtual] |
Definition at line 213 of file IORManipulation.cpp.
References CORBA::Object::_stubobj(), TAO_Stub::base_profiles(), and TAO_MProfile::profile_count().
00216 { 00217 // make sure we have some profiles 00218 if (group->_stubobj ()->base_profiles ().profile_count () == 0) 00219 throw TAO_IOP::Invalid_IOR (); 00220 00221 // Call the implementation object to 00222 return prop->set_property (group); 00223 }