TAO_IOR_Manipulation_impl Class Reference

#include <IORManipulation.h>

Inheritance diagram for TAO_IOR_Manipulation_impl:

Inheritance graph
[legend]
Collaboration diagram for TAO_IOR_Manipulation_impl:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TAO_IOR_Manipulation_impl (void)
virtual CORBA::Object_ptr merge_iors (const TAO_IOP::TAO_IOR_Manipulation::IORList &iors) throw ( CORBA::SystemException, TAO_IOP::EmptyProfileList, TAO_IOP::Duplicate, TAO_IOP::Invalid_IOR )
virtual CORBA::Object_ptr add_profiles (CORBA::Object_ptr ior1, CORBA::Object_ptr ior2) throw ( CORBA::SystemException, TAO_IOP::EmptyProfileList, TAO_IOP::Duplicate, TAO_IOP::Invalid_IOR )
virtual CORBA::Object_ptr remove_profiles (CORBA::Object_ptr group, CORBA::Object_ptr ior2) throw ( CORBA::SystemException, TAO_IOP::Invalid_IOR, TAO_IOP::EmptyProfileList, TAO_IOP::NotFound )
virtual CORBA::Boolean set_property (TAO_IOP::TAO_IOR_Property_ptr prop, CORBA::Object_ptr group) throw ( CORBA::SystemException, TAO_IOP::Invalid_IOR, TAO_IOP::Duplicate )
virtual CORBA::Boolean set_primary (TAO_IOP::TAO_IOR_Property_ptr prop, CORBA::Object_ptr new_primary, CORBA::Object_ptr group) throw ( CORBA::SystemException, TAO_IOP::Invalid_IOR, TAO_IOP::Duplicate, TAO_IOP::MultiProfileList )
virtual CORBA::Object_ptr get_primary (TAO_IOP::TAO_IOR_Property_ptr prop, CORBA::Object_ptr group) throw ( CORBA::SystemException, TAO_IOP::NotFound )
virtual CORBA::Boolean is_primary_set (TAO_IOP::TAO_IOR_Property_ptr prop, CORBA::Object_ptr group) throw ( CORBA::SystemException )
virtual CORBA::Boolean remove_primary_tag (TAO_IOP::TAO_IOR_Property_ptr prop, CORBA::Object_ptr iogr) throw ( CORBA::SystemException )
virtual CORBA::ULong is_in_ior (CORBA::Object_ptr ior1, CORBA::Object_ptr ior2) throw ( CORBA::SystemException, TAO_IOP::NotFound )
virtual CORBA::ULong get_profile_count (CORBA::Object_ptr group) throw ( CORBA::SystemException, TAO_IOP::EmptyProfileList )

Protected Member Functions

 ~TAO_IOR_Manipulation_impl (void)

Constructor & Destructor Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_IOR_Manipulation_impl::TAO_IOR_Manipulation_impl void   ) 
 

Definition at line 18 of file IORManipulation.cpp.

00019 {
00020 }

TAO_IOR_Manipulation_impl::~TAO_IOR_Manipulation_impl void   )  [protected]
 

Definition at line 22 of file IORManipulation.cpp.

00023 {
00024 }


Member Function Documentation

CORBA::Object_ptr TAO_IOR_Manipulation_impl::add_profiles CORBA::Object_ptr  ior1,
CORBA::Object_ptr  ior2
throw ( CORBA::SystemException, TAO_IOP::EmptyProfileList, TAO_IOP::Duplicate, TAO_IOP::Invalid_IOR ) [virtual]
 

Definition at line 132 of file IORManipulation.cpp.

References ACE_ENV_ARG_PARAMETER.

00140 {
00141 
00142   // Get an estimate of the number of profiles
00143   CORBA::Object_ptr buffer [2];
00144   buffer [0] = ior1;
00145   buffer [1] = ior2;
00146   TAO_IOP::TAO_IOR_Manipulation::IORList iors (2, 2, buffer, 0);
00147   return this->merge_iors (iors ACE_ENV_ARG_PARAMETER);
00148 }

CORBA::Object_ptr TAO_IOR_Manipulation_impl::get_primary TAO_IOP::TAO_IOR_Property_ptr  prop,
CORBA::Object_ptr  group
throw ( CORBA::SystemException, TAO_IOP::NotFound ) [virtual]
 

