Updated logging to include the class/method so that it is more obvious where these...
[ACE_TAO.git] / TAO / tao / Cache_Entries_T.h
blobed391738a3800b059dab4ade65d320c4eeedbd7e
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file Cache_Entries_T.h
7 * @author Bala Natarajan <bala@cs.wustl.edu>
8 */
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)
17 # pragma once
18 #endif /* ACE_LACKS_PRAGMA_ONCE */
20 #include "tao/Basic_Types.h"
22 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
24 #ifdef index
25 # undef index
26 #endif /* index */
28 namespace TAO
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).
41 ENTRY_BUSY,
43 /// Closed.
44 ENTRY_CLOSED,
46 /// Connection in process, but not complete
47 ENTRY_CONNECTING,
49 /// Unknown state.
50 ENTRY_UNKNOWN
53 /**
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>
62 class Cache_IntId_T
64 public:
65 typedef TRANSPORT_TYPE transport_type;
67 /// Constructor.
68 Cache_IntId_T ();
70 /// Constructor.
71 Cache_IntId_T (transport_type *transport);
73 /// Copy constructor.
74 Cache_IntId_T (const Cache_IntId_T & rhs);
76 /// Destructor.
77 ~Cache_IntId_T ();
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);
119 private:
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.
128 bool is_connected_;
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
138 * Transport Cache.
140 template <typename TRANSPORT_DESCRIPTOR_TYPE>
141 class Cache_ExtId_T
143 public:
144 typedef TRANSPORT_DESCRIPTOR_TYPE transport_descriptor_type;
146 /// Constructor.
147 Cache_ExtId_T ();
149 /// Constructor.
150 explicit Cache_ExtId_T (transport_descriptor_type *prop);
152 /// Copy constructor.
153 Cache_ExtId_T (const Cache_ExtId_T & rhs);
155 /// Destructor.
156 ~Cache_ExtId_T ();
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
173 void duplicate ();
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
183 void incr_index ();
185 // = Accessors
186 /// Get the underlying the property pointer
187 transport_descriptor_type *property () const;
189 private:
190 /// A property object that we represent.
191 transport_descriptor_type *transport_property_;
193 /// Do we need to delete transport_property?
194 bool is_delete_;
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
200 * details.
202 CORBA::ULong index_;
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 */