00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file POA_Current_Impl.h 00006 * 00007 * $Id: POA_Current_Impl.h 76898 2007-02-04 18:58:07Z johnnyw $ 00008 * 00009 * @author Irfan Pyarali 00010 */ 00011 //============================================================================= 00012 00013 #ifndef TAO_POA_CURRENT_IMPL_H 00014 #define TAO_POA_CURRENT_IMPL_H 00015 00016 #include /**/ "ace/pre.h" 00017 00018 #include "tao/PortableServer/portableserver_export.h" 00019 00020 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00021 # pragma once 00022 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00023 00024 #include "tao/PortableServer/PS_ForwardC.h" 00025 00026 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00027 00028 #ifndef TAO_POA_OBJECT_ID_BUF_SIZE 00029 #define TAO_POA_OBJECT_ID_BUF_SIZE 512 00030 #endif /* TAO_POA_OBJECT_ID_BUF_SIZE */ 00031 00032 namespace TAO 00033 { 00034 namespace Portable_Server 00035 { 00036 class Non_Servant_Upcall; 00037 class Servant_Upcall; 00038 } 00039 00040 class ObjectKey; 00041 } 00042 00043 class TAO_TSS_Resources; 00044 00045 namespace TAO 00046 { 00047 namespace Portable_Server 00048 { 00049 /** 00050 * @class POA_Current_Impl 00051 * 00052 * @brief Implementation of the PortableServer::Current object. 00053 * 00054 * Objects of this class hold state information regarding the 00055 * current POA invocation. Savvy readers will notice that this 00056 * contains substantially more methods than the POA spec shows; 00057 * they exist because the ORB either (a) needs them or (b) finds 00058 * them useful for implementing a more efficient ORB. 00059 * The intent is that instances of this class are held in 00060 * Thread-Specific Storage so that upcalls can get context 00061 * information regarding their invocation. The POA itself must 00062 * insure that all <set_*> operations are performed in the 00063 * execution thread so that the proper <TAO_POA_Current> pointer 00064 * is obtained from TSS. 00065 */ 00066 class TAO_PortableServer_Export POA_Current_Impl 00067 { 00068 public: 00069 friend class ::TAO_Root_POA; 00070 00071 /// Return pointer to the invoking POA. Raises the 00072 /// <CORBA::NoContext> exception. 00073 PortableServer::POA_ptr get_POA (void); 00074 00075 /** 00076 * Return pointer to the object id through which this was invoked. 00077 * This may be necessary in cases where a <Servant> is serving under 00078 * the guise of multiple object ids. 00079 */ 00080 PortableServer::ObjectId *get_object_id (void); 00081 00082 /** 00083 * Returns a reference to the servant that hosts the object in whose 00084 * context it is called. 00085 */ 00086 PortableServer::Servant get_servant (void); 00087 00088 /** 00089 * This operation returns a locally manufactured reference to the object 00090 * in the context of which it is called. 00091 */ 00092 CORBA::Object_ptr get_reference (void); 00093 00094 /// Set the POA implementation. 00095 void poa (::TAO_Root_POA *); 00096 00097 /// Get the POA implemantation 00098 ::TAO_Root_POA *poa (void) const; 00099 00100 /// ORB Core for this current. 00101 TAO_ORB_Core &orb_core (void) const; 00102 00103 /// Set the object ID. 00104 void object_id (const PortableServer::ObjectId &id); 00105 00106 /// Get the object ID. 00107 const PortableServer::ObjectId &object_id (void) const; 00108 00109 /// Just replace the object id smartly 00110 void replace_object_id (const PortableServer::ObjectId &system_id); 00111 00112 /// Set the object key. 00113 void object_key (const TAO::ObjectKey &key); 00114 00115 /// Get the object key. 00116 const TAO::ObjectKey &object_key (void) const; 00117 00118 /// Set the servant for the current upcall. 00119 void servant (PortableServer::Servant servant); 00120 00121 /// Get the servant for the current upcall. 00122 PortableServer::Servant servant (void) const; 00123 00124 /// Set the priority for the current upcall. 00125 void priority (CORBA::Short priority); 00126 00127 /// Get the priority for the current upcall. 00128 CORBA::Short priority (void) const; 00129 00130 /// Convenience constructor combining construction & initialization. 00131 POA_Current_Impl (void); 00132 00133 /// Return the previous current implementation. 00134 POA_Current_Impl *previous (void) const; 00135 00136 /// Teardown the current for this request. 00137 void teardown (void); 00138 00139 /// Setup the current. 00140 void setup (::TAO_Root_POA *impl, const TAO::ObjectKey &key); 00141 00142 private: 00143 00144 // = Hidden because we don't allow these 00145 POA_Current_Impl (const POA_Current_Impl &); 00146 void operator= (const POA_Current_Impl &); 00147 00148 protected: 00149 /// The POA implementation invoking an upcall 00150 ::TAO_Root_POA *poa_; 00151 00152 /// In order to avoid memory allocations, we will populate 00153 /// the object id with this buffer. 00154 CORBA::Octet object_id_buf_[TAO_POA_OBJECT_ID_BUF_SIZE]; 00155 00156 /** 00157 * The object ID of the current context. This is the user id and 00158 * not the id the goes into the IOR. Note also that unlike the 00159 * <object_key>, this field is stored by value. 00160 */ 00161 PortableServer::ObjectId object_id_; 00162 00163 /// The object key of the current context. 00164 const TAO::ObjectKey *object_key_; 00165 00166 /// The servant for the current upcall. 00167 PortableServer::Servant servant_; 00168 00169 /// The priority for the current upcall. 00170 CORBA::Short priority_; 00171 00172 /// Current previous from <this>. 00173 POA_Current_Impl *previous_current_impl_; 00174 00175 /// Is setup complete? 00176 bool setup_done_; 00177 00178 /// Pointer to tss resources. 00179 TAO_TSS_Resources *tss_resources_; 00180 00181 }; 00182 } 00183 } 00184 00185 TAO_END_VERSIONED_NAMESPACE_DECL 00186 00187 #if defined (__ACE_INLINE__) 00188 # include "tao/PortableServer/POA_Current_Impl.inl" 00189 #endif /* __ACE_INLINE__ */ 00190 00191 #include /**/ "ace/post.h" 00192 00193 #endif /* TAO_POA_CURRENT_IMPL_H */