Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

TAO_PICurrent_Impl Class Reference

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

#include <PICurrent.h>

Collaboration diagram for TAO_PICurrent_Impl:

Collaboration graph
[legend]
List of all members.

Public Types

typedef ACE_Array_Base< CORBA::AnyTable
 Typedef for the underyling "slot table.". More...


Public Methods

 TAO_PICurrent_Impl (void)
 Constructor. More...

 ~TAO_PICurrent_Impl (void)
 Destructor. More...

CORBA::Anyget_slot (PortableInterceptor::SlotId id ACE_ENV_ARG_DECL) throw (CORBA::SystemException, PortableInterceptor::InvalidSlot)
 Retrieve information stored in the slot table at the given SlotId. More...

void set_slot (PortableInterceptor::SlotId id, const CORBA::Any &data ACE_ENV_ARG_DECL) throw (CORBA::SystemException, PortableInterceptor::InvalidSlot)
 Set information in the slot table at the given SlotId. More...

TAO_PICurrent_Impl * pi_peer (void)
 Get the PICurrent peer associated with this PICurrent implementation. More...

void pi_peer (TAO_PICurrent_Impl *peer)
 Set the PICurrent peer associated with this PICurrent implementation. More...

Tableslot_table (void)
 Return a reference to the underlying slot table. More...

void dirty (CORBA::Boolean dirty)
 Mark the slot table as being clean or dirty. The slot table is dirty if it has been modified since the last time it was copied. More...

CORBA::Boolean dirty (void) const
 Flag that specifies if the underlying slot table has been modified since last copy. More...

void copy (TAO_PICurrent_Impl &rhs, CORBA::Boolean deep_copy)
 Copy the contents of the given PICurrent. More...


Private Methods

 TAO_PICurrent_Impl (const TAO_PICurrent_Impl &)
void operator= (const TAO_PICurrent_Impl &)

Private Attributes

TAO_PICurrent_Impl * pi_peer_
 The PICurrent implementation with which this implementation's slot table interacts. More...

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

Tablelc_slot_table_
 Table that was logically copied from a PICurrent in another scope, i.e. either the request scope or the thread scope. More...

CORBA::Boolean dirty_
 Flag that specifies if the underlying slot table has been modified since last copy. More...


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 151 of file PICurrent.h.


Member Typedef Documentation

typedef ACE_Array_Base<CORBA::Any> TAO_PICurrent_Impl::Table
 

Typedef for the underyling "slot table.".

Note:
The slot table is implemented as an array of pointers to void to simply avoid increasing the footprint of the ORB. A template instance of ACE_Array_Base<void*> is already used by TAO_ORB_Core_TSS_Resources. Thus, no increase in footprint will occur due to this template instance.

Definition at line 164 of file PICurrent.h.

Referenced by get_slot.


Constructor & Destructor Documentation

TAO_PICurrent_Impl::TAO_PICurrent_Impl void   
 

Constructor.

Definition at line 106 of file PICurrent.cpp.

00107   : pi_peer_ (0),
00108     slot_table_ (),
00109     lc_slot_table_ (0),
00110     dirty_ (0)
00111 {
00112 }

TAO_PICurrent_Impl::~TAO_PICurrent_Impl void   
 

Destructor.

Definition at line 114 of file PICurrent.cpp.

References pi_peer, and pi_peer_.

00115 {
00116   // Make sure the peer TAO_PICurrent_Impl object no longer considers
00117   // this TAO_PICurrent_Impl its peer since this object will no longer
00118   // exist once this destructor completes execution.
00119   if (this->pi_peer_ != 0 && this->pi_peer_->pi_peer () == this)
00120     this->pi_peer_->pi_peer (0);
00121 }

TAO_PICurrent_Impl::TAO_PICurrent_Impl const TAO_PICurrent_Impl &    [private]
 


Member Function Documentation

void TAO_PICurrent_Impl::copy TAO_PICurrent_Impl &    rhs,
CORBA::Boolean    deep_copy
 

Copy the contents of the given PICurrent.

Definition at line 216 of file PICurrent.cpp.

References dirty, dirty_, lc_slot_table_, pi_peer, pi_peer_, ACE_Array_Base< CORBA::Any >::size, slot_table, and slot_table_.

