3 //=============================================================================
5 * @file Caching_Utility_T.h
7 * @author Kirthika Parameswaran <kirthika@cs.wustl.edu>
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)
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
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
46 typedef ACE_Cleanup_Strategy
<KEY
, VALUE
, CONTAINER
> CLEANUP_STRATEGY
;
49 ACE_Pair_Caching_Utility (ACE_Cleanup_Strategy
<KEY
, VALUE
, CONTAINER
> *cleanup_strategy
= 0,
50 bool delete_cleanup_strategy
= false);
53 ~ACE_Pair_Caching_Utility (void);
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
);
63 /// Find the entry with minimum caching attributes.
64 void minimum (CONTAINER
&container
,
66 VALUE
*&value_to_remove
);
68 /// The cleanup strategy which can be used to destroy the entries of
70 CLEANUP_STRATEGY
*cleanup_strategy_
;
72 /// Whether the cleanup_strategy should be destroyed or not.
73 bool delete_cleanup_strategy_
;
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
94 typedef ACE_Recyclable_Handler_Cleanup_Strategy
<KEY
, VALUE
, CONTAINER
> CLEANUP_STRATEGY
;
95 typedef ACE_Cleanup_Strategy
<KEY
, VALUE
, CONTAINER
> CLEANUP_STRATEGY_BASE
;
98 ACE_Recyclable_Handler_Caching_Utility (ACE_Cleanup_Strategy
<KEY
, VALUE
, CONTAINER
> *cleanup_strategy
= 0,
99 bool delete_cleanup_strategy
= false);
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
109 int clear_cache (CONTAINER
&container
,
110 double purge_percent
);
114 /// Find the entry with minimum caching attributes.
115 void minimum (CONTAINER
&container
,
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
141 template <class KEY
, class VALUE
, class CONTAINER
, class ITERATOR
, class ATTRIBUTES
>
142 class ACE_Refcounted_Recyclable_Handler_Caching_Utility
: private ACE_Copy_Disabled
145 typedef ACE_Refcounted_Recyclable_Handler_Cleanup_Strategy
<KEY
, VALUE
, CONTAINER
> CLEANUP_STRATEGY
;
146 typedef ACE_Cleanup_Strategy
<KEY
, VALUE
, CONTAINER
> CLEANUP_STRATEGY_BASE
;
149 ACE_Refcounted_Recyclable_Handler_Caching_Utility (ACE_Cleanup_Strategy
<KEY
, VALUE
, CONTAINER
> *cleanup_strategy
= 0,
150 bool delete_cleanup_strategy
= false);
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
160 int clear_cache (CONTAINER
&container
,
161 double purge_percent
);
165 /// Find the entry with minimum caching attributes.
166 void minimum (CONTAINER
&container
,
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
202 typedef ACE_Handler_Cleanup_Strategy
<KEY
, VALUE
, CONTAINER
> CLEANUP_STRATEGY
;
203 typedef ACE_Cleanup_Strategy
<KEY
, VALUE
, CONTAINER
> CLEANUP_STRATEGY_BASE
;
206 ACE_Handler_Caching_Utility (ACE_Cleanup_Strategy
<KEY
, VALUE
, CONTAINER
> *cleanup_strategy
= 0,
207 bool delete_cleanup_strategy
= false);
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
217 int clear_cache (CONTAINER
&container
,
218 double purge_percent
);
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
,
230 VALUE
*&value_to_remove
);
232 /// The cleanup strategy which can be used to destroy the entries of
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
256 typedef ACE_Null_Cleanup_Strategy
<KEY
, VALUE
, CONTAINER
> CLEANUP_STRATEGY
;
257 typedef ACE_Cleanup_Strategy
<KEY
, VALUE
, CONTAINER
> CLEANUP_STRATEGY_BASE
;
260 ACE_Null_Caching_Utility (ACE_Cleanup_Strategy
<KEY
, VALUE
, CONTAINER
> *cleanup_strategy
= 0,
261 bool delete_cleanup_strategy
= false);
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
);
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
,
284 VALUE
*&value_to_remove
);
286 /// The cleanup strategy which can be used to destroy the entries of
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 */