Definition at line 292 of file IORManipulation.cpp.

References ACE_ENV_ARG_PARAMETER, ACE_THROW_RETURN, and TAO_IOP::TAO_IOR_Property_ptr.

00301 {
00302   // make sure we have some profiles in IOR
00303   if (group->_stubobj ()->base_profiles ().profile_count () == 0)
00304     ACE_THROW_RETURN (TAO_IOP::NotFound (), 0);
00305   // @@ Bala: this was throwing TAO_IOP::Invalid_IOR, but it was not
00306   // in the throw spec, that will result in a CORBA::UNKNOWN at
00307   // run-time (if it does not crash).  Any idea about what is going on
00308   // here?
00309 
00310   return prop->get_primary (group
00311                             ACE_ENV_ARG_PARAMETER);
00312 }

CORBA::ULong TAO_IOR_Manipulation_impl::get_profile_count CORBA::Object_ptr  group  )  throw ( CORBA::SystemException, TAO_IOP::EmptyProfileList ) [virtual]
 

Definition at line 366 of file IORManipulation.cpp.

References ACE_THROW_RETURN.

00371 {
00372   CORBA::ULong count;
00373   count = group->_stubobj ()->base_profiles ().profile_count ();
00374 
00375   if (count == 0)
00376     ACE_THROW_RETURN (TAO_IOP::EmptyProfileList (),
00377                       0);
00378 
00379   return count;
00380 }

CORBA::ULong TAO_IOR_Manipulation_impl::is_in_ior CORBA::Object_ptr  ior1,
CORBA::Object_ptr  ior2
throw ( CORBA::SystemException, TAO_IOP::NotFound ) [virtual]
 

Definition at line 335 of file IORManipulation.cpp.

References ACE_THROW_RETURN, and TAO_Profile::is_equivalent().

00341 {
00342   CORBA::ULong count = 0;
00343   TAO_Profile *pfile1, *pfile2;
00344   auto_ptr<TAO_MProfile> tmp_pfiles1 (ior1->_stubobj ()->make_profiles ());
00345   auto_ptr<TAO_MProfile> tmp_pfiles2 (ior2->_stubobj ()->make_profiles ());
00346 
00347   tmp_pfiles1->rewind ();
00348   while ((pfile1 = tmp_pfiles1->get_next ()) > 0)
00349     {
00350       tmp_pfiles2->rewind ();
00351       while ((pfile2 = tmp_pfiles2->get_next ()) > 0)
00352         {
00353           if (pfile1->is_equivalent (pfile2))
00354             count++;
00355         }
00356     }
00357 
00358   if (count == 0)
00359     ACE_THROW_RETURN (TAO_IOP::NotFound (),
00360                       0);
00361 
00362   return count;
00363 }

CORBA::Boolean TAO_IOR_Manipulation_impl::is_primary_set TAO_IOP::TAO_IOR_Property_ptr  prop,
CORBA::Object_ptr  group
throw ( CORBA::SystemException ) [virtual]
 

Definition at line 315 of file IORManipulation.cpp.

References ACE_ENV_ARG_PARAMETER, and TAO_IOP::TAO_IOR_Property_ptr.

00320 {
00321   return prop->is_primary_set (group ACE_ENV_ARG_PARAMETER);
00322 }

CORBA::Object_ptr TAO_IOR_Manipulation_impl::merge_iors const TAO_IOP::TAO_IOR_Manipulation::IORList iors  )  throw ( CORBA::SystemException, TAO_IOP::EmptyProfileList, TAO_IOP::Duplicate, TAO_IOP::Invalid_IOR ) [virtual]
 

Definition at line 27 of file IORManipulation.cpp.

References CORBA::Object::_nil(), ACE_AUTO_PTR_RESET, ACE_CHECK_RETURN, ACE_ENV_ARG_PARAMETER, ACE_NEW_THROW_EX, ACE_THROW_RETURN, TAO_MProfile::add_profiles(), TAO_ORB_Core::create_stub(), TAO_Stub_Auto_Ptr::get(), ACE_Auto_Basic_Ptr< X >::get(), TAO_MProfile::is_equivalent(), CORBA::is_nil(), TAO_Stub_Auto_Ptr::release(), ACE_OS::strcmp(), CORBA::string_dup(), and TAO_ORB_Core_instance().

