3 //=============================================================================
5 * @file Cache_Entries_T.h
7 * @author Bala Natarajan <bala@cs.wustl.edu>
9 //=============================================================================
11 #ifndef TAO_CACHE_ENTRIES_T_H
12 #define TAO_CACHE_ENTRIES_T_H
14 #include /**/ "ace/pre.h"
16 #if !defined (ACE_LACKS_PRAGMA_ONCE)
18 #endif /* ACE_LACKS_PRAGMA_ONCE */
20 #include "tao/Basic_Types.h"
22 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
30 /// States of a recyclable object.
31 /// @todo: see discussion in bugzilla 3024
32 enum Cache_Entries_State
34 /// Idle and can be purged.
35 ENTRY_IDLE_AND_PURGABLE
,
37 /// Can be purged, but is not idle (mostly for debugging).
38 ENTRY_PURGABLE_BUT_NOT_IDLE
,
40 /// Busy (i.e., cannot be recycled or purged).
46 /// Connection in process, but not complete
54 * @brief Helper class for TAO_Transport_Cache_Manager
56 * Helper class that wraps the <value> part of the Map or
57 * table holding the Transport state.: unifies data items, so
58 * they can be stored together as a <value> for a <key> in a
59 * table holding the state of the Transport Cache.
61 template <typename TRANSPORT_TYPE
>
65 typedef TRANSPORT_TYPE transport_type
;
71 Cache_IntId_T (transport_type
*transport
);
74 Cache_IntId_T (const Cache_IntId_T
& rhs
);
79 /// Assignment operator (does copy memory).
80 Cache_IntId_T
& operator= (const Cache_IntId_T
&rhs
);
82 /// Equality comparison operator (must match both id_ and kind_).
83 bool operator== (const Cache_IntId_T
&rhs
) const;
85 /// Inequality comparison operator.
86 bool operator!= (const Cache_IntId_T
&rhs
) const;
88 /// Return the underlying transport
89 transport_type
*transport ();
91 /// Return the underlying transport
92 const transport_type
*transport () const;
94 /// Set recycle_state.
95 void recycle_state (Cache_Entries_State new_state
);
97 /// Get recycle_state.
98 Cache_Entries_State
recycle_state () const;
100 /// Relinquish ownership of the TAO_Transport object associated with
101 /// this Cache_IntId_T.
103 * @note This method should go away once the
104 * Transport_Cache_Map_Manager is improved so that it returns
105 * TAO_Transport objects when performing a find() operation.
106 * This method really only exists to get around inadequacies
107 * in the Transport_Cache_Map_Manager interface.
109 transport_type
*relinquish_transport ();
111 /// Get the connected flag
112 bool is_connected () const;
114 /// Set the connected flag
115 void is_connected (bool connected
);
117 static const char *state_name (Cache_Entries_State st
);
120 /// The transport that needs to be cached.
121 transport_type
*transport_
;
123 /// The state of the handle
124 Cache_Entries_State recycle_state_
;
126 /// This is an analog for the transport::is_connected(), which is
127 /// guarded by a mutex.
133 * @class Cache_ExtId_T
135 * @brief Helper class for TAO_Transport_Cache_Manager: unifies
136 * several data items, so they can be stored together as a
137 * @c value for a @c key in a hash table holding the state of the
140 template <typename TRANSPORT_DESCRIPTOR_TYPE
>
144 typedef TRANSPORT_DESCRIPTOR_TYPE transport_descriptor_type
;
150 explicit Cache_ExtId_T (transport_descriptor_type
*prop
);
152 /// Copy constructor.
153 Cache_ExtId_T (const Cache_ExtId_T
& rhs
);
158 // = Assignment and comparison operators.
159 /// Assignment operator (does copy memory).
160 Cache_ExtId_T
& operator= (const Cache_ExtId_T
&rhs
);
162 /// Equality comparison operator (must match both id_ and kind_).
163 bool operator== (const Cache_ExtId_T
&rhs
) const;
165 /// Inequality comparison operator.
166 bool operator!= (const Cache_ExtId_T
&rhs
) const;
168 /// hash function is required in order for this class to be usable by
169 /// ACE_Hash_Map_Manager_Ex.
170 u_long
hash () const;
172 /// Make a deep copy of the underlying pointer
175 /// Return the index value
176 CORBA::ULong
index () const;
178 /// Set the index value. This calls should not be used by any users
179 /// but for the TAO_Transport_Cache_Manager class.
180 void index (CORBA::ULong index
);
182 /// Increment the index value
186 /// Get the underlying the property pointer
187 transport_descriptor_type
*property () const;
190 /// A property object that we represent.
191 transport_descriptor_type
*transport_property_
;
193 /// Do we need to delete transport_property?
197 * This is a supplementary index. Would be set to zero by
198 * default. Would be altered by the Transport_Cache of TAO. Please
199 * see the documentation of TAO_Transport_Cache_Manager for
206 TAO_END_VERSIONED_NAMESPACE_DECL
208 #if defined (__ACE_INLINE__)
209 # include "tao/Cache_Entries_T.inl"
210 #endif /* __ACE_INLINE__ */
212 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
213 #include "tao/Cache_Entries_T.cpp"
214 #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
216 #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
217 #pragma implementation ("tao/Cache_Entries_T.cpp")
218 #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
220 #include /**/ "ace/post.h"
222 #endif /* TAO_CACHE_ENTRIES_T_H */