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