00034 {
00035   // we need to create a new CORBA::Object which has the union of the
00036   // two profile lists.  However, if any profiles are duplicates (i.e. in
00037   // bott lisis) then an exception is raised.
00038 
00039   // Deterinine how many profiles we have
00040   // Get an estimate of the size - pfile count could change since we
00041   // neither lock nor get a copy in this loop.
00042   CORBA::ULong i, count=0;
00043   for (i = 0; i < iors.length (); i++)
00044     {
00045       count += iors[i]->_stubobj ()->base_profiles ().profile_count ();
00046     }
00047 
00048   // make sure we have some profiles
00049   if (count == 0)
00050     ACE_THROW_RETURN (TAO_IOP::EmptyProfileList (),
00051                       CORBA::Object::_nil ());
00052 
00053   // initialize with estimated pfile count.
00054   TAO_MProfile Merged_Profiles (count);
00055 
00056   // get the profile lists, start by initialize the composite reference
00057   // by using the first Object.  Then for each subsequent Object verify
00058   // they are the same type and they do not have duplicate profiles.
00059   auto_ptr<TAO_MProfile> tmp_pfiles (iors[0]->_stubobj ()->make_profiles ());
00060   if (Merged_Profiles.add_profiles (tmp_pfiles.get ())< 0)
00061     ACE_THROW_RETURN (TAO_IOP::Invalid_IOR (),
00062                       CORBA::Object::_nil ());
00063   CORBA::String_var id =
00064     CORBA::string_dup (iors[0]->_stubobj ()->type_id.in ());
00065 
00066   for (i = 1; i < iors.length () ; i++)
00067     {
00068       // this gets a copy of the MProfile, hense the auto_ptr;
00069 
00070       ACE_AUTO_PTR_RESET (tmp_pfiles,
00071                           iors[i]->_stubobj ()->make_profiles (),
00072                           TAO_MProfile);
00073 
00074       // check to see if any of the profile in tmp_pfiles are already
00075       // in Merged_Profiles.  If so raise exception.
00076       if (Merged_Profiles.is_equivalent (tmp_pfiles.get ()))
00077         ACE_THROW_RETURN (TAO_IOP::Duplicate (),
00078                           CORBA::Object::_nil ());
00079 
00080       // If the object type_id's differ then raise an exception.
00081       if (id.in () && iors[i]->_stubobj ()->type_id.in () &&
00082           ACE_OS::strcmp (id.in (), iors[i]->_stubobj ()->type_id.in ()))
00083         ACE_THROW_RETURN (TAO_IOP::Invalid_IOR (),
00084                           CORBA::Object::_nil ());
00085 
00086       // append profiles
00087       if (Merged_Profiles.add_profiles (tmp_pfiles.get ()) < 0)
00088         ACE_THROW_RETURN (TAO_IOP::Invalid_IOR (),
00089                           CORBA::Object::_nil ());
00090 
00091     }
00092 
00093   // MS C++ knows nothing about reset!
00094   // tmp_pfiles.reset (0); // get rid of last MProfile
00095 
00096   TAO_ORB_Core *orb_core = TAO_ORB_Core_instance ();
00097 
00098   TAO_Stub *stub = orb_core->create_stub (id.in (), // give the id string
00099                                           Merged_Profiles
00100                                           ACE_ENV_ARG_PARAMETER);
00101   ACE_CHECK_RETURN (CORBA::Object::_nil ());
00102 
00103   // Make the stub memory allocation exception safe for the duration
00104   // of this method.
00105   TAO_Stub_Auto_Ptr safe_stub (stub);
00106 
00107   // Create the CORBA level proxy
00108   CORBA::Object_ptr temp_obj = CORBA::Object::_nil ();
00109   ACE_NEW_THROW_EX (temp_obj,
00110                     CORBA::Object (safe_stub.get ()),
00111                     CORBA::NO_MEMORY ());
00112 
00113   CORBA::Object_var new_obj = temp_obj;
00114 
00115   ACE_CHECK_RETURN (CORBA::Object::_nil ());
00116 
00117   // Clean up in case of errors.
00118   if (CORBA::is_nil (new_obj.in ()))
00119     {
00120       ACE_THROW_RETURN (TAO_IOP::Invalid_IOR (),
00121                         CORBA::Object::_nil ());
00122     }
00123 
00124   // Release ownership of the pointers protected by the auto_ptrs since they
00125   // no longer need to be protected by this point.
00126   stub = safe_stub.release ();
00127 
00128   return new_obj._retn ();
00129 }