Referenced by TAO_PICurrent::set_slot, TAO_ClientRequestInfo_i::setup_picurrent, and TAO_PICurrent_Guard::~TAO_PICurrent_Guard.

00217 {
00218   if (!rhs.dirty ())
00219     return;  // Nothing to copy
00220 
00221   if (deep_copy)
00222     {
00223       const Table &t = rhs.slot_table ();
00224       size_t new_size = t.size ();
00225 
00226       this->slot_table_.size (new_size);
00227 
00228       for (size_t i = 0; i < new_size; ++i)
00229         this->slot_table_[i] = t[i];  // Deep copy
00230 
00231       rhs.dirty (0);
00232 
00233       // Break all ties with the PICurrent peer.
00234       rhs.pi_peer (0);
00235       this->lc_slot_table_ = 0;
00236     }
00237   else
00238     {
00239       this->lc_slot_table_ = &rhs.slot_table ();  // Shallow copy
00240 
00241       this->pi_peer_ = &rhs;
00242 
00243       this->dirty_ = 1;
00244     }
00245 }

ACE_INLINE CORBA::Boolean TAO_PICurrent_Impl::dirty void    const
 

Flag that specifies if the underlying slot table has been modified since last copy.

Definition at line 48 of file PICurrent.inl.

References dirty_.

00049 {
00050   return this->dirty_;
00051 }

ACE_INLINE void TAO_PICurrent_Impl::dirty CORBA::Boolean    dirty
 

Mark the slot table as being clean or dirty. The slot table is dirty if it has been modified since the last time it was copied.

Definition at line 42 of file PICurrent.inl.

References dirty_.

Referenced by copy, and TAO_ClientRequestInfo_i::setup_picurrent.

00043 {
00044   this->dirty_ = d;
00045 }

CORBA::Any * TAO_PICurrent_Impl::get_slot PortableInterceptor::SlotId id    ACE_ENV_ARG_DECL throw (CORBA::SystemException, PortableInterceptor::InvalidSlot)
 

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

Definition at line 124 of file PICurrent.cpp.

References CORBA_SystemException::_tao_minor_code, ACE_CHECK_RETURN, ACE_ENV_ARG_DECL, ACE_NEW_THROW_EX, Table, and TAO_DEFAULT_MINOR_CODE.

Referenced by TAO_PICurrent::get_slot.

00128 {
00129   // No need to check validity of SlotId.  It is validated before this
00130   // method is invoked.
00131 
00132   TAO_PICurrent_Impl::Table &table =
00133     this->lc_slot_table_ == 0 ? this->slot_table_ : *this->lc_slot_table_;
00134 
00135   CORBA::Any * any = 0;
00136 
00137   if (id >= table.size ())
00138     {
00139       // In accordance with the Portable Interceptor specification,
00140       // return an Any with a TCKind of tk_null.  A default
00141       // constructed Any has that TCKind.
00142       ACE_NEW_THROW_EX (any,
00143                         CORBA::Any,
00144                         CORBA::NO_MEMORY (
00145                           CORBA_SystemException::_tao_minor_code (
00146                             TAO_DEFAULT_MINOR_CODE,
00147                             ENOMEM),
00148                           CORBA::COMPLETED_NO));
00149       ACE_CHECK_RETURN (0);
00150 
00151       return any;
00152     }
00153 
00154   ACE_NEW_THROW_EX (any,
00155                     CORBA::Any (table[id]), // Make a copy.
00156                     CORBA::NO_MEMORY (
00157                       CORBA_SystemException::_tao_minor_code (
00158                         TAO_DEFAULT_MINOR_CODE,
00159                         ENOMEM),
00160                       CORBA::COMPLETED_NO));
00161   ACE_CHECK_RETURN (0);
00162 
00163   return any;
00164 }

void TAO_PICurrent_Impl::operator= const TAO_PICurrent_Impl &    [private]
 

ACE_INLINE void TAO_PICurrent_Impl::pi_peer TAO_PICurrent_Impl *    peer
 

Set the PICurrent peer associated with this PICurrent implementation.

Definition at line 30 of file PICurrent.inl.

References pi_peer_.

00031 {
00032   this->pi_peer_ = peer;
00033 }

ACE_INLINE TAO_PICurrent_Impl * TAO_PICurrent_Impl::pi_peer void   
 

Get the PICurrent peer associated with this PICurrent implementation.

Definition at line 24 of file PICurrent.inl.

References pi_peer_.

Referenced by copy, TAO_PICurrent::set_slot, TAO_ClientRequestInfo_i::setup_picurrent, TAO_PICurrent_Guard::~TAO_PICurrent_Guard, and ~TAO_PICurrent_Impl.

00025 {
00026   return this->pi_peer_;
00027 }

void TAO_PICurrent_Impl::set_slot PortableInterceptor::SlotId    id,
const CORBA::Any &data    ACE_ENV_ARG_DECL
throw (CORBA::SystemException, PortableInterceptor::InvalidSlot)
 

Set information in the slot table at the given SlotId.

Definition at line 167 of file PICurrent.cpp.

References ACE_ENV_ARG_DECL, ACE_THROW, CORBA::Any, and ACE_Array_Base< CORBA::Any >::size.

Referenced by TAO_PICurrent::set_slot.

00172 {
00173   // No need to check validity of SlotId.  It is validated before this
00174   // method is invoked.
00175 
00176   // Copy the contents of the logically copied slot table before
00177   // modifying our own slot table.
00178   if (this->lc_slot_table_ != 0)
00179     {
00180       // Deep copy
00181 
00182       const Table &table = *this->lc_slot_table_;
00183 
00184       size_t new_size = table.size ();
00185       if (this->slot_table_.size (id >= new_size ? id + 1 : new_size) != 0)
00186         ACE_THROW (CORBA::INTERNAL ());
00187 
00188       // Note that the number of elements to copy is bounded by the
00189       // size of the source array, not the destination array.
00190       for (size_t i = 0; i < new_size; ++i)
00191         {
00192           if (i == id)
00193             continue;  // Avoid copying data twice.
00194 
00195           this->slot_table_[i] = table[i];
00196         }
00197 
00198       // Break all ties with the logically copied slot table.
00199       this->lc_slot_table_ = 0;
00200     }
00201 
00202   // If the slot table array isn't large enough, then increase its
00203   // size.  We're guaranteed not to exceed the number of allocated
00204   // slots for the reason stated above.
00205   if (id >= this->slot_table_.size ()
00206       && this->slot_table_.size (id + 1) != 0)
00207     ACE_THROW (CORBA::INTERNAL ());
00208 
00209   this->slot_table_[id] = CORBA::Any (data);
00210 
00211   // Mark the table as being modified.
00212   this->dirty_ = 1;
00213 }

ACE_INLINE TAO_PICurrent_Impl::Table & TAO_PICurrent_Impl::slot_table void   
 

Return a reference to the underlying slot table.

Definition at line 36 of file PICurrent.inl.

References lc_slot_table_, and slot_table_.

Referenced by copy.

00037 {
00038   return this->lc_slot_table_ == 0 ? this->slot_table_ : *this->lc_slot_table_;
00039 }


Member Data Documentation

CORBA::Boolean TAO_PICurrent_Impl::dirty_ [private]
 

Flag that specifies if the underlying slot table has been modified since last copy.

Note:
This flag is only used when copying between a request scope current and a thread scope current.

Definition at line 239 of file PICurrent.h.

Referenced by copy, and dirty.

Table* TAO_PICurrent_Impl::lc_slot_table_ [private]
 

Table that was logically copied from a PICurrent in another scope, i.e. either the request scope or the thread scope.

Definition at line 231 of file PICurrent.h.

Referenced by copy, and slot_table.

TAO_PICurrent_Impl* TAO_PICurrent_Impl::pi_peer_ [private]
 

The PICurrent implementation with which this implementation's slot table interacts.

Definition at line 224 of file PICurrent.h.

Referenced by copy, pi_peer, and ~TAO_PICurrent_Impl.

Table TAO_PICurrent_Impl::slot_table_ [private]
 

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

Definition at line 227 of file PICurrent.h.

Referenced by copy, and slot_table.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 15:33:28 2003 for TAO by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002