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