CORBA::Boolean TAO_IOR_Manipulation_impl::remove_primary_tag TAO_IOP::TAO_IOR_Property_ptr  prop,
CORBA::Object_ptr  iogr
throw ( CORBA::SystemException ) [virtual]
 

Definition at line 325 of file IORManipulation.cpp.

References ACE_ENV_ARG_PARAMETER, and TAO_IOP::TAO_IOR_Property_ptr.

00330 {
00331   return prop->remove_primary_tag (group ACE_ENV_ARG_PARAMETER);
00332 }

CORBA::Object_ptr TAO_IOR_Manipulation_impl::remove_profiles CORBA::Object_ptr  group,
CORBA::Object_ptr  ior2
throw ( CORBA::SystemException, TAO_IOP::Invalid_IOR, TAO_IOP::EmptyProfileList, TAO_IOP::NotFound ) [virtual]
 

Definition at line 151 of file IORManipulation.cpp.

References CORBA::Object::_nil(), ACE_AUTO_PTR_RESET, ACE_CHECK_RETURN, ACE_ENV_ARG_PARAMETER, ACE_NEW_THROW_EX, ACE_THROW_RETURN, TAO_MProfile::add_profiles(), TAO_ORB_Core::create_stub(), TAO_Stub_Auto_Ptr::get(), ACE_Auto_Basic_Ptr< X >::get(), CORBA::is_nil(), TAO_Stub_Auto_Ptr::release(), TAO_MProfile::remove_profiles(), ACE_OS::strcmp(), CORBA::string_dup(), and TAO_ORB_Core_instance().

00161 {
00162   // First verify they are the same type!
00163   CORBA::String_var id =
00164     CORBA::string_dup (group->_stubobj ()->type_id.in ());
00165   if (id.in () && ior2->_stubobj ()->type_id.in () &&
00166       ACE_OS::strcmp (id.in (), ior2->_stubobj ()->type_id.in ()))
00167     ACE_THROW_RETURN (TAO_IOP::Invalid_IOR (),
00168                       CORBA::Object::_nil ());
00169 
00170   // Since we are removing from group ...
00171   CORBA::ULong count = group->_stubobj ()->base_profiles ().profile_count ();
00172 
00173   // make sure we have some profiles
00174   if (count == 0 ||
00175       ior2->_stubobj ()->base_profiles ().profile_count () == 0)
00176     ACE_THROW_RETURN (TAO_IOP::EmptyProfileList (),
00177                       CORBA::Object::_nil ());
00178 
00179   // initialize with estimated pfile count.
00180   TAO_MProfile Diff_Profiles (count);
00181 
00182   auto_ptr<TAO_MProfile> tmp_pfiles (group->_stubobj ()->make_profiles ());
00183   if (Diff_Profiles.add_profiles (tmp_pfiles.get ()) < 0)
00184     ACE_THROW_RETURN (TAO_IOP::Invalid_IOR (),
00185                       CORBA::Object::_nil ());
00186 
00187   // We are done with add_profiles.
00188   // At this point, we don't do remove_profiles()
00189   // immediately like before,
00190   // because it could result in an
00191   // Object Reference with 0 profile. And it would not pass
00192   // the ::CORBA::is_nil() evaluation.
00193   // Instead, we create the Object Reference right here, which is
00194   // earlier than before.(Actually, I just moved some code
00195   // from below up to here).
00196   TAO_ORB_Core *orb_core = TAO_ORB_Core_instance ();
00197 
00198   TAO_Stub *stub = orb_core->create_stub (id.in (), // give the id string
00199                                           Diff_Profiles
00200                                           ACE_ENV_ARG_PARAMETER);
00201   ACE_CHECK_RETURN (CORBA::Object::_nil ());
00202 
00203   // Make the stub memory allocation exception safe for the duration
00204   // of this method.
00205   TAO_Stub_Auto_Ptr safe_stub (stub);
00206 
00207   // Create the CORBA level proxy
00208   CORBA::Object_ptr temp_obj = CORBA::Object::_nil ();
00209   ACE_NEW_THROW_EX (temp_obj,
00210                     CORBA::Object (safe_stub.get ()),
00211                     CORBA::NO_MEMORY ());
00212 
00213   CORBA::Object_var new_obj = temp_obj;
00214 
00215   // Exception safety is no longer an issue by this point so release
00216   // the TAO_Stub from the TAO_Stub_Auto_Ptr.
00217   stub = safe_stub.release ();
00218 
00219   // Clean up in case of errors.
00220   if (CORBA::is_nil (new_obj.in ()))
00221     {
00222       ACE_THROW_RETURN (TAO_IOP::Invalid_IOR (),
00223                         CORBA::Object::_nil ());
00224     }
00225 
00226   // Now we can remove the profiles which we want to elimitate from
00227   // the Object.
00228   ACE_AUTO_PTR_RESET (tmp_pfiles,
00229                       ior2->_stubobj ()->make_profiles (),
00230                       TAO_MProfile);
00231 
00232   TAO_MProfile& mp = stub -> base_profiles();
00233   if (mp.remove_profiles (tmp_pfiles.get ()) < 0)
00234     ACE_THROW_RETURN (TAO_IOP::NotFound (),
00235                       CORBA::Object::_nil ());
00236 
00237   // MS C++ knows nothing about reset!
00238   // tmp_pfiles.reset (0); // get rid of last MProfile
00239 
00240   return new_obj._retn ();
00241 }

