Go to the documentation of this file.00001
00002
00003 #ifndef TAO_ABSTRACT_BASE_T_CPP
00004 #define TAO_ABSTRACT_BASE_T_CPP
00005
00006 #include "tao/Valuetype/AbstractBase_T.h"
00007 #include "tao/Valuetype/AbstractBase.h"
00008 #include "tao/Stub.h"
00009
00010 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00011
00012 namespace TAO
00013 {
00014 template<typename T> T *
00015 AbstractBase_Narrow_Utils<T>::narrow (
00016 CORBA::AbstractBase_ptr obj,
00017 const char *repo_id,
00018 Proxy_Broker_Factory pbf
00019 )
00020 {
00021 if (CORBA::is_nil (obj))
00022 {
00023 return T::_nil ();
00024 }
00025
00026 CORBA::Boolean const is_it =
00027 obj->_is_a (
00028 repo_id
00029
00030 );
00031
00032 if (is_it == false)
00033 {
00034 return T::_nil ();
00035 }
00036
00037 return
00038 AbstractBase_Narrow_Utils<T>::unchecked_narrow (obj,
00039 repo_id,
00040 pbf
00041 );
00042 }
00043
00044 template<typename T> T *
00045 AbstractBase_Narrow_Utils<T>::unchecked_narrow (
00046 CORBA::AbstractBase_ptr obj,
00047 Proxy_Broker_Factory pbf)
00048 {
00049 T *proxy = 0;
00050
00051
00052 try
00053 {
00054 proxy =
00055 AbstractBase_Narrow_Utils<T>::unchecked_narrow (
00056 obj,
00057 0,
00058 pbf
00059 );
00060
00061 }
00062 catch (const ::CORBA::Exception&)
00063 {
00064
00065 return proxy;
00066 }
00067
00068 return proxy;
00069 }
00070
00071 template<typename T> T *
00072 AbstractBase_Narrow_Utils<T>::unchecked_narrow (
00073 CORBA::AbstractBase_ptr obj,
00074 const char *,
00075 Proxy_Broker_Factory pbf
00076 )
00077 {
00078 if (CORBA::is_nil (obj))
00079 {
00080 return T::_nil ();
00081 }
00082
00083 T_ptr proxy = T::_nil ();
00084
00085 if (obj->_is_objref ())
00086 {
00087 TAO_Stub* stub = obj->_stubobj ();
00088
00089 bool const collocated =
00090 !CORBA::is_nil (stub->servant_orb_var ().in ())
00091 && stub->optimize_collocation_objects ()
00092 && obj->_is_collocated ()
00093 && pbf != 0;
00094
00095 ACE_NEW_THROW_EX (proxy,
00096 T (obj->_stubobj (),
00097 collocated ? 1 : 0,
00098 obj->_servant ()),
00099 CORBA::NO_MEMORY ());
00100 }
00101 else
00102 {
00103 proxy = dynamic_cast<T *> (obj);
00104 if (proxy)
00105 proxy->_add_ref ();
00106 }
00107
00108 return proxy;
00109 }
00110 }
00111
00112 TAO_END_VERSIONED_NAMESPACE_DECL
00113
00114 #endif