Go to the documentation of this file.00001 #include "tao/PI/PICurrent_Impl.h"
00002
00003 #if TAO_HAS_INTERCEPTORS == 1
00004
00005 ACE_RCSID (tao,
00006 PICurrent,
00007 "$Id: PICurrent_Impl.cpp 85371 2009-05-18 13:39:38Z sma $")
00008
00009 #include "tao/ORB_Core.h"
00010
00011 #if !defined (__ACE_INLINE__)
00012 # include "tao/PI/PICurrent_Impl.inl"
00013 #endif
00014
00015 #include "tao/TAO_Server_Request.h"
00016 #include "ace/Log_Msg.h"
00017 #include "tao/debug.h"
00018 #include "ace/CORBA_macros.h"
00019
00020 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00021
00022 CORBA::Any *
00023 TAO::PICurrent_Impl::get_slot (PortableInterceptor::SlotId identifier)
00024 {
00025
00026
00027
00028
00029 if ( (0 != this->lazy_copy_)
00030 && (&this->lazy_copy_->current_slot_table () == &this->slot_table_))
00031 {
00032 if (TAO_debug_level > 0)
00033 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("TAO (%P|%t) Lazy copy of self detected at %N,%l\n")));
00034 throw ::CORBA::INTERNAL ();
00035 }
00036
00037
00038 PICurrent_Impl::Table & table = this->current_slot_table ();
00039 CORBA::Any * any = 0;
00040
00041 if (identifier < table.size ())
00042 {
00043 ACE_NEW_THROW_EX (any,
00044 CORBA::Any (table[identifier]),
00045 CORBA::NO_MEMORY (
00046 CORBA::SystemException::_tao_minor_code (
00047 0,
00048 ENOMEM),
00049 CORBA::COMPLETED_NO));
00050 }
00051 else
00052 {
00053
00054
00055
00056 ACE_NEW_THROW_EX (any,
00057 CORBA::Any,
00058 CORBA::NO_MEMORY (
00059 CORBA::SystemException::_tao_minor_code (
00060 0,
00061 ENOMEM),
00062 CORBA::COMPLETED_NO));
00063 }
00064
00065 return any;
00066 }
00067
00068 void
00069 TAO::PICurrent_Impl::set_slot (PortableInterceptor::SlotId identifier,
00070 const CORBA::Any & data)
00071 {
00072
00073
00074
00075
00076
00077 if (0 != this->impending_change_callback_)
00078 this->impending_change_callback_->convert_from_lazy_to_real_copy ();
00079
00080
00081
00082 this->convert_from_lazy_to_real_copy ();
00083
00084
00085
00086
00087 if (identifier >= this->slot_table_.size ()
00088 && this->slot_table_.size (identifier + 1) != 0)
00089 throw ::CORBA::INTERNAL ();
00090
00091 this->slot_table_[identifier] = CORBA::Any (data);
00092 }
00093
00094 void
00095 TAO::PICurrent_Impl::take_lazy_copy (
00096 TAO::PICurrent_Impl * p)
00097 {
00098
00099
00100
00101 if ( (p != this->lazy_copy_)
00102 && ((0 == p) || (&p->current_slot_table () != &this->current_slot_table ()))
00103 )
00104 {
00105
00106
00107 if (0 != this->impending_change_callback_)
00108 this->impending_change_callback_->convert_from_lazy_to_real_copy ();
00109
00110
00111
00112
00113 if (0 != this->lazy_copy_)
00114 this->lazy_copy_->set_callback_for_impending_change (0);
00115
00116
00117 if ((0 == p) || (this == p))
00118 {
00119 this->lazy_copy_ = 0;
00120 }
00121 else
00122 {
00123 this->lazy_copy_ = p;
00124
00125
00126
00127 this->lazy_copy_->set_callback_for_impending_change (this);
00128 }
00129 }
00130 }
00131
00132 TAO::PICurrent_Impl::~PICurrent_Impl ()
00133 {
00134 if (this->push_)
00135 {
00136
00137
00138
00139 this->push_->pop_= 0;
00140
00141 delete this->push_;
00142 }
00143 else if (this->orb_core_)
00144 {
00145
00146
00147
00148 this->orb_core_->set_tss_resource (this->tss_slot_, 0);
00149 }
00150
00151
00152
00153 if (0 != this->impending_change_callback_)
00154 this->impending_change_callback_->convert_from_lazy_to_real_copy ();
00155
00156
00157
00158
00159 if (0 != this->lazy_copy_)
00160 this->lazy_copy_->set_callback_for_impending_change (0);
00161
00162 if (this->pop_)
00163 {
00164
00165
00166
00167
00168 this->pop_->orb_core_= 0;
00169
00170
00171
00172 this->pop_->push_= 0;
00173 delete this->pop_;
00174 }
00175 }
00176
00177 void
00178 TAO::PICurrent_Impl::push (void)
00179 {
00180 if (this->orb_core_)
00181 {
00182 TAO::PICurrent_Impl *const currentHead =
00183 static_cast<TAO::PICurrent_Impl *> (
00184 this->orb_core_->get_tss_resource (this->tss_slot_));
00185 if (!currentHead->push_)
00186 {
00187
00188
00189 ACE_NEW_THROW_EX (currentHead->push_,
00190 PICurrent_Impl (this->orb_core_, this->tss_slot_, currentHead),
00191 CORBA::NO_MEMORY (
00192 CORBA::SystemException::_tao_minor_code (
00193 0,
00194 ENOMEM),
00195 CORBA::COMPLETED_NO));
00196 }
00197 this->orb_core_->set_tss_resource (this->tss_slot_, currentHead->push_);
00198 }
00199 else
00200 throw ::CORBA::INTERNAL ();
00201 }
00202
00203 void
00204 TAO::PICurrent_Impl::pop (void)
00205 {
00206 if (this->orb_core_)
00207 {
00208 TAO::PICurrent_Impl *const currentHead =
00209 static_cast<TAO::PICurrent_Impl *> (
00210 this->orb_core_->get_tss_resource (this->tss_slot_));
00211 if (currentHead->pop_)
00212 orb_core_->set_tss_resource (tss_slot_, currentHead->pop_);
00213 else
00214 throw ::CORBA::INTERNAL ();
00215 }
00216 else
00217 throw ::CORBA::INTERNAL ();
00218 }
00219
00220 TAO_END_VERSIONED_NAMESPACE_DECL
00221
00222 #endif