CORBA::Boolean TAO_IOR_Manipulation_impl::set_primary TAO_IOP::TAO_IOR_Property_ptr  prop,
CORBA::Object_ptr  new_primary,
CORBA::Object_ptr  group
throw ( CORBA::SystemException, TAO_IOP::Invalid_IOR, TAO_IOP::Duplicate, TAO_IOP::MultiProfileList ) [virtual]
 

Definition at line 264 of file IORManipulation.cpp.

References ACE_ENV_ARG_PARAMETER, ACE_THROW_RETURN, and TAO_IOP::TAO_IOR_Property_ptr.

00273 {
00274   // make sure we have some profiles in GROUP
00275   if (group->_stubobj ()->base_profiles ().profile_count () == 0)
00276     ACE_THROW_RETURN (TAO_IOP::Invalid_IOR (),
00277                       0);
00278 
00279   // Make sure we have only one profile in new_primary
00280   // @@ Will fail if the object has been
00281   /*if (new_primary->_stubobj ()->base_profiles ().profile_count () > 1)
00282     ACE_THROW_RETURN (TAO_IOP::MultiProfileList (),
00283     0);*/
00284 
00285   // Call the callback object to do the rest of the processing.
00286   return prop->set_primary (new_primary,
00287                             group
00288                             ACE_ENV_ARG_PARAMETER);
00289 }

CORBA::Boolean TAO_IOR_Manipulation_impl::set_property TAO_IOP::TAO_IOR_Property_ptr  prop,
CORBA::Object_ptr  group
throw ( CORBA::SystemException, TAO_IOP::Invalid_IOR, TAO_IOP::Duplicate ) [virtual]
 

Definition at line 244 of file IORManipulation.cpp.

References ACE_ENV_ARG_PARAMETER, ACE_THROW_RETURN, and TAO_IOP::TAO_IOR_Property_ptr.

00251 {
00252   // make sure we have some profiles
00253   if (group->_stubobj ()->base_profiles ().profile_count () == 0)
00254     ACE_THROW_RETURN (TAO_IOP::Invalid_IOR (),
00255                       0);
00256 
00257   // Call the implementation object to
00258   return prop->set_property (group
00259                              ACE_ENV_ARG_PARAMETER);
00260 }


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 13:06:14 2006 for TAO_IORManipulation by doxygen 1.3.6