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 76995 2007-02-11 12:51:42Z johnnyw $")
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 "ace/Log_Msg.h"
00016 #include "tao/debug.h"
00017 #include "ace/CORBA_macros.h"
00018
00019 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00020
00021 CORBA::Any *
00022 TAO::PICurrent_Impl::get_slot (PortableInterceptor::SlotId identifier)
00023 {
00024
00025
00026
00027
00028 if ( (0 != this->lazy_copy_)
00029 && (&this->lazy_copy_->current_slot_table () == &this->slot_table_))
00030 {
00031 if (TAO_debug_level > 0)
00032 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("TAO (%P|%t) Lazy copy of self detected at %N,%l\n")));
00033 throw ::CORBA::INTERNAL ();
00034 }
00035
00036
00037 PICurrent_Impl::Table & table = this->current_slot_table ();
00038 CORBA::Any * any = 0;
00039
00040 if (identifier < table.size ())
00041 {
00042 ACE_NEW_THROW_EX (any,
00043 CORBA::Any (table[identifier]),
00044 CORBA::NO_MEMORY (
00045 CORBA::SystemException::_tao_minor_code (
00046 0,
00047 ENOMEM),
00048 CORBA::COMPLETED_NO));
00049 }
00050 else
00051 {
00052
00053
00054
00055 ACE_NEW_THROW_EX (any,
00056 CORBA::Any,
00057 CORBA::NO_MEMORY (
00058 CORBA::SystemException::_tao_minor_code (
00059 0,
00060 ENOMEM),
00061 CORBA::COMPLETED_NO));
00062 }
00063
00064 return any;
00065 }
00066
00067 void
00068 TAO::PICurrent_Impl::set_slot (PortableInterceptor::SlotId identifier,
00069 const CORBA::Any & data)
00070 {
00071
00072
00073
00074
00075
00076 if (0 != this->impending_change_callback_)
00077 this->impending_change_callback_->convert_from_lazy_to_real_copy ();
00078
00079
00080
00081 this->convert_from_lazy_to_real_copy ();
00082
00083
00084
00085
00086 if (identifier >= this->slot_table_.size ()
00087 && this->slot_table_.size (identifier + 1) != 0)
00088 throw ::CORBA::INTERNAL ();
00089
00090 this->slot_table_[identifier] = CORBA::Any (data);
00091 }
00092
00093 void
00094 TAO::PICurrent_Impl::take_lazy_copy (
00095 TAO::PICurrent_Impl * p)
00096 {
00097
00098
00099
00100 if ( (p != this->lazy_copy_)
00101 && ((0 == p) || (&p->current_slot_table () != &this->current_slot_table ()))
00102 )
00103 {
00104
00105
00106 if (0 != this->impending_change_callback_)
00107 this->impending_change_callback_->convert_from_lazy_to_real_copy ();
00108
00109
00110
00111
00112 if (0 != this->lazy_copy_)
00113 this->lazy_copy_->set_callback_for_impending_change (0);
00114
00115
00116 if ((0 == p) || (this == p))
00117 {
00118 this->lazy_copy_ = 0;
00119 }
00120 else
00121 {
00122 this->lazy_copy_ = p;
00123
00124
00125
00126 this->lazy_copy_->set_callback_for_impending_change (this);
00127 }
00128 }
00129 }
00130
00131 TAO_END_VERSIONED_NAMESPACE_DECL
00132
00133 #endif