Caching_Utility_T.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    Caching_Utility_T.h
00006  *
00007  *  Caching_Utility_T.h,v 4.18 2006/01/25 13:05:49 jwillemsen Exp
00008  *
00009  *  @author Kirthika Parameswaran <kirthika@cs.wustl.edu>
00010  */
00011 //=============================================================================
00012 
00013 #ifndef ACE_CACHING_UTILITY_H
00014 #define ACE_CACHING_UTILITY_H
00015 
00016 #include /**/ "ace/pre.h"
00017 
00018 #include "ace/config-all.h"
00019 
00020 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00021 # pragma once
00022 #endif /* ACE_LACKS_PRAGMA_ONCE */
00023 
00024 #include "ace/Global_Macros.h"
00025 #include "ace/Cleanup_Strategies_T.h"
00026 
00027 // For linkers that cant grok long names.
00028 #define ACE_Pair_Caching_Utility APUTIL
00029 
00030 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00031 
00032 /**
00033  * @class ACE_Pair_Caching_Utility
00034  *
00035  * @brief Defines a helper class for the Caching Strategies.
00036  *
00037  * This class defines the methods commonly used by the different
00038  * caching strategies. For instance: <clear_cache> method which
00039  * decides and purges the entry from the container.  @note This
00040  * class helps in the caching_strategies using a container
00041  * containing entries of <KEY, ACE_Pair<VALUE, attributes>>
00042  * kind. The attributes helps in deciding the entries to be
00043  * purged. The Cleanup_Strategy is the callback class to which the
00044  * entries to be cleaned up will be delegated.
00045  */
00046 template <class KEY, class VALUE, class CONTAINER, class ITERATOR, class ATTRIBUTES>
00047 class ACE_Pair_Caching_Utility
00048 {
00049 public:
00050 
00051   typedef ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> CLEANUP_STRATEGY;
00052 
00053   /// Constructor.
00054   ACE_Pair_Caching_Utility (ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_strategy = 0,
00055                             int delete_cleanup_strategy = 0);
00056 
00057   /// Destructor.
00058   ~ACE_Pair_Caching_Utility (void);
00059 
00060   /**
00061    * Purge entries from the <container>. The Cleanup_Strategy will do the actual
00062    * job of cleanup once the entries to be cleaned up are decided.
00063    */
00064   int clear_cache (CONTAINER &container,
00065                    double purge_percent);
00066 
00067 protected:
00068 
00069   /// Find the entry with minimum caching attributes.
00070   void minimum (CONTAINER &container,
00071                 KEY *&key_to_remove,
00072                 VALUE *&value_to_remove);
00073 
00074   /// The cleanup strategy which can be used to destroy the entries of
00075   /// the container.
00076   CLEANUP_STRATEGY *cleanup_strategy_;
00077 
00078   /// Whether the cleanup_strategy should be destroyed or not.
00079   int delete_cleanup_strategy_;
00080 
00081   ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Pair_Caching_Utility<KEY,VALUE,CONTAINER,ITERATOR,ATTRIBUTES> &))
00082   ACE_UNIMPLEMENTED_FUNC (ACE_Pair_Caching_Utility (const ACE_Pair_Caching_Utility<KEY,VALUE,CONTAINER,ITERATOR,ATTRIBUTES> &))
00083 };
00084 
00085 ////////////////////////////////////////////////////////////////////////////////
00086 #define ACE_Recyclable_Handler_Caching_Utility ARHUTIL
00087 
00088 /**
00089  * @class ACE_Recyclable_Handler_Caching_Utility
00090  *
00091  * @brief Defines a helper class for the Caching Strategies.
00092  *
00093  * This class defines the methods commonly used by the different
00094  * caching strategies. For instance: <clear_cache> method which
00095  * decides and purges the entry from the container.  @note This
00096  * class helps in the caching_strategies using a container
00097  * containing entries of <KEY, Svc_Handler> kind. The attributes
00098  * helps in deciding the entries to be purged. The
00099  * Cleanup_Strategy is the callback class to which the entries to
00100  * be cleaned up will be delegated.
00101  */
00102 template <class KEY, class VALUE, class CONTAINER, class ITERATOR, class ATTRIBUTES>
00103 class ACE_Recyclable_Handler_Caching_Utility
00104 {
00105 
00106 public:
00107 
00108   typedef ACE_Recyclable_Handler_Cleanup_Strategy<KEY, VALUE, CONTAINER> CLEANUP_STRATEGY;
00109   typedef ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> CLEANUP_STRATEGY_BASE;
00110 
00111   /// Constructor.
00112   ACE_Recyclable_Handler_Caching_Utility (ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_strategy = 0,
00113                                           int delete_cleanup_strategy = 0);
00114 
00115   /// Destructor.
00116   ~ACE_Recyclable_Handler_Caching_Utility (void);
00117 
00118   /**
00119    * Purge entries from the <container>. The Cleanup_Strategy will do
00120    * the actual job of cleanup once the entries to be cleaned up are
00121    * decided.
00122    */
00123   int clear_cache (CONTAINER &container,
00124                    double purge_percent);
00125 
00126 protected:
00127 
00128   /// Find the entry with minimum caching attributes.
00129   void minimum (CONTAINER &container,
00130                 KEY *&key_to_remove,
00131                 VALUE *&value_to_remove);
00132 
00133   /// This is the default Cleanup Strategy for this utility.
00134   CLEANUP_STRATEGY_BASE *cleanup_strategy_;
00135 
00136   /// Whether the cleanup_strategy should be destroyed or not.
00137   int delete_cleanup_strategy_;
00138 
00139 private:
00140   ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Recyclable_Handler_Caching_Utility<KEY,VALUE,CONTAINER,ITERATOR,ATTRIBUTES> &))
00141   ACE_UNIMPLEMENTED_FUNC (ACE_Recyclable_Handler_Caching_Utility (const ACE_Recyclable_Handler_Caching_Utility<KEY,VALUE,CONTAINER,ITERATOR,ATTRIBUTES> &))
00142 };
00143 
00144 ///////////////////////////////////////////////////////////////////////////
00145 #define ACE_Refcounted_Recyclable_Handler_Caching_Utility ARRHUTIL
00146 
00147 /**
00148  * @class ACE_Refcounted_Recyclable_Handler_Caching_Utility
00149  *
00150  * @brief Defines a helper class for the Caching Strategies.
00151  *
00152  * This class defines the methods commonly used by the different
00153  * caching strategies. For instance: clear_cache () method which
00154  * decides and purges the entry from the container.  @note This
00155  * class helps in the caching_strategies using a container
00156  * containing entries of <Refcounted_KEY,
00157  * Recyclable_Connection_Handler> kind. The attributes helps in
00158  * deciding the entries to be purged. The Cleanup_Strategy is the
00159  * callback class to which the entries to be cleaned up will be
00160  * delegated.
00161  */
00162 template <class KEY, class VALUE, class CONTAINER, class ITERATOR, class ATTRIBUTES>
00163 class ACE_Refcounted_Recyclable_Handler_Caching_Utility
00164 {
00165 
00166 public:
00167 
00168   typedef ACE_Refcounted_Recyclable_Handler_Cleanup_Strategy<KEY, VALUE, CONTAINER> CLEANUP_STRATEGY;
00169   typedef ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> CLEANUP_STRATEGY_BASE;
00170 
00171   /// Constructor.
00172   ACE_Refcounted_Recyclable_Handler_Caching_Utility (ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_strategy = 0,
00173                                                      int delete_cleanup_strategy = 0);
00174 
00175   /// Destructor.
00176   ~ACE_Refcounted_Recyclable_Handler_Caching_Utility (void);
00177 
00178   /**
00179    * Purge entries from the <container>. The Cleanup_Strategy will do
00180    * the actual job of cleanup once the entries to be cleaned up are
00181    * decided.
00182    */
00183   int clear_cache (CONTAINER &container,
00184                    double purge_percent);
00185 
00186 protected:
00187 
00188   /// Find the entry with minimum caching attributes.
00189   void minimum (CONTAINER &container,
00190                 KEY *&key_to_remove,
00191                 VALUE *&value_to_remove);
00192 
00193   /// This is the default Cleanup Strategy for this utility.
00194   CLEANUP_STRATEGY_BASE *cleanup_strategy_;
00195 
00196   /// Whether the cleanup_strategy should be destroyed or not.
00197   int delete_cleanup_strategy_;
00198 
00199   /**
00200    * This figure denotes the number of entries are there in the
00201    * container which have been marked as closed already but might
00202    * not have been unbound from the container.
00203    */
00204   size_t marked_as_closed_entries_;
00205 
00206 private:
00207   ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Refcounted_Recyclable_Handler_Caching_Utility<KEY,VALUE,CONTAINER,ITERATOR,ATTRIBUTES> &))
00208   ACE_UNIMPLEMENTED_FUNC (ACE_Refcounted_Recyclable_Handler_Caching_Utility (const ACE_Refcounted_Recyclable_Handler_Caching_Utility<KEY,VALUE,CONTAINER,ITERATOR,ATTRIBUTES> &))
00209 };
00210 
00211 ////////////////////////////////////////////////////////////////////////////////////////
00212 
00213 /**
00214  * @class ACE_Handler_Caching_Utility
00215  *
00216  * @brief Defines a helper class for the Caching Strategies.
00217  *
00218  * This class defines the methods commonly used by the different
00219  * caching strategies. For instance: <clear_cache> method which
00220  * decides and purges the entry from the container.  @note This
00221  * class helps in the caching_strategies using a container
00222  * containing entries of <KEY, HANDLER> kind where the HANDLER
00223  * contains the caching attributes which help in deciding the
00224  * entries to be purged. The Cleanup_Strategy is the callback
00225  * class to which the entries to be cleaned up will be delegated.
00226  */
00227 template <class KEY, class VALUE, class CONTAINER, class ITERATOR, class ATTRIBUTES>
00228 class ACE_Handler_Caching_Utility
00229 {
00230 public:
00231 
00232   typedef ACE_Handler_Cleanup_Strategy<KEY, VALUE, CONTAINER> CLEANUP_STRATEGY;
00233   typedef ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> CLEANUP_STRATEGY_BASE;
00234 
00235   /// Constructor.
00236   ACE_Handler_Caching_Utility (ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_strategy = 0,
00237                                int delete_cleanup_strategy = 0);
00238 
00239   /// Destructor.
00240   ~ACE_Handler_Caching_Utility (void);
00241 
00242   /**
00243    * Purge entries from the <container>. The Cleanup_Strategy will do
00244    * the actual job of cleanup once the entries to be cleaned up are
00245    * decided.
00246    */
00247   int clear_cache (CONTAINER &container,
00248                    double purge_percent);
00249 
00250 protected:
00251 
00252   /**
00253    * Find the entry with minimum caching attributes.  This is handler
00254    * specific since this utility is to be used very specifically for
00255    * handler who have caching_attributes for server side acched
00256    * connection management.
00257    */
00258   void minimum (CONTAINER &container,
00259                 KEY *&key_to_remove,
00260                 VALUE *&value_to_remove);
00261 
00262   /// The cleanup strategy which can be used to destroy the entries of
00263   /// the container.
00264   CLEANUP_STRATEGY_BASE *cleanup_strategy_;
00265 
00266   /// Whether the cleanup_strategy should be destroyed or not.
00267   int delete_cleanup_strategy_;
00268 
00269 private:
00270   ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Handler_Caching_Utility<KEY,VALUE,CONTAINER,ITERATOR,ATTRIBUTES> &))
00271   ACE_UNIMPLEMENTED_FUNC (ACE_Handler_Caching_Utility (const ACE_Handler_Caching_Utility<KEY,VALUE,CONTAINER,ITERATOR,ATTRIBUTES> &))
00272 };
00273 
00274 ///////////////////////////////////////////////////////////////////////////
00275 #define ACE_Null_Caching_Utility ANUTIL
00276 /**
00277  * @class ACE_Null_Caching_Utility
00278  *
00279  * @brief Defines a dummy helper class for the Caching Strategies.
00280  *
00281  * This class defines the methods commonly used by the different
00282  * caching strategies. For instance: <clear_cache> method which
00283  * decides and purges the entry from the container.  @note This
00284  * class is be used with the Null_Caching_Strategy. The
00285  * Cleanup_Strategy is the callback class to which the entries to
00286  * be cleaned up will be delegated.
00287  */
00288 template <class KEY, class VALUE, class CONTAINER, class ITERATOR, class ATTRIBUTES>
00289 class ACE_Null_Caching_Utility
00290 {
00291 public:
00292 
00293   typedef ACE_Null_Cleanup_Strategy<KEY, VALUE, CONTAINER> CLEANUP_STRATEGY;
00294   typedef ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> CLEANUP_STRATEGY_BASE;
00295 
00296   /// Constructor.
00297   ACE_Null_Caching_Utility (ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_strategy = 0,
00298                             int delete_cleanup_strategy = 0);
00299 
00300   /// Destructor.
00301   ~ACE_Null_Caching_Utility (void);
00302 
00303   /**
00304    * Purge entries from the <container>. The Cleanup_Strategy will do
00305    * the actual job of cleanup once the entries to be cleaned up are
00306    * decided. @note Here it is a no-op.
00307    */
00308   int clear_cache (CONTAINER &container,
00309                    double purge_percent);
00310 
00311 protected:
00312 
00313   /**
00314    * Find the entry with minimum caching attributes.  This is handler
00315    * specific since this utility is to be used very specifically for
00316    * handler who have caching_attributes for server side acched
00317    * connection management.@note Here it is a no-op.
00318    */
00319   void minimum (CONTAINER &container,
00320                 KEY *&key_to_remove,
00321                 VALUE *&value_to_remove);
00322 
00323   /// The cleanup strategy which can be used to destroy the entries of
00324   /// the container.
00325   CLEANUP_STRATEGY_BASE *cleanup_strategy_;
00326 
00327   /// Whether the cleanup_strategy should be destroyed or not.
00328   int delete_cleanup_strategy_;
00329 
00330 private:
00331   ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Null_Caching_Utility<KEY,VALUE,CONTAINER,ITERATOR,ATTRIBUTES> &))
00332   ACE_UNIMPLEMENTED_FUNC (ACE_Null_Caching_Utility (const ACE_Null_Caching_Utility<KEY,VALUE,CONTAINER,ITERATOR,ATTRIBUTES> &))
00333 };
00334 
00335 ACE_END_VERSIONED_NAMESPACE_DECL
00336 
00337 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
00338 #include "ace/Caching_Utility_T.cpp"
00339 #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
00340 
00341 #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
00342 #pragma implementation ("Caching_Utility_T.cpp")
00343 #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
00344 
00345 #include /**/ "ace/post.h"
00346 
00347 #endif /* ACE_CACHING_UTILITY_H */

Generated on Thu Nov 9 09:41:48 2006 for ACE by doxygen 1.3.6