00001 // $Id: RIR_Narrow.cpp 76874 2007-02-02 14:12:41Z johnnyw $ 00002 00003 #ifndef TAO_UTILS_RIR_NARROW_CPP 00004 #define TAO_UTILS_RIR_NARROW_CPP 00005 00006 #include "tao/Utils/RIR_Narrow.h" 00007 #include "tao/SystemException.h" 00008 #include <stdexcept> 00009 00010 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00011 00012 template<class T> typename TAO::Utils::RIR_Narrow<T>::_ptr_type 00013 TAO::Utils::RIR_Narrow<T>::narrow (CORBA::ORB_ptr orb, char const * id) 00014 { 00015 CORBA::Object_var object = 00016 orb->resolve_initial_references (id); 00017 00018 return RIR_Narrow<T>::narrow_object (object.in ()); 00019 } 00020 00021 template<class T> typename TAO::Utils::RIR_Narrow<T>::_ptr_type 00022 TAO::Utils::RIR_Narrow<T>::narrow (PortableInterceptor::ORBInitInfo_ptr info, 00023 char const * id) 00024 { 00025 CORBA::Object_var object = info->resolve_initial_references (id); 00026 00027 return RIR_Narrow<T>::narrow_object (object.in ()); 00028 } 00029 00030 template<class T> typename TAO::Utils::RIR_Narrow<T>::_ptr_type 00031 TAO::Utils::RIR_Narrow<T>::narrow_object (CORBA::Object_ptr object) 00032 { 00033 _var_type narrowed_object = T::_narrow (object); 00034 00035 if (CORBA::is_nil (narrowed_object.in ())) 00036 { 00037 throw ::CORBA::INV_OBJREF (); 00038 } 00039 return narrowed_object._retn (); 00040 } 00041 00042 TAO_END_VERSIONED_NAMESPACE_DECL 00043 00044 #endif /*TAO_UTILS_RIR_NARROW_CPP*/