00001 // -*- C++ -*- 00002 00003 // =================================================================== 00004 /** 00005 * @file PICurrent_Impl.h 00006 * 00007 * $Id: PICurrent_Impl.h 79914 2007-11-01 10:51:19Z johnnyw $ 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 00033 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00034 00035 /// Forward declarations. 00036 class TAO_ORB_Core; 00037 00038 namespace TAO 00039 { 00040 /** 00041 * @class PICurrent_Impl 00042 * 00043 * @brief Implementation of the PortableInterceptor::Current 00044 * interface. 00045 * 00046 * This class implements both the "request scope current" and the 00047 * "thread scope current" objects as required by Portable 00048 * Interceptors. 00049 */ 00050 class TAO_PI_Export PICurrent_Impl 00051 { 00052 public: 00053 /// Constructor. 00054 PICurrent_Impl (void); 00055 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 private: 00071 /// Force this object to convert from a logical (referenced) 00072 /// copy, to a physical (or deep, actual) copy. 00073 void convert_from_lazy_to_real_copy (); 00074 00075 /// Set the callback PICurrent_Impl object that will be notified 00076 /// of this object's impending destruction or change. 00077 /// Set to 0 to clear. (NOTE Only handles a SINGLE object at 00078 /// at time, does NOT warn previous callback that this has 00079 /// been changed.) 00080 void set_callback_for_impending_change (PICurrent_Impl *p); 00081 00082 /// Typedef for the underyling "slot table." 00083 typedef ACE_Array_Base<CORBA::Any> Table; 00084 00085 /// Return a reference to the slot table currently associated 00086 /// with this PICurrent_Impl object. 00087 /** 00088 * @return Logically copied slot table if available, otherwise 00089 * underlying slot table. 00090 */ 00091 Table & current_slot_table (); 00092 00093 /// Prevent copying through the copy constructor and the assignment 00094 /// operator. 00095 //@{ 00096 PICurrent_Impl (const PICurrent_Impl &); 00097 void operator= (const PICurrent_Impl &); 00098 //@} 00099 00100 private: 00101 /// Array of CORBA::Anys that is the underlying "slot table." 00102 Table slot_table_; 00103 00104 /// Access to logical copy from a PICurrent_Impl in another 00105 /// scope, i.e. either the request scope or the thread scope. 00106 PICurrent_Impl *lazy_copy_; 00107 00108 /// PICurrent_Impl object that will be notified of this object's 00109 /// impending destruction or change to its slot_table_. This is 00110 /// the PICurrent_Impl that has access to our slot_table_ via its 00111 /// lazy_copy_ pointer. As necessary this allows that object's 00112 /// convert_from_lazy_to_real_copy() to be called. 00113 PICurrent_Impl *impending_change_callback_; 00114 }; 00115 } 00116 00117 TAO_END_VERSIONED_NAMESPACE_DECL 00118 00119 #if defined (__ACE_INLINE__) 00120 # include "tao/PI/PICurrent_Impl.inl" 00121 #endif /* __ACE_INLINE__ */ 00122 00123 #endif /* TAO_HAS_INTERCEPTORS == 1 */ 00124 00125 #include /**/ "ace/post.h" 00126 00127 #endif /* TAO_PI_CURRENT_IMPL_H */