Revert to Current Include Style
[ACE_TAO.git] / ACE / ace / Caching_Utility_T.h
blobac046b974626658a9bb87e22d96b48f5bf6bd134
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file Caching_Utility_T.h
7 * @author Kirthika Parameswaran <kirthika@cs.wustl.edu>
8 */
9 //=============================================================================
11 #ifndef ACE_CACHING_UTILITY_H
12 #define ACE_CACHING_UTILITY_H
14 #include /**/ "ace/pre.h"
16 #include /**/ "ace/config-all.h"
18 #if !defined (ACE_LACKS_PRAGMA_ONCE)
19 # pragma once
20 #endif /* ACE_LACKS_PRAGMA_ONCE */
22 #include "ace/Global_Macros.h"
23 #include "ace/Cleanup_Strategies_T.h"
24 #include "ace/Copy_Disabled.h"
26 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
28 /**
29 * @class ACE_Pair_Caching_Utility
31 * @brief Defines a helper class for the Caching Strategies.
33 * This class defines the methods commonly used by the different
34 * caching strategies. For instance: clear_cache() method which
35 * decides and purges the entry from the container. @note This
36 * class helps in the caching_strategies using a container
37 * containing entries of <KEY, ACE_Pair<VALUE, attributes>>
38 * kind. The attributes helps in deciding the entries to be
39 * purged. The Cleanup_Strategy is the callback class to which the
40 * entries to be cleaned up will be delegated.
42 template <class KEY, class VALUE, class CONTAINER, class ITERATOR, class ATTRIBUTES>
43 class ACE_Pair_Caching_Utility : private ACE_Copy_Disabled
45 public:
46 typedef ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> CLEANUP_STRATEGY;
48 /// Constructor.
49 ACE_Pair_Caching_Utility (ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_strategy = 0,
50 bool delete_cleanup_strategy = false);
52 /// Destructor.
53 ~ACE_Pair_Caching_Utility (void);
55 /**
56 * Purge entries from the @a container. The Cleanup_Strategy will do the
57 * actual job of cleanup once the entries to be cleaned up are decided.
59 int clear_cache (CONTAINER &container, double purge_percent);
61 protected:
63 /// Find the entry with minimum caching attributes.
64 void minimum (CONTAINER &container,
65 KEY *&key_to_remove,
66 VALUE *&value_to_remove);
68 /// The cleanup strategy which can be used to destroy the entries of
69 /// the container.
70 CLEANUP_STRATEGY *cleanup_strategy_;
72 /// Whether the cleanup_strategy should be destroyed or not.
73 bool delete_cleanup_strategy_;
76 /**
77 * @class ACE_Recyclable_Handler_Caching_Utility
79 * @brief Defines a helper class for the Caching Strategies.
81 * This class defines the methods commonly used by the different
82 * caching strategies. For instance: clear_cache() method which
83 * decides and purges the entry from the container. @note This
84 * class helps in the caching_strategies using a container
85 * containing entries of <KEY, Svc_Handler> kind. The attributes
86 * helps in deciding the entries to be purged. The
87 * Cleanup_Strategy is the callback class to which the entries to
88 * be cleaned up will be delegated.
90 template <class KEY, class VALUE, class CONTAINER, class ITERATOR, class ATTRIBUTES>
91 class ACE_Recyclable_Handler_Caching_Utility : private ACE_Copy_Disabled
93 public:
94 typedef ACE_Recyclable_Handler_Cleanup_Strategy<KEY, VALUE, CONTAINER> CLEANUP_STRATEGY;
95 typedef ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> CLEANUP_STRATEGY_BASE;
97 /// Constructor.
98 ACE_Recyclable_Handler_Caching_Utility (ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_strategy = 0,
99 bool delete_cleanup_strategy = false);
101 /// Destructor.
102 ~ACE_Recyclable_Handler_Caching_Utility (void);
105 * Purge entries from the @a container. The Cleanup_Strategy will do
106 * the actual job of cleanup once the entries to be cleaned up are
107 * decided.
109 int clear_cache (CONTAINER &container,
110 double purge_percent);
112 protected:
114 /// Find the entry with minimum caching attributes.
115 void minimum (CONTAINER &container,
116 KEY *&key_to_remove,
117 VALUE *&value_to_remove);
119 /// This is the default Cleanup Strategy for this utility.
120 CLEANUP_STRATEGY_BASE *cleanup_strategy_;
122 /// Whether the cleanup_strategy should be destroyed or not.
123 bool delete_cleanup_strategy_;
127 * @class ACE_Refcounted_Recyclable_Handler_Caching_Utility
129 * @brief Defines a helper class for the Caching Strategies.
131 * This class defines the methods commonly used by the different
132 * caching strategies. For instance: clear_cache () method which
133 * decides and purges the entry from the container. @note This
134 * class helps in the caching_strategies using a container
135 * containing entries of <Refcounted_KEY,
136 * Recyclable_Connection_Handler> kind. The attributes helps in
137 * deciding the entries to be purged. The Cleanup_Strategy is the
138 * callback class to which the entries to be cleaned up will be
139 * delegated.
141 template <class KEY, class VALUE, class CONTAINER, class ITERATOR, class ATTRIBUTES>
142 class ACE_Refcounted_Recyclable_Handler_Caching_Utility : private ACE_Copy_Disabled
144 public:
145 typedef ACE_Refcounted_Recyclable_Handler_Cleanup_Strategy<KEY, VALUE, CONTAINER> CLEANUP_STRATEGY;
146 typedef ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> CLEANUP_STRATEGY_BASE;
148 /// Constructor.
149 ACE_Refcounted_Recyclable_Handler_Caching_Utility (ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_strategy = 0,
150 bool delete_cleanup_strategy = false);
152 /// Destructor.
153 ~ACE_Refcounted_Recyclable_Handler_Caching_Utility (void);
156 * Purge entries from the @a container. The Cleanup_Strategy will do
157 * the actual job of cleanup once the entries to be cleaned up are
158 * decided.
160 int clear_cache (CONTAINER &container,
161 double purge_percent);
163 protected:
165 /// Find the entry with minimum caching attributes.
166 void minimum (CONTAINER &container,
167 KEY *&key_to_remove,
168 VALUE *&value_to_remove);
170 /// This is the default Cleanup Strategy for this utility.
171 CLEANUP_STRATEGY_BASE *cleanup_strategy_;
173 /// Whether the cleanup_strategy should be destroyed or not.
174 bool delete_cleanup_strategy_;
177 * This figure denotes the number of entries are there in the
178 * container which have been marked as closed already but might
179 * not have been unbound from the container.
181 size_t marked_as_closed_entries_;
185 * @class ACE_Handler_Caching_Utility
187 * @brief Defines a helper class for the Caching Strategies.
189 * This class defines the methods commonly used by the different
190 * caching strategies. For instance: clear_cache() method which
191 * decides and purges the entry from the container. @note This
192 * class helps in the caching_strategies using a container
193 * containing entries of <KEY, HANDLER> kind where the HANDLER
194 * contains the caching attributes which help in deciding the
195 * entries to be purged. The Cleanup_Strategy is the callback
196 * class to which the entries to be cleaned up will be delegated.
198 template <class KEY, class VALUE, class CONTAINER, class ITERATOR, class ATTRIBUTES>
199 class ACE_Handler_Caching_Utility : private ACE_Copy_Disabled
201 public:
202 typedef ACE_Handler_Cleanup_Strategy<KEY, VALUE, CONTAINER> CLEANUP_STRATEGY;
203 typedef ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> CLEANUP_STRATEGY_BASE;
205 /// Constructor.
206 ACE_Handler_Caching_Utility (ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_strategy = 0,
207 bool delete_cleanup_strategy = false);
209 /// Destructor.
210 ~ACE_Handler_Caching_Utility (void);
213 * Purge entries from the @a container. The Cleanup_Strategy will do
214 * the actual job of cleanup once the entries to be cleaned up are
215 * decided.
217 int clear_cache (CONTAINER &container,
218 double purge_percent);
220 protected:
223 * Find the entry with minimum caching attributes. This is handler
224 * specific since this utility is to be used very specifically for
225 * handler who have caching_attributes for server side acched
226 * connection management.
228 void minimum (CONTAINER &container,
229 KEY *&key_to_remove,
230 VALUE *&value_to_remove);
232 /// The cleanup strategy which can be used to destroy the entries of
233 /// the container.
234 CLEANUP_STRATEGY_BASE *cleanup_strategy_;
236 /// Whether the cleanup_strategy should be destroyed or not.
237 bool delete_cleanup_strategy_;
241 * @class ACE_Null_Caching_Utility
243 * @brief Defines a dummy helper class for the Caching Strategies.
245 * This class defines the methods commonly used by the different
246 * caching strategies. For instance: clear_cache() method which
247 * decides and purges the entry from the container. @note This
248 * class is be used with the Null_Caching_Strategy. The
249 * Cleanup_Strategy is the callback class to which the entries to
250 * be cleaned up will be delegated.
252 template <class KEY, class VALUE, class CONTAINER, class ITERATOR, class ATTRIBUTES>
253 class ACE_Null_Caching_Utility : private ACE_Copy_Disabled
255 public:
256 typedef ACE_Null_Cleanup_Strategy<KEY, VALUE, CONTAINER> CLEANUP_STRATEGY;
257 typedef ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> CLEANUP_STRATEGY_BASE;
259 /// Constructor.
260 ACE_Null_Caching_Utility (ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_strategy = 0,
261 bool delete_cleanup_strategy = false);
263 /// Destructor.
264 ~ACE_Null_Caching_Utility (void);
267 * Purge entries from the @a container. The Cleanup_Strategy will do
268 * the actual job of cleanup once the entries to be cleaned up are
269 * decided. @note Here it is a no-op.
271 int clear_cache (CONTAINER &container,
272 double purge_percent);
274 protected:
277 * Find the entry with minimum caching attributes. This is handler
278 * specific since this utility is to be used very specifically for
279 * handler who have caching_attributes for server side acched
280 * connection management.@note Here it is a no-op.
282 void minimum (CONTAINER &container,
283 KEY *&key_to_remove,
284 VALUE *&value_to_remove);
286 /// The cleanup strategy which can be used to destroy the entries of
287 /// the container.
288 CLEANUP_STRATEGY_BASE *cleanup_strategy_;
290 /// Whether the cleanup_strategy should be destroyed or not.
291 bool delete_cleanup_strategy_;
294 ACE_END_VERSIONED_NAMESPACE_DECL
296 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
297 #include "ace/Caching_Utility_T.cpp"
298 #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
300 #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
301 #pragma implementation ("Caching_Utility_T.cpp")
302 #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
304 #include /**/ "ace/post.h"
306 #endif /* ACE_CACHING_UTILITY_H */