Main Page | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

utility.h

Go to the documentation of this file.
00001 00021 #ifndef _UTILITY_GUARD 00022 #define _UTILITY_GUARD 00023 00034 #include "BP_CORBA.h" 00035 00051 template<class T> 00052 inline typename T::_ptr_type 00053 resolve_init(CORBA::ORB_ptr orb, const char *id) 00054 { 00055 CORBA::Object_var obj; 00056 try { 00057 obj = orb->resolve_initial_references(id); 00058 } catch (const CORBA::ORB::InvalidName & e) { 00059 throw; 00060 } catch (const CORBA::Exception & e) { 00061 throw 0; 00062 } 00063 assert(!CORBA::is_nil(obj)); 00064 00065 typename T::_var_type ref; 00066 try { 00067 ref = T::_narrow(obj); 00068 } catch (const CORBA::Exception & e) { 00069 throw 0; 00070 } 00071 if(CORBA::is_nil(ref) ) 00072 { 00073 throw 0; 00074 } 00075 return(ref._retn()); 00076 }; 00077 00078 00094 template<class T> 00095 inline typename T::_ptr_type 00096 resolve_name( 00097 CosNaming::NamingContext_ptr nc, 00098 const CosNaming::Name & name) 00099 { 00100 CORBA::Object_var obj; 00101 try { 00102 obj = nc->resolve(name); 00103 } catch(const CosNaming::NamingContext::NotFound & e) { 00104 throw; 00105 } catch(const CORBA::Exception & e) { 00106 throw 0; 00107 } 00108 if(CORBA::is_nil(obj)) { 00109 throw 0; 00110 } 00111 00112 typename T::_var_type ref; 00113 try { 00114 ref = T::_narrow(obj); 00115 } catch(const CORBA::Exception & e) { 00116 throw 0; 00117 } 00118 if(CORBA::is_nil(ref)) 00119 { 00120 throw 0; 00121 } 00122 return(ref._retn()); 00123 }; 00124 00125 #endif