PICurrent.cpp

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            "PICurrent.cpp,v 1.4 2006/03/10 07:19:12 jtc Exp")
00008 
00009 
00010 #if !defined (__ACE_INLINE__)
00011 # include "tao/PI/PICurrent.inl"
00012 #endif /* __ACE_INLINE__ */
00013 
00014 #include "tao/PI/PICurrent_Impl.h"
00015 
00016 #include "tao/ORB_Core.h"
00017 #include "tao/ORB_Core_TSS_Resources.h"
00018 #include "tao/TAO_Server_Request.h"
00019 #include "tao/SystemException.h"
00020 
00021 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00022 
00023 TAO::PICurrent::PICurrent (TAO_ORB_Core &orb_core)
00024   : orb_core_ (orb_core),
00025     tss_slot_ (0),
00026     slot_count_ (0)
00027 {
00028 }
00029 
00030 TAO::PICurrent::~PICurrent (void)
00031 {
00032 }
00033 
00034 CORBA::Any *
00035 TAO::PICurrent::get_slot (PortableInterceptor::SlotId identifier
00036                          ACE_ENV_ARG_DECL)
00037   ACE_THROW_SPEC ((CORBA::SystemException,
00038                    PortableInterceptor::InvalidSlot))
00039 {
00040   this->check_validity (identifier ACE_ENV_ARG_PARAMETER);
00041   ACE_CHECK_RETURN (0);
00042 
00043   PICurrent_Impl *impl = this->tsc ();
00044 
00045   if (impl == 0)
00046     ACE_THROW_RETURN (CORBA::BAD_INV_ORDER (CORBA::OMGVMCID | 14,
00047                                             CORBA::COMPLETED_NO),
00048                       0);
00049 
00050   return impl->get_slot (identifier ACE_ENV_ARG_PARAMETER);
00051 }
00052 
00053 void
00054 TAO::PICurrent::set_slot (PortableInterceptor::SlotId identifier,
00055                          const CORBA::Any &data
00056                          ACE_ENV_ARG_DECL)
00057   ACE_THROW_SPEC ((CORBA::SystemException,
00058                    PortableInterceptor::InvalidSlot))
00059 {
00060   this->check_validity (identifier ACE_ENV_ARG_PARAMETER);
00061   ACE_CHECK;
00062 
00063   PICurrent_Impl *impl = this->tsc ();
00064 
00065   if (impl == 0)
00066     ACE_THROW (CORBA::BAD_INV_ORDER (CORBA::OMGVMCID | 14,
00067                                      CORBA::COMPLETED_NO));
00068 
00069   impl->set_slot (identifier, data ACE_ENV_ARG_PARAMETER);
00070   ACE_CHECK;
00071 }
00072 
00073 TAO::PICurrent_Impl *
00074 TAO::PICurrent::tsc (void)
00075 {
00076   TAO::PICurrent_Impl *impl =
00077     static_cast<TAO::PICurrent_Impl *> (
00078       this->orb_core_.get_tss_resource (this->tss_slot_));
00079 
00080   return impl;
00081 }
00082 
00083 void
00084 TAO::PICurrent::check_validity (const PortableInterceptor::SlotId &identifier
00085                                 ACE_ENV_ARG_DECL)
00086 {
00087   // No need to acquire a lock for this check.  At this point, these
00088   // attributes are read only.
00089   if (identifier >= this->slot_count_)
00090     ACE_THROW (PortableInterceptor::InvalidSlot ());
00091 }
00092 
00093 CORBA::ORB_ptr
00094 TAO::PICurrent::_get_orb (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
00095 {
00096   return CORBA::ORB::_duplicate (this->orb_core_.orb ());
00097 }
00098 
00099 int
00100 TAO::PICurrent::initialize (PortableInterceptor::SlotId sc
00101                             ACE_ENV_ARG_DECL_NOT_USED)
00102 {
00103   this->slot_count_ = sc;
00104 
00105   if (this->tsc () == 0 && tss_slot_ == 0)
00106     {
00107       TAO::PICurrent_Impl *impl = 0;
00108       ACE_NEW_RETURN (impl,
00109                       TAO::PICurrent_Impl,
00110                       0);
00111 
00112       const int result = this->orb_core_.add_tss_cleanup_func (0,
00113                                                                tss_slot_);
00114 
00115       if (result != 0)
00116         return result;
00117 
00118       this->orb_core_.set_tss_resource (tss_slot_, impl);
00119     }
00120 
00121   return 0;
00122 }
00123 
00124 TAO_END_VERSIONED_NAMESPACE_DECL
00125 
00126 #endif  /* TAO_HAS_INTERCEPTORS == 1 */

Generated on Thu Nov 9 12:51:39 2006 for TAO_PI by doxygen 1.3.6