00001 #include "tao/PI/PICurrent_Impl.h"
00002
00003 #if TAO_HAS_INTERCEPTORS == 1
00004
00005 ACE_RCSID (tao,
00006 PICurrent,
00007 "PICurrent_Impl.cpp,v 1.10 2006/06/26 09:24:20 sma Exp")
00008
00009
00010 #if !defined (__ACE_INLINE__)
00011 # include "tao/PI/PICurrent_Impl.inl"
00012 #endif
00013
00014 #include "tao/TAO_Server_Request.h"
00015 #include "tao/SystemException.h"
00016 #include "ace/Log_Msg.h"
00017 #include "tao/debug.h"
00018
00019 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00020
00021 CORBA::Any *
00022 TAO::PICurrent_Impl::get_slot (PortableInterceptor::SlotId identifier
00023 ACE_ENV_ARG_DECL)
00024 ACE_THROW_SPEC ((CORBA::SystemException,
00025 PortableInterceptor::InvalidSlot))
00026 {
00027
00028
00029
00030
00031 if ( (0 != this->lazy_copy_)
00032 && (&this->lazy_copy_->current_slot_table () == &this->slot_table_))
00033 {
00034 if (TAO_debug_level > 0)
00035 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("TAO (%P|%t) Lazy copy of self detected at %N,%l\n")));
00036 ACE_THROW (CORBA::INTERNAL ());
00037 }
00038
00039
00040 PICurrent_Impl::Table & table = this->current_slot_table ();
00041 CORBA::Any * any = 0;
00042
00043 if (identifier < table.size ())
00044 {
00045 ACE_NEW_THROW_EX (any,
00046 CORBA::Any (table[identifier]),
00047 CORBA::NO_MEMORY (
00048 CORBA::SystemException::_tao_minor_code (
00049 0,
00050 ENOMEM),
00051 CORBA::COMPLETED_NO));
00052 ACE_CHECK_RETURN (any);
00053 }
00054 else
00055 {
00056
00057
00058
00059 ACE_NEW_THROW_EX (any,
00060 CORBA::Any,
00061 CORBA::NO_MEMORY (
00062 CORBA::SystemException::_tao_minor_code (
00063 0,
00064 ENOMEM),
00065 CORBA::COMPLETED_NO));
00066 ACE_CHECK_RETURN (any);
00067 }
00068
00069 return any;
00070 }
00071
00072 void
00073 TAO::PICurrent_Impl::set_slot (PortableInterceptor::SlotId identifier,
00074 const CORBA::Any & data
00075 ACE_ENV_ARG_DECL)
00076 ACE_THROW_SPEC ((CORBA::SystemException,
00077 PortableInterceptor::InvalidSlot))
00078 {
00079
00080
00081
00082
00083
00084 if (0 != this->impending_change_callback_)
00085 this->impending_change_callback_->convert_from_lazy_to_real_copy ();
00086
00087
00088
00089 this->convert_from_lazy_to_real_copy ();
00090
00091
00092
00093
00094 if (identifier >= this->slot_table_.size ()
00095 && this->slot_table_.size (identifier + 1) != 0)
00096 ACE_THROW (CORBA::INTERNAL ());
00097
00098 this->slot_table_[identifier] = CORBA::Any (data);
00099 }
00100
00101 void
00102 TAO::PICurrent_Impl::take_lazy_copy (
00103 TAO::PICurrent_Impl * p)
00104 {
00105
00106
00107
00108 if ( (p != this->lazy_copy_)
00109 && ((0 == p) || (&p->current_slot_table () != &this->current_slot_table ()))
00110 )
00111 {
00112
00113
00114 if (0 != this->impending_change_callback_)
00115 this->impending_change_callback_->convert_from_lazy_to_real_copy ();
00116
00117
00118
00119
00120 if (0 != this->lazy_copy_)
00121 this->lazy_copy_->set_callback_for_impending_change (0);
00122
00123
00124 if ((0 == p) || (this == p))
00125 {
00126 this->lazy_copy_ = 0;
00127 }
00128 else
00129 {
00130 this->lazy_copy_ = p;
00131
00132
00133
00134 this->lazy_copy_->set_callback_for_impending_change (this);
00135 }
00136 }
00137 }
00138
00139 TAO_END_VERSIONED_NAMESPACE_DECL
00140
00141 #endif