00001 #include "tao/PI/PICurrent.h"
00002
00003 #if TAO_HAS_INTERCEPTORS == 1
00004
00005 ACE_RCSID (tao,
00006 PICurrent,
00007 "$Id: PICurrent.cpp 77151 2007-02-15 13:24:41Z johnnyw $")
00008
00009 #if !defined (__ACE_INLINE__)
00010 # include "tao/PI/PICurrent.inl"
00011 #endif
00012
00013 #include "tao/PI/PICurrent_Impl.h"
00014
00015 #include "tao/ORB_Core.h"
00016 #include "tao/ORB_Core_TSS_Resources.h"
00017 #include "tao/TAO_Server_Request.h"
00018 #include "ace/CORBA_macros.h"
00019
00020 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00021
00022 TAO::PICurrent::PICurrent (TAO_ORB_Core &orb_core)
00023 : orb_core_ (orb_core),
00024 tss_slot_ (0),
00025 slot_count_ (0)
00026 {
00027 }
00028
00029 TAO::PICurrent::~PICurrent (void)
00030 {
00031 }
00032
00033 CORBA::Any *
00034 TAO::PICurrent::get_slot (PortableInterceptor::SlotId identifier)
00035 {
00036 this->check_validity (identifier);
00037
00038 return this->tsc ()->get_slot (identifier);
00039 }
00040
00041 void
00042 TAO::PICurrent::set_slot (PortableInterceptor::SlotId identifier,
00043 const CORBA::Any &data)
00044 {
00045 this->check_validity (identifier);
00046
00047 this->tsc ()->set_slot (identifier, data);
00048 }
00049
00050 namespace
00051 {
00052 extern "C" void CleanUpPICurrent(void *object, void *)
00053 {
00054 delete static_cast<TAO::PICurrent_Impl *> (object);
00055 }
00056 }
00057
00058 TAO::PICurrent_Impl *
00059 TAO::PICurrent::tsc (void)
00060 {
00061 TAO::PICurrent_Impl *impl =
00062 static_cast<TAO::PICurrent_Impl *> (
00063 this->orb_core_.get_tss_resource (this->tss_slot_));
00064
00065
00066 if (0 == impl)
00067 {
00068 ACE_NEW_THROW_EX (impl,
00069 TAO::PICurrent_Impl,
00070 CORBA::NO_MEMORY (
00071 CORBA::SystemException::_tao_minor_code (
00072 TAO::VMCID,
00073 ENOMEM),
00074 CORBA::COMPLETED_NO));
00075
00076 this->orb_core_.set_tss_resource (this->tss_slot_, impl);
00077 }
00078
00079 return impl;
00080 }
00081
00082 void
00083 TAO::PICurrent::check_validity (const PortableInterceptor::SlotId &identifier)
00084 {
00085
00086
00087
00088 if (0 == this->slot_count_)
00089 throw ::CORBA::BAD_INV_ORDER (CORBA::OMGVMCID | 14, CORBA::COMPLETED_NO);
00090
00091
00092
00093 if (identifier >= this->slot_count_)
00094 throw PortableInterceptor::InvalidSlot ();
00095 }
00096
00097 CORBA::ORB_ptr
00098 TAO::PICurrent::_get_orb (void)
00099 {
00100 return CORBA::ORB::_duplicate (this->orb_core_.orb ());
00101 }
00102
00103 void
00104 TAO::PICurrent::initialize (PortableInterceptor::SlotId sc)
00105 {
00106
00107
00108
00109 if ((0 == this->slot_count_) && (0 != sc))
00110 {
00111
00112
00113
00114
00115 if (0 != orb_core_.add_tss_cleanup_func (CleanUpPICurrent, this->tss_slot_))
00116 throw ::CORBA::NO_MEMORY (
00117 CORBA::SystemException::_tao_minor_code (
00118 TAO::VMCID,
00119 ENOMEM),
00120 CORBA::COMPLETED_NO);
00121
00122 this->slot_count_ = sc;
00123 }
00124 }
00125
00126 TAO_END_VERSIONED_NAMESPACE_DECL
00127
00128 #endif