00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file Cache_Entries_T.h 00006 * 00007 * $Id: Cache_Entries_T.h 85436 2009-05-25 21:57:28Z coryan $ 00008 * 00009 * 00010 * @author Bala Natarajan <bala@cs.wustl.edu> 00011 */ 00012 //============================================================================= 00013 00014 #ifndef TAO_CACHE_ENTRIES_T_H 00015 #define TAO_CACHE_ENTRIES_T_H 00016 00017 #include /**/ "ace/pre.h" 00018 00019 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00020 # pragma once 00021 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00022 00023 #include "tao/Basic_Types.h" 00024 00025 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00026 00027 #ifdef index 00028 # undef index 00029 #endif /* index */ 00030 00031 namespace TAO 00032 { 00033 /// States of a recyclable object. 00034 /// @todo: see discussion in bugzilla 3024 00035 enum Cache_Entries_State 00036 { 00037 /// Idle and can be purged. 00038 ENTRY_IDLE_AND_PURGABLE, 00039 00040 /// Can be purged, but is not idle (mostly for debugging). 00041 ENTRY_PURGABLE_BUT_NOT_IDLE, 00042 00043 /// Busy (i.e., cannot be recycled or purged). 00044 ENTRY_BUSY, 00045 00046 /// Closed. 00047 ENTRY_CLOSED, 00048 00049 /// Connection in process, but not complete 00050 ENTRY_CONNECTING, 00051 00052 /// Unknown state. 00053 ENTRY_UNKNOWN 00054 }; 00055 00056 /** 00057 * @brief Helper class for TAO_Transport_Cache_Manager 00058 * 00059 * Helper class that wraps the <value> part of the Map or 00060 * table holding the Transport state.: unifies data items, so 00061 * they can be stored together as a <value> for a <key> in a 00062 * table holding the state of the Transport Cache. 00063 */ 00064 template <typename TRANSPORT_TYPE> 00065 class Cache_IntId_T 00066 { 00067 public: 00068 typedef TRANSPORT_TYPE transport_type; 00069 00070 /// Constructor. 00071 Cache_IntId_T (void); 00072 00073 /// Constructor. 00074 Cache_IntId_T (transport_type *transport); 00075 00076 /// Copy constructor. 00077 Cache_IntId_T (const Cache_IntId_T & rhs); 00078 00079 /// Destructor. 00080 ~Cache_IntId_T (void); 00081 00082 /// Assignment operator (does copy memory). 00083 Cache_IntId_T& operator= (const Cache_IntId_T &rhs); 00084 00085 /// Equality comparison operator (must match both id_ and kind_). 00086 bool operator== (const Cache_IntId_T &rhs) const; 00087 00088 /// Inequality comparison operator. 00089 bool operator!= (const Cache_IntId_T &rhs) const; 00090 00091 /// Return the underlying transport 00092 transport_type *transport (void); 00093 00094 /// Return the underlying transport 00095 const transport_type *transport (void) const; 00096 00097 /// Set recycle_state. 00098 void recycle_state (Cache_Entries_State new_state); 00099 00100 /// Get recycle_state. 00101 Cache_Entries_State recycle_state (void) const; 00102 00103 /// Relinquish ownership of the TAO_Transport object associated with 00104 /// this Cache_IntId_T. 00105 /** 00106 * @note This method should go away once the 00107 * Transport_Cache_Map_Manager is improved so that it returns 00108 * TAO_Transport objects when performing a find() operation. 00109 * This method really only exists to get around inadequacies 00110 * in the Transport_Cache_Map_Manager interface. 00111 */ 00112 transport_type *relinquish_transport (void); 00113 00114 /// Get the connected flag 00115 bool is_connected (void) const; 00116 00117 /// Set the connected flag 00118 void is_connected (bool connected); 00119 00120 static const char *state_name (Cache_Entries_State st); 00121 00122 private: 00123 /// The transport that needs to be cached. 00124 transport_type *transport_; 00125 00126 /// The state of the handle 00127 Cache_Entries_State recycle_state_; 00128 00129 /// This is an analog for the transport::is_connected(), which is 00130 /// guarded by a mutex. 00131 bool is_connected_; 00132 }; 00133 00134 00135 /** 00136 * @class Cache_ExtId_T 00137 * 00138 * @brief Helper class for TAO_Transport_Cache_Manager: unifies 00139 * several data items, so they can be stored together as a 00140 * @c value for a @c key in a hash table holding the state of the 00141 * Transport Cache. 00142 */ 00143 template <typename TRANSPORT_DESCRIPTOR_TYPE> 00144 class Cache_ExtId_T 00145 { 00146 public: 00147 typedef TRANSPORT_DESCRIPTOR_TYPE transport_descriptor_type; 00148 00149 /// Constructor. 00150 Cache_ExtId_T (void); 00151 00152 /// Constructor. 00153 explicit Cache_ExtId_T (transport_descriptor_type *prop); 00154 00155 /// Copy constructor. 00156 Cache_ExtId_T (const Cache_ExtId_T & rhs); 00157 00158 /// Destructor. 00159 ~Cache_ExtId_T (void); 00160 00161 // = Assignment and comparison operators. 00162 /// Assignment operator (does copy memory). 00163 Cache_ExtId_T& operator= (const Cache_ExtId_T &rhs); 00164 00165 /// Equality comparison operator (must match both id_ and kind_). 00166 bool operator== (const Cache_ExtId_T &rhs) const; 00167 00168 /// Inequality comparison operator. 00169 bool operator!= (const Cache_ExtId_T &rhs) const; 00170 00171 /// hash function is required in order for this class to be usable by 00172 /// ACE_Hash_Map_Manager_Ex. 00173 u_long hash (void) const; 00174 00175 /// Make a deep copy of the underlying pointer 00176 void duplicate (void); 00177 00178 /// Return the index value 00179 CORBA::ULong index (void) const; 00180 00181 /// Set the index value. This calls should not be used by any users 00182 /// but for the TAO_Transport_Cache_Manager class. 00183 void index (CORBA::ULong index); 00184 00185 /// Increment the index value 00186 void incr_index (void); 00187 00188 // = Accessors 00189 /// Get the underlying the property pointer 00190 transport_descriptor_type *property (void) const; 00191 00192 private: 00193 /// A property object that we represent. 00194 transport_descriptor_type *transport_property_; 00195 00196 /// Do we need to delete transport_property? 00197 CORBA::Boolean is_delete_; 00198 00199 /** 00200 * This is a supplementary index. Would be set to zero by 00201 * default. Would be altered by the Transport_Cache of TAO. Please 00202 * see the documentation of TAO_Transport_Cache_Manager for 00203 * details. 00204 */ 00205 CORBA::ULong index_; 00206 }; 00207 } 00208 00209 TAO_END_VERSIONED_NAMESPACE_DECL 00210 00211 #if defined (__ACE_INLINE__) 00212 # include "tao/Cache_Entries_T.inl" 00213 #endif /* __ACE_INLINE__ */ 00214 00215 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE) 00216 #include "tao/Cache_Entries_T.cpp" 00217 #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ 00218 00219 #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) 00220 #pragma implementation ("tao/Cache_Entries_T.cpp") 00221 #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ 00222 00223 #include /**/ "ace/post.h" 00224 00225 #endif /* TAO_CACHE_ENTRIES_T_H */