00001 // -*- C++ -*- 00002 00003 // =================================================================== 00004 /** 00005 * @file PICurrent.h 00006 * 00007 * $Id: PICurrent.h 81429 2008-04-24 18:49:54Z johnnyw $ 00008 * 00009 * @author Ossama Othman <ossama@dre.vanderbilt.edu> 00010 */ 00011 // =================================================================== 00012 00013 #ifndef TAO_PI_CURRENT_H 00014 #define TAO_PI_CURRENT_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 00030 #include "tao/LocalObject.h" 00031 #include "ace/Array_Base.h" 00032 00033 #if defined(_MSC_VER) 00034 # pragma warning(push) 00035 # pragma warning(disable:4250) 00036 #endif /* _MSC_VER */ 00037 00038 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00039 00040 /// Forward declarations. 00041 class TAO_ORB_Core; 00042 00043 namespace TAO 00044 { 00045 class PICurrent_Impl; 00046 00047 /** 00048 * @class PICurrent 00049 * 00050 * @brief Implementation of the PortableInterceptor::Current 00051 * interface. 00052 * 00053 * PortableInterceptor::Current is useful for passing data between 00054 * request interceptors, in addition to passing data from an 00055 * interceptor to the calling thread. 00056 */ 00057 class TAO_PI_Export PICurrent 00058 : public virtual PortableInterceptor::Current, 00059 public virtual ::CORBA::LocalObject 00060 { 00061 public: 00062 /// Constructor. 00063 PICurrent (TAO_ORB_Core &orb_core); 00064 00065 /** 00066 * @name PortableInterceptor::Current Methods 00067 * 00068 * These are methods exposed by the PortableInterceptor::Current 00069 * interface. 00070 */ 00071 //@{ 00072 /// Retrieve information stored in the slot table at the given 00073 /// SlotId. 00074 virtual CORBA::Any *get_slot (PortableInterceptor::SlotId id); 00075 00076 /// Set information in the slot table at the given SlotId. 00077 virtual void set_slot (PortableInterceptor::SlotId identifier, 00078 const CORBA::Any & data); 00079 //@} 00080 00081 virtual CORBA::ORB_ptr _get_orb (void); 00082 00083 /// Number of slots allocated in the slot table. 00084 PortableInterceptor::SlotId slot_count (void) const; 00085 00086 /// Retrieve the PICurrent implementation from TSS, i.e. the thread 00087 /// scope current (TSC). 00088 PICurrent_Impl * tsc (void); 00089 00090 /// Verify the validity of the given SlotId. 00091 void check_validity (const PortableInterceptor::SlotId &identifier); 00092 00093 /// Initialize the PICurrent object. 00094 void initialize (PortableInterceptor::SlotId sc); 00095 00096 protected: 00097 /// Destructor 00098 /** 00099 * Protected destructor to enforce the fact this class is reference 00100 * counted, and should not be destroyed using delete() by anything 00101 * other than the reference counting mechanism. 00102 */ 00103 virtual ~PICurrent (void); 00104 00105 private: 00106 /// Prevent copying through the copy constructor and the assignment 00107 /// operator. 00108 //@{ 00109 PICurrent (const PICurrent &); 00110 void operator= (const PICurrent &); 00111 //@} 00112 00113 private: 00114 /// Reference to the orb core. 00115 TAO_ORB_Core &orb_core_; 00116 00117 /// TSS slot assigned to PICurrent_Impl objects in the OrbCore. 00118 /// Allocated by the orb_core_.add_tss_cleanup_func() when our 00119 /// initialize() method is called. 00120 size_t tss_slot_; 00121 00122 /// The number of allocated PICurrent slots end user wants. (0 is 00123 /// uninitialized or PICurrent is not used as no data is to be stored). 00124 PortableInterceptor::SlotId slot_count_; 00125 }; 00126 } 00127 00128 TAO_END_VERSIONED_NAMESPACE_DECL 00129 00130 #if defined (__ACE_INLINE__) 00131 # include "tao/PI/PICurrent.inl" 00132 #endif /* __ACE_INLINE__ */ 00133 00134 #if defined(_MSC_VER) 00135 #pragma warning(pop) 00136 #endif /* _MSC_VER */ 00137 00138 #endif /* TAO_HAS_INTERCEPTORS == 1 */ 00139 00140 #include /**/ "ace/post.h" 00141 00142 #endif /* TAO_PI_CURRENT_H */