00001 // -*- C++ -*- 00002 00003 // =================================================================== 00004 /** 00005 * @file PICurrent_Impl.h 00006 * 00007 * $Id: PICurrent_Impl.h 85371 2009-05-18 13:39:38Z sma $ 00008 * 00009 * @author Ossama Othman <ossama@dre.vanderbilt.edu> 00010 */ 00011 // =================================================================== 00012 00013 #ifndef TAO_PI_CURRENT_IMPL_H 00014 #define TAO_PI_CURRENT_IMPL_H 00015 00016 #include /**/ "ace/pre.h" 00017 00018 #include "tao/PI/pi_export.h" 00019 00020 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00021 # pragma once 00022 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00023 00024 #include "tao/orbconf.h" 00025 00026 #if TAO_HAS_INTERCEPTORS == 1 00027 00028 #include "tao/PI/PI_includeC.h" 00029 #include "tao/AnyTypeCode/Any.h" 00030 #include "ace/Array_Base.h" 00031 00032 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00033 00034 /// Forward declarations. 00035 class TAO_ORB_Core; 00036 00037 namespace TAO 00038 { 00039 /** 00040 * @class PICurrent_Impl 00041 * 00042 * @brief Implementation of the PortableInterceptor::Current 00043 * interface. 00044 * 00045 * This class implements both the "request scope current" and the 00046 * "thread scope current" objects as required by Portable 00047 * Interceptors. 00048 */ 00049 class TAO_PI_Export PICurrent_Impl 00050 { 00051 public: 00052 /// Constructor. 00053 PICurrent_Impl (TAO_ORB_Core *orb_core= 0, 00054 size_t tss_slot= 0, 00055 PICurrent_Impl *pop= 0); 00056 /// Destructor. 00057 ~PICurrent_Impl (void); 00058 00059 /// Retrieve information stored in the slot table at the given 00060 /// SlotId. 00061 CORBA::Any *get_slot (PortableInterceptor::SlotId identifier); 00062 00063 /// Set information in the slot table at the given SlotId. 00064 void set_slot (PortableInterceptor::SlotId identifier, 00065 const CORBA::Any & data); 00066 00067 /// Logically/Lazy (shallow) copy the given object's slot table. 00068 void take_lazy_copy (PICurrent_Impl *p); 00069 00070 /// Push a new PICurrent_Impl on stack 00071 void push (void); 00072 00073 /// Pop old PICurrent_Impl from stack 00074 void pop (void); 00075 00076 private: 00077 /// Force this object to convert from a logical (referenced) 00078 /// copy, to a physical (or deep, actual) copy. 00079 void convert_from_lazy_to_real_copy (); 00080 00081 /// Set the callback PICurrent_Impl object that will be notified 00082 /// of this object's impending destruction or change. 00083 /// Set to 0 to clear. (NOTE Only handles a SINGLE object at 00084 /// at time, does NOT warn previous callback that this has 00085 /// been changed.) 00086 void set_callback_for_impending_change (PICurrent_Impl *p); 00087 00088 /// Typedef for the underyling "slot table." 00089 typedef ACE_Array_Base<CORBA::Any> Table; 00090 00091 /// Return a reference to the slot table currently associated 00092 /// with this PICurrent_Impl object. 00093 /** 00094 * @return Logically copied slot table if available, otherwise 00095 * underlying slot table. 00096 */ 00097 Table & current_slot_table (); 00098 00099 /// Prevent copying through the copy constructor and the assignment 00100 /// operator. 00101 //@{ 00102 PICurrent_Impl (const PICurrent_Impl &); 00103 void operator= (const PICurrent_Impl &); 00104 //@} 00105 00106 private: 00107 /// Allow for stack of PICurrent_Impl as required. 00108 TAO_ORB_Core *orb_core_; 00109 size_t tss_slot_; 00110 PICurrent_Impl *pop_; 00111 PICurrent_Impl *push_; 00112 00113 /// Array of CORBA::Anys that is the underlying "slot table." 00114 Table slot_table_; 00115 00116 /// Access to logical copy from a PICurrent_Impl in another 00117 /// scope, i.e. either the request scope or the thread scope. 00118 PICurrent_Impl *lazy_copy_; 00119 00120 /// PICurrent_Impl object that will be notified of this object's 00121 /// impending destruction or change to its slot_table_. This is 00122 /// the PICurrent_Impl that has access to our slot_table_ via its 00123 /// lazy_copy_ pointer. As necessary this allows that object's 00124 /// convert_from_lazy_to_real_copy() to be called. 00125 PICurrent_Impl *impending_change_callback_; 00126 }; 00127 } 00128 00129 TAO_END_VERSIONED_NAMESPACE_DECL 00130 00131 #if defined (__ACE_INLINE__) 00132 # include "tao/PI/PICurrent_Impl.inl" 00133 #endif /* __ACE_INLINE__ */ 00134 00135 #endif /* TAO_HAS_INTERCEPTORS == 1 */ 00136 00137 #include /**/ "ace/post.h" 00138 00139 #endif /* TAO_PI_CURRENT_IMPL_H */