TAO::PICurrent_Impl Class Reference

Implementation of the PortableInterceptor::Current interface. More...

#include <PICurrent_Impl.h>

Collaboration diagram for TAO::PICurrent_Impl:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 PICurrent_Impl (void)
 Constructor.

 ~PICurrent_Impl (void)
 Destructor.

CORBA::Any * get_slot (PortableInterceptor::SlotId identifier) throw (CORBA::SystemException, PortableInterceptor::InvalidSlot)
void set_slot (PortableInterceptor::SlotId identifier, const CORBA::Any &data) throw (CORBA::SystemException, PortableInterceptor::InvalidSlot)
 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.


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)
Tablecurrent_slot_table ()
 PICurrent_Impl (const PICurrent_Impl &)
void operator= (const PICurrent_Impl &)

Private Attributes

Table slot_table_
 Array of CORBA::Anys that is the underlying "slot table.".

PICurrent_Impllazy_copy_
PICurrent_Implimpending_change_callback_

Detailed Description

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 50 of file PICurrent_Impl.h.


Member Typedef Documentation

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.


Constructor & Destructor Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE TAO::PICurrent_Impl::PICurrent_Impl void   ) 
 

Constructor.

Definition at line 8 of file PICurrent_Impl.inl.

00009   : slot_table_ (),
00010     lazy_copy_ (0),
00011     impending_change_callback_ (0)
00012 {
00013 }

ACE_INLINE TAO::PICurrent_Impl::~PICurrent_Impl void   ) 
 

Destructor.

Definition at line 16 of file PICurrent_Impl.inl.

References convert_from_lazy_to_real_copy(), impending_change_callback_, lazy_copy_, and set_callback_for_impending_change().

00017 {
00018   // Break any existing ties that another PICurrent has with our table
00019   // since our table will no longer exist once this destructor completes.
00020   if (0 != this->impending_change_callback_)
00021     this->impending_change_callback_->convert_from_lazy_to_real_copy ();
00022 
00023   // If we have logically copied another table, ensure it is told about our
00024   // demise so that it will not call our non-existant
00025   // convert_from_lazy_to_real_copy() when it changes/destructs.
00026   if (0 != this->lazy_copy_)
00027     this->lazy_copy_->set_callback_for_impending_change (0);
00028 }

TAO::PICurrent_Impl::PICurrent_Impl const PICurrent_Impl  )  [private]
 

Prevent copying through the copy constructor and the assignment operator.


Member Function Documentation

ACE_INLINE 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 31 of file PICurrent_Impl.inl.

References current_slot_table(), lazy_copy_, set_callback_for_impending_change(), and slot_table_.

Referenced by take_lazy_copy(), and ~PICurrent_Impl().

00032 {
00033   // Make sure we take a physical copy of the existing logical
00034   // copy of the table before it disappears/changes.
00035   if (0 != this->lazy_copy_)
00036     {
00037       this->slot_table_ = this->lazy_copy_->current_slot_table ();
00038 
00039       // Must tell the old copied PICurrent_Impl that we no
00040       // longer want to be told when/if it is going to be
00041       // changed or destroyed.
00042       this->lazy_copy_->set_callback_for_impending_change (0);
00043       this->lazy_copy_ = 0;
00044     }
00045 }

ACE_INLINE TAO::PICurrent_Impl::Table & TAO::PICurrent_Impl::current_slot_table  )  [private]
 

Returns:
Logically copied slot table if available, otherwise underlying slot table.

Definition at line 54 of file PICurrent_Impl.inl.

References lazy_copy_, and slot_table_.

Referenced by convert_from_lazy_to_real_copy(), and take_lazy_copy().

00055 {
00056   return (0 == this->lazy_copy_) ?
00057          this->slot_table_ :
00058          this->lazy_copy_->current_slot_table ();
00059 }

TAO_BEGIN_VERSIONED_NAMESPACE_DECL CORBA::Any * TAO::PICurrent_Impl::get_slot PortableInterceptor::SlotId  identifier  )  throw (CORBA::SystemException, PortableInterceptor::InvalidSlot)
 

Retrieve information stored in the slot table at the given SlotId.

Definition at line 22 of file PICurrent_Impl.cpp.

References ACE_CHECK_RETURN, ACE_DEBUG, ACE_NEW_THROW_EX, ACE_TEXT, ACE_THROW, LM_DEBUG, and TAO_debug_level.

Referenced by TAO::PICurrent::get_slot().

00026 {
00027   // No need to check validity of SlotId.  It is validated before this
00028   // method is invoked.
00029 
00030   // The active slot table should never be a lazy copy of itself!
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   // Get the slot table that is currently active
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]), // Make a copy.
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       // In accordance with the Portable Interceptor specification,
00057       // return an Any with a TCKind of tk_null.  A default
00058       // constructed Any has that TCKind.
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 }

void TAO::PICurrent_Impl::operator= const PICurrent_Impl  )  [private]
 

Prevent copying through the copy constructor and the assignment operator.

ACE_INLINE void TAO::PICurrent_Impl::set_callback_for_impending_change 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 48 of file PICurrent_Impl.inl.

References impending_change_callback_.

Referenced by convert_from_lazy_to_real_copy(), take_lazy_copy(), and ~PICurrent_Impl().

00049 {
00050   this->impending_change_callback_ = (this == p) ? 0 : p;
00051 }

void TAO::PICurrent_Impl::set_slot PortableInterceptor::SlotId  identifier,
const CORBA::Any &  data
throw (CORBA::SystemException, PortableInterceptor::InvalidSlot)
 

Set information in the slot table at the given SlotId.

Definition at line 73 of file PICurrent_Impl.cpp.

References ACE_THROW.

Referenced by TAO::PICurrent::set_slot().

00078 {
00079   // No need to check validity of SlotId.  It is validated before this
00080   // method is invoked.
00081 
00082   // Break any existing ties that another PICurrent has with our table
00083   // since our table is changing.
00084   if (0 != this->impending_change_callback_)
00085     this->impending_change_callback_->convert_from_lazy_to_real_copy ();
00086 
00087   // Ensure that we have a real physical copy of the table before
00088   // making any changes to it.
00089   this->convert_from_lazy_to_real_copy ();
00090 
00091   // If the slot table array isn't large enough, then increase its
00092   // size.  We're guaranteed not to exceed the number of allocated
00093   // slots for the reason stated above.
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 }

void TAO::PICurrent_Impl::take_lazy_copy PICurrent_Impl p  ) 
 

Logically/Lazy (shallow) copy the given object's slot table.

Definition at line 102 of file PICurrent_Impl.cpp.

References convert_from_lazy_to_real_copy(), current_slot_table(), impending_change_callback_, lazy_copy_, and set_callback_for_impending_change().

Referenced by TAO_ClientRequestInfo::setup_picurrent().

00104 {
00105   // Check that we are being told to actually change which table we are
00106   // copying from. (If it is the same as before OR it would ultimately be
00107   // the same table, we are already correctly setup and we do nothing.)
00108   if ( (p != this->lazy_copy_)
00109       && ((0 == p) || (&p->current_slot_table () != &this->current_slot_table ()))
00110       )
00111     {
00112       // Break any existing ties that another PICurrent has with our table
00113       // since our table is changing.
00114       if (0 != this->impending_change_callback_)
00115         this->impending_change_callback_->convert_from_lazy_to_real_copy ();
00116 
00117       // If we have previously logically copied another table, ensure it is
00118       // told that we are no longer interested in it so that it will not
00119       // call our conver_from_lazy_to_real_copy() when it changes/destructs.
00120       if (0 != this->lazy_copy_)
00121         this->lazy_copy_->set_callback_for_impending_change (0);
00122 
00123       // Are we being asked to copy ourself (or nothing)
00124       if ((0 == p) || (this == p))
00125         {
00126           this->lazy_copy_ = 0; // Use our own physical slot_table_
00127         }
00128       else
00129         {
00130           this->lazy_copy_ = p;
00131 
00132           // Must tell the newly copied PICurrent_Impl that we want to
00133           // be told when/if it is going to be changed or destroyed.
00134           this->lazy_copy_->set_callback_for_impending_change (this);
00135         }
00136     }
00137 }


Member Data Documentation

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 119 of file PICurrent_Impl.h.

Referenced by set_callback_for_impending_change(), take_lazy_copy(), and ~PICurrent_Impl().

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 112 of file PICurrent_Impl.h.

Referenced by convert_from_lazy_to_real_copy(), current_slot_table(), take_lazy_copy(), and ~PICurrent_Impl().

Table TAO::PICurrent_Impl::slot_table_ [private]
 

Array of CORBA::Anys that is the underlying "slot table.".

Definition at line 108 of file PICurrent_Impl.h.

Referenced by convert_from_lazy_to_real_copy(), and current_slot_table().


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 12:52:53 2006 for TAO_PI by doxygen 1.3.6