Implementation of the PortableInterceptor::Current interface. More...
#include <PICurrent_Impl.h>

Public Member Functions | |
| PICurrent_Impl (TAO_ORB_Core *orb_core=0, size_t tss_slot=0, PICurrent_Impl *pop=0) | |
| Constructor. | |
| ~PICurrent_Impl (void) | |
| Destructor. | |
| CORBA::Any * | get_slot (PortableInterceptor::SlotId identifier) |
| void | set_slot (PortableInterceptor::SlotId identifier, const CORBA::Any &data) |
| Set information in the slot table at the given SlotId. | |
| void | take_lazy_copy (PICurrent_Impl *p) |
| Logically/Lazy (shallow) copy the given object's slot table. | |
| void | push (void) |
| Push a new PICurrent_Impl on stack. | |
| void | pop (void) |
| Pop old PICurrent_Impl from stack. | |
Private Types | |
| typedef ACE_Array_Base < CORBA::Any > | Table |
| Typedef for the underyling "slot table.". | |
Private Member Functions | |
| void | convert_from_lazy_to_real_copy () |
| void | set_callback_for_impending_change (PICurrent_Impl *p) |
| Table & | current_slot_table () |
| PICurrent_Impl (const PICurrent_Impl &) | |
| void | operator= (const PICurrent_Impl &) |
Private Attributes | |
| TAO_ORB_Core * | orb_core_ |
| Allow for stack of PICurrent_Impl as required. | |
| size_t | tss_slot_ |
| PICurrent_Impl * | pop_ |
| PICurrent_Impl * | push_ |
| Table | slot_table_ |
| Array of CORBA::Anys that is the underlying "slot table.". | |
| PICurrent_Impl * | lazy_copy_ |
| PICurrent_Impl * | impending_change_callback_ |
Implementation of the PortableInterceptor::Current interface.
This class implements both the "request scope current" and the "thread scope current" objects as required by Portable Interceptors.
Definition at line 49 of file PICurrent_Impl.h.
typedef ACE_Array_Base<CORBA::Any> TAO::PICurrent_Impl::Table [private] |
Typedef for the underyling "slot table.".
Definition at line 89 of file PICurrent_Impl.h.
| TAO::PICurrent_Impl::PICurrent_Impl | ( | TAO_ORB_Core * | orb_core = 0, |
|
| size_t | tss_slot = 0, |
|||
| PICurrent_Impl * | pop = 0 | |||
| ) |
Constructor.
Definition at line 8 of file PICurrent_Impl.inl.
: orb_core_ (orb_core), tss_slot_ (tss_slot), pop_ (pop), push_ (0), slot_table_ (), lazy_copy_ (0), impending_change_callback_ (0) { }
| TAO::PICurrent_Impl::~PICurrent_Impl | ( | void | ) |
Destructor.
Definition at line 132 of file PICurrent_Impl.cpp.
{
if (this->push_)
{
// We have YOUNGER stack members to REMOVE as well. HOWEVER we
// don't want the entry above us coming back down and trying
// to delete us again. (As we are currently doing just that.)
this->push_->pop_= 0;
delete this->push_;
}
else if (this->orb_core_)
{
// Since there are no entries above us, we must be the top of
// the stack and since all are being deleted, the stack will
// be empty.
this->orb_core_->set_tss_resource (this->tss_slot_, 0);
}
// Break any existing ties that another PICurrent has with our table
// since our table will no longer exists once this destructor completes.
if (0 != this->impending_change_callback_)
this->impending_change_callback_->convert_from_lazy_to_real_copy ();
// If we have logically copied another table, ensure it is told about our
// demise so that it will not call our non-existant
// convert_from_lazy_to_real_copy() when it changes/destructs.
if (0 != this->lazy_copy_)
this->lazy_copy_->set_callback_for_impending_change (0);
if (this->pop_)
{
// We have OLDER stack members to REMOVE as well. HOWEVER we
// don't want multiple adjustments of the stack head pointer from
// every older entry as they delete, as this requires multiple
// set_tss_resource updates which would be slow and unnecessary.
this->pop_->orb_core_= 0;
// We also don't want double deletions of what used to be above these
// since we have just completed the deletion of these ourselves.
this->pop_->push_= 0;
delete this->pop_;
}
}
| TAO::PICurrent_Impl::PICurrent_Impl | ( | const PICurrent_Impl & | ) | [private] |
Prevent copying through the copy constructor and the assignment operator.
| void TAO::PICurrent_Impl::convert_from_lazy_to_real_copy | ( | ) | [private] |
Force this object to convert from a logical (referenced) copy, to a physical (or deep, actual) copy.
Definition at line 23 of file PICurrent_Impl.inl.
{
// Make sure we take a physical copy of the existing logical
// copy of the table before it disappears/changes.
if (0 != this->lazy_copy_)
{
this->slot_table_ = this->lazy_copy_->current_slot_table ();
// Must tell the old copied PICurrent_Impl that we no
// longer want to be told when/if it is going to be
// changed or destroyed.
this->lazy_copy_->set_callback_for_impending_change (0);
this->lazy_copy_ = 0;
}
}
| TAO::PICurrent_Impl::Table & TAO::PICurrent_Impl::current_slot_table | ( | ) | [private] |
Return a reference to the slot table currently associated with this PICurrent_Impl object.
Definition at line 46 of file PICurrent_Impl.inl.
{
return (0 == this->lazy_copy_) ?
this->slot_table_ :
this->lazy_copy_->current_slot_table ();
}
| CORBA::Any * TAO::PICurrent_Impl::get_slot | ( | PortableInterceptor::SlotId | identifier | ) |
Retrieve information stored in the slot table at the given SlotId.
Definition at line 23 of file PICurrent_Impl.cpp.
{
// No need to check validity of SlotId. It is validated before this
// method is invoked.
// The active slot table should never be a lazy copy of itself!
if ( (0 != this->lazy_copy_)
&& (&this->lazy_copy_->current_slot_table () == &this->slot_table_))
{
if (TAO_debug_level > 0)
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("TAO (%P|%t) Lazy copy of self detected at %N,%l\n")));
throw ::CORBA::INTERNAL ();
}
// Get the slot table that is currently active
PICurrent_Impl::Table & table = this->current_slot_table ();
CORBA::Any * any = 0;
if (identifier < table.size ())
{
ACE_NEW_THROW_EX (any,
CORBA::Any (table[identifier]), // Make a copy.
CORBA::NO_MEMORY (
CORBA::SystemException::_tao_minor_code (
0,
ENOMEM),
CORBA::COMPLETED_NO));
}
else
{
// In accordance with the Portable Interceptor specification,
// return an Any with a TCKind of tk_null. A default
// constructed Any has that TCKind.
ACE_NEW_THROW_EX (any,
CORBA::Any,
CORBA::NO_MEMORY (
CORBA::SystemException::_tao_minor_code (
0,
ENOMEM),
CORBA::COMPLETED_NO));
}
return any;
}
| void TAO::PICurrent_Impl::operator= | ( | const PICurrent_Impl & | ) | [private] |
Prevent copying through the copy constructor and the assignment operator.
| void TAO::PICurrent_Impl::pop | ( | void | ) |
Pop old PICurrent_Impl from stack.
Definition at line 204 of file PICurrent_Impl.cpp.
{
if (this->orb_core_) // We have a stack to adjust
{
TAO::PICurrent_Impl *const currentHead =
static_cast<TAO::PICurrent_Impl *> (
this->orb_core_->get_tss_resource (this->tss_slot_));
if (currentHead->pop_)
orb_core_->set_tss_resource (tss_slot_, currentHead->pop_);
else
throw ::CORBA::INTERNAL (); // Too many pop's
}
else
throw ::CORBA::INTERNAL (); // Should only call push if we have a stack
}
| void TAO::PICurrent_Impl::push | ( | void | ) |
Push a new PICurrent_Impl on stack.
Definition at line 178 of file PICurrent_Impl.cpp.
{
if (this->orb_core_) // We have a stack to adjust
{
TAO::PICurrent_Impl *const currentHead =
static_cast<TAO::PICurrent_Impl *> (
this->orb_core_->get_tss_resource (this->tss_slot_));
if (!currentHead->push_)
{
// Since there is nothing younger above us, we need to create
// a new entry.
ACE_NEW_THROW_EX (currentHead->push_,
PICurrent_Impl (this->orb_core_, this->tss_slot_, currentHead),
CORBA::NO_MEMORY (
CORBA::SystemException::_tao_minor_code (
0,
ENOMEM),
CORBA::COMPLETED_NO));
}
this->orb_core_->set_tss_resource (this->tss_slot_, currentHead->push_);
}
else
throw ::CORBA::INTERNAL (); // Should only call push if we have a stack
}
| void TAO::PICurrent_Impl::set_callback_for_impending_change | ( | TAO::PICurrent_Impl * | p | ) | [private] |
Set the callback PICurrent_Impl object that will be notified of this object's impending destruction or change. Set to 0 to clear. (NOTE Only handles a SINGLE object at at time, does NOT warn previous callback that this has been changed.)
Definition at line 40 of file PICurrent_Impl.inl.
{
this->impending_change_callback_ = (this == p) ? 0 : p;
}
| void TAO::PICurrent_Impl::set_slot | ( | PortableInterceptor::SlotId | identifier, | |
| const CORBA::Any & | data | |||
| ) |
Set information in the slot table at the given SlotId.
Definition at line 69 of file PICurrent_Impl.cpp.
{
// No need to check validity of SlotId. It is validated before this
// method is invoked.
// Break any existing ties that another PICurrent has with our table
// since our table is changing.
if (0 != this->impending_change_callback_)
this->impending_change_callback_->convert_from_lazy_to_real_copy ();
// Ensure that we have a real physical copy of the table before
// making any changes to it.
this->convert_from_lazy_to_real_copy ();
// If the slot table array isn't large enough, then increase its
// size. We're guaranteed not to exceed the number of allocated
// slots for the reason stated above.
if (identifier >= this->slot_table_.size ()
&& this->slot_table_.size (identifier + 1) != 0)
throw ::CORBA::INTERNAL ();
this->slot_table_[identifier] = CORBA::Any (data);
}
| void TAO::PICurrent_Impl::take_lazy_copy | ( | TAO::PICurrent_Impl * | p | ) |
Logically/Lazy (shallow) copy the given object's slot table.
Definition at line 95 of file PICurrent_Impl.cpp.
{
// Check that we are being told to actually change which table we are
// copying from. (If it is the same as before OR it would ultimately be
// the same table, we are already correctly setup and we do nothing.)
if ( (p != this->lazy_copy_)
&& ((0 == p) || (&p->current_slot_table () != &this->current_slot_table ()))
)
{
// Break any existing ties that another PICurrent has with our table
// since our table is changing.
if (0 != this->impending_change_callback_)
this->impending_change_callback_->convert_from_lazy_to_real_copy ();
// If we have previously logically copied another table, ensure it is
// told that we are no longer interested in it so that it will not
// call our conver_from_lazy_to_real_copy() when it changes/destructs.
if (0 != this->lazy_copy_)
this->lazy_copy_->set_callback_for_impending_change (0);
// Are we being asked to copy ourself (or nothing)
if ((0 == p) || (this == p))
{
this->lazy_copy_ = 0; // Use our own physical slot_table_
}
else
{
this->lazy_copy_ = p;
// Must tell the newly copied PICurrent_Impl that we want to
// be told when/if it is going to be changed or destroyed.
this->lazy_copy_->set_callback_for_impending_change (this);
}
}
}
PICurrent_Impl* TAO::PICurrent_Impl::impending_change_callback_ [private] |
PICurrent_Impl object that will be notified of this object's impending destruction or change to its slot_table_. This is the PICurrent_Impl that has access to our slot_table_ via its lazy_copy_ pointer. As necessary this allows that object's convert_from_lazy_to_real_copy() to be called.
Definition at line 125 of file PICurrent_Impl.h.
PICurrent_Impl* TAO::PICurrent_Impl::lazy_copy_ [private] |
Access to logical copy from a PICurrent_Impl in another scope, i.e. either the request scope or the thread scope.
Definition at line 118 of file PICurrent_Impl.h.
TAO_ORB_Core* TAO::PICurrent_Impl::orb_core_ [private] |
Allow for stack of PICurrent_Impl as required.
Definition at line 108 of file PICurrent_Impl.h.
PICurrent_Impl* TAO::PICurrent_Impl::pop_ [private] |
Definition at line 110 of file PICurrent_Impl.h.
PICurrent_Impl* TAO::PICurrent_Impl::push_ [private] |
Definition at line 111 of file PICurrent_Impl.h.
Table TAO::PICurrent_Impl::slot_table_ [private] |
Array of CORBA::Anys that is the underlying "slot table.".
Definition at line 114 of file PICurrent_Impl.h.
size_t TAO::PICurrent_Impl::tss_slot_ [private] |
Definition at line 109 of file PICurrent_Impl.h.
1.7.0