diff options
author | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2000-11-01 22:17:39 +0000 |
---|---|---|
committer | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2000-11-01 22:17:39 +0000 |
commit | 53284e215e3d3351a7d7e9c4b68f14b427fb4377 (patch) | |
tree | 97236ece363cff48fd287c780db4290da39b02cb /ace/Caching_Strategies_T.h | |
parent | 7b7c52ad2abd228138ba1a948d5e28bf6dc3b880 (diff) | |
download | ATCD-53284e215e3d3351a7d7e9c4b68f14b427fb4377.tar.gz |
ChangeLogTag:Wed Nov 1 14:11:48 2000 Carlos O'Ryan <coryan@uci.edu>
Diffstat (limited to 'ace/Caching_Strategies_T.h')
-rw-r--r-- | ace/Caching_Strategies_T.h | 406 |
1 files changed, 209 insertions, 197 deletions
diff --git a/ace/Caching_Strategies_T.h b/ace/Caching_Strategies_T.h index 8fd8c86aa06..5871d5b397e 100644 --- a/ace/Caching_Strategies_T.h +++ b/ace/Caching_Strategies_T.h @@ -1,18 +1,15 @@ /* -*- C++ -*- */ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// ace -// -// = FILENAME -// Caching_Strategies_T.h -// -// = AUTHOR -// Kirthika Parameswaran <kirthika@cs.wustl.edu> -// -// ============================================================================ + +//============================================================================= +/** + * @file Caching_Strategies_T.h + * + * $Id$ + * + * @author Kirthika Parameswaran <kirthika@cs.wustl.edu> + */ +//============================================================================= + #ifndef CACHING_STRATEGIES_H #define CACHING_STRATEGIES_H @@ -33,23 +30,25 @@ // For linkers that cant grok long names. #define ACE_Caching_Strategy ACS +/** + * @class ACE_Caching_Strategy + * + * @brief This class is an abstract base class for a caching strategy. + * + * This class consists of all the interfaces a caching strategy should have and + * is used in association with the ACE_Caching_Strategy_Adaptor. + */ template <class ATTRIBUTES, class CACHING_UTILITY> class ACE_Caching_Strategy { - // = TITLE - // This class is an abstract base class for a caching strategy. - // - // = DESCRIPTION - // This class consists of all the interfaces a caching strategy should have and - // is used in association with the ACE_Caching_Strategy_Adaptor. public: + /// Destructor. virtual ~ACE_Caching_Strategy (void); - // Destructor. + /// Accessor method for the timer attributes. virtual ATTRIBUTES attributes (void) = 0; - // Accessor method for the timer attributes. // = Accessor methods for the percentage of entries to purge. virtual double purge_percent (void) = 0; @@ -57,66 +56,68 @@ public: // = Strategy related Operations + /// This method acts as a notification about the CONTAINERs bind + /// method call. virtual int notify_bind (int result, const ATTRIBUTES &attr) = 0; - // This method acts as a notification about the CONTAINERs bind - // method call. + /// This method acts as a notification about the CONTAINERs find + /// method call virtual int notify_find (int result, ATTRIBUTES &attr) = 0; - // This method acts as a notification about the CONTAINERs find - // method call + /// This method acts as a notification about the CONTAINERs unbind + /// method call virtual int notify_unbind (int result, const ATTRIBUTES &attr) = 0; - // This method acts as a notification about the CONTAINERs unbind - // method call + /// This method acts as a notification about the CONTAINERs trybind + /// method call virtual int notify_trybind (int result, ATTRIBUTES &attr) = 0; - // This method acts as a notification about the CONTAINERs trybind - // method call + /// This method acts as a notification about the CONTAINERs rebind + /// method call virtual int notify_rebind (int result, const ATTRIBUTES &attr) = 0; - // This method acts as a notification about the CONTAINERs rebind - // method call + /// Purge the cache. virtual CACHING_UTILITY &caching_utility (void) = 0; - // Purge the cache. + /// Dumps the state of the object. virtual void dump (void) const = 0; - // Dumps the state of the object. }; ////////////////////////////////////////////////////////////////////////// #define ACE_Caching_Strategy_Adapter ACSA +/** + * @class ACE_Caching_Strategy_Adapter + * + * @brief This class follows the Adaptor pattern and is used to provide + * External Polymorphism by deriving from ACE_Caching_Strategy. + * + * This class simply delegates all requests to the + * IMPLEMNETATION object within. This class should be passed in + * place of the the abstract base ACE_Caching_Strategy class as + * part of the External Polymorphism pattern. + */ template <class ATTRIBUTES, class CACHING_UTILITY, class IMPLEMENTATION> class ACE_Caching_Strategy_Adapter : public ACE_Caching_Strategy<ATTRIBUTES, CACHING_UTILITY> { - // = TITLE - // This class follows the Adaptor pattern and is used to provide - // External Polymorphism by deriving from ACE_Caching_Strategy. - // - // = DESCRIPTION - // This class simply delegates all requests to the - // IMPLEMNETATION object within. This class should be passed in - // place of the the abstract base ACE_Caching_Strategy class as - // part of the External Polymorphism pattern. public: + /// Constructor. ACE_Caching_Strategy_Adapter (IMPLEMENTATION *implementation = 0, int delete_implementation = 0); - // Constructor. + /// Destructor. ~ACE_Caching_Strategy_Adapter (void); - // Destructor. + /// Accessor method for the timer attributes. ATTRIBUTES attributes (void); - // Accessor method for the timer attributes. // = Accessor methods for the percentage of entries to purge. double purge_percent (void); @@ -124,73 +125,74 @@ public: // = Strategy related Operations + /// This method acts as a notification about the CONTAINERs bind + /// method call. int notify_bind (int result, const ATTRIBUTES &attr); - // This method acts as a notification about the CONTAINERs bind - // method call. + /// This method acts as a notification about the CONTAINERs find + /// method call int notify_find (int result, ATTRIBUTES &attr); - // This method acts as a notification about the CONTAINERs find - // method call + /// This method acts as a notification about the CONTAINERs unbind + /// method call int notify_unbind (int result, const ATTRIBUTES &attr); - // This method acts as a notification about the CONTAINERs unbind - // method call + /// This method acts as a notification about the CONTAINERs trybind + /// method call int notify_trybind (int result, ATTRIBUTES &attr); - // This method acts as a notification about the CONTAINERs trybind - // method call + /// This method acts as a notification about the CONTAINERs rebind + /// method call int notify_rebind (int result, const ATTRIBUTES &attr); - // This method acts as a notification about the CONTAINERs rebind - // method call + /// Accessor to the implementation. IMPLEMENTATION &implementation (void); - // Accessor to the implementation. + /// Purge the cache. CACHING_UTILITY &caching_utility (void); - // Purge the cache. + /// Dumps the state of the object. void dump (void) const; - // Dumps the state of the object. private: + /// Implementation class. IMPLEMENTATION *implementation_; - // Implementation class. + /// Do we need to delete the implementation? int delete_implementation_; - // Do we need to delete the implementation? }; ////////////////////////////////////////////////////////////////////////// #define ACE_LRU_Caching_Strategy ALRU +/** + * @class ACE_LRU_Caching_Strategy + * + * @brief Defines a Least Recently Used strategy which will decide on + * the item to be removed from the cache. + * + * This is a strategy which makes use of a virtual timer which + * is updated whenever an item is inserted or looked up in the + * container. When the need of purging entries arises, the items + * with the lowest timer values are removed. + * Explanation of the template parameter list: + * CONTAINER is any map with entries of type <KEY, VALUE>. + * The ATTRIBUTES are the deciding factor for purging of entries + * and should logically be included with the VALUE. Some ways of + * doing this are: As being a member of the VALUE or VALUE being + * ACE_Pair<x, ATTRIBUTES>. The CACHING_UTILITY is the + * class which can be plugged in and which decides the entries + * to purge. + */ template <class ATTRIBUTES, class CACHING_UTILITY> class ACE_LRU_Caching_Strategy { - // = TITLE - // Defines a Least Recently Used strategy which will decide on - // the item to be removed from the cache. - // - // = DESCRIPTION - // This is a strategy which makes use of a virtual timer which - // is updated whenever an item is inserted or looked up in the - // container. When the need of purging entries arises, the items - // with the lowest timer values are removed. - // - // Explanation of the template parameter list: - // CONTAINER is any map with entries of type <KEY, VALUE>. - // The ATTRIBUTES are the deciding factor for purging of entries - // and should logically be included with the VALUE. Some ways of - // doing this are: As being a member of the VALUE or VALUE being - // ACE_Pair<x, ATTRIBUTES>. The CACHING_UTILITY is the - // class which can be plugged in and which decides the entries - // to purge. public: @@ -199,17 +201,19 @@ public: // = Initialisation and termination. + /** + * The <container> is the map in which the entries reside. The + * timer attribute is initialed to zero in this constructor. And + * the <purge_percent> field denotes the percentage of the entries + * in the cache which can be purged automagically and by default is + * set to 10%. + */ ACE_LRU_Caching_Strategy (void); - // The <container> is the map in which the entries reside. The - // timer attribute is initialed to zero in this constructor. And - // the <purge_percent> field denotes the percentage of the entries - // in the cache which can be purged automagically and by default is - // set to 10%. // = Operations of the strategy. + /// Accessor method for the timer attributes. ATTRIBUTES attributes (void); - // Accessor method for the timer attributes. // = Accessor methods for the percentage of entries to purge. double purge_percent (void); @@ -218,76 +222,77 @@ public: // = Strategy related Operations + /// This method acts as a notification about the CONTAINERs bind + /// method call. int notify_bind (int result, const ATTRIBUTES &attr); - // This method acts as a notification about the CONTAINERs bind - // method call. + /// This method acts as a notification about the CONTAINERs find + /// method call int notify_find (int result, ATTRIBUTES &attr); - // This method acts as a notification about the CONTAINERs find - // method call + /// This method acts as a notification about the CONTAINERs unbind + /// method call int notify_unbind (int result, const ATTRIBUTES &attr); - // This method acts as a notification about the CONTAINERs unbind - // method call + /// This method acts as a notification about the CONTAINERs trybind + /// method call int notify_trybind (int result, ATTRIBUTES &attr); - // This method acts as a notification about the CONTAINERs trybind - // method call + /// This method acts as a notification about the CONTAINERs rebind + /// method call int notify_rebind (int result, const ATTRIBUTES &attr); - // This method acts as a notification about the CONTAINERs rebind - // method call + /// Purge the cache. CACHING_UTILITY &caching_utility (void); - // Purge the cache. + /// Dumps the state of the object. void dump (void) const; - // Dumps the state of the object. private: + /// This element is the one which is the deciding factor for purging + /// of an ITEM. ATTRIBUTES timer_; - // This element is the one which is the deciding factor for purging - // of an ITEM. + /// The level about which the purging will happen automagically. double purge_percent_; - // The level about which the purging will happen automagically. + /// This is the helper class which will decide and expunge entries + /// from the cache. CACHING_UTILITY caching_utility_; - // This is the helper class which will decide and expunge entries - // from the cache. }; ////////////////////////////////////////////////////////////////////////// #define ACE_LFU_Caching_Strategy ALFU +/** + * @class ACE_LFU_Caching_Strategy + * + * @brief Defines a Least Frequently Used strategy for which will decide on + * the item to be removed from the cache. + * + * A attribute is tagged to each item which increments whenever + * the item is bound or looked up in the cache. Thus it denotes + * the frequency of use. According to the value of the attribute + * the item is removed from the CONTAINER i.e cache. + * Explanation of the template parameter list: + * CONTAINER is any map with entries of type <KEY, VALUE>. + * The ATTRIBUTES are the deciding factor for purging of entries + * and should logically be included with the VALUE. Some ways of + * doing this are: As being a member of the VALUE or VALUE being + * ACE_Pair<x, ATTRIBUTES>. The CACHING_UTILITY is the + * class which can be plugged in and which decides the entries + * to purge. + */ template <class ATTRIBUTES, class CACHING_UTILITY> class ACE_LFU_Caching_Strategy { - // = TITLE - // Defines a Least Frequently Used strategy for which will decide on - // the item to be removed from the cache. - // - // = DESCRIPTION - // A attribute is tagged to each item which increments whenever - // the item is bound or looked up in the cache. Thus it denotes - // the frequency of use. According to the value of the attribute - // the item is removed from the CONTAINER i.e cache. - // - // Explanation of the template parameter list: - // CONTAINER is any map with entries of type <KEY, VALUE>. - // The ATTRIBUTES are the deciding factor for purging of entries - // and should logically be included with the VALUE. Some ways of - // doing this are: As being a member of the VALUE or VALUE being - // ACE_Pair<x, ATTRIBUTES>. The CACHING_UTILITY is the - // class which can be plugged in and which decides the entries - // to purge. public: @@ -296,17 +301,19 @@ public: // = Initialisation and termination methods. + /** + * The <container> is the map in which the entries reside. The + * timer attribute is initialed to zero in this constructor. And + * the <purge_percent> field denotes the percentage of the entries + * in the cache which can be purged automagically and by default is + * set to 10%. + */ ACE_LFU_Caching_Strategy (void); - // The <container> is the map in which the entries reside. The - // timer attribute is initialed to zero in this constructor. And - // the <purge_percent> field denotes the percentage of the entries - // in the cache which can be purged automagically and by default is - // set to 10%. // = Strategy methods. + /// Access the attributes. ATTRIBUTES attributes (void); - // Access the attributes. // = Accessor methods for the percentage of entries to purge. double purge_percent (void); @@ -315,68 +322,69 @@ public: // = Strategy related Operations + /// This method acts as a notification about the CONTAINERs bind + /// method call. int notify_bind (int result, const ATTRIBUTES &attr); - // This method acts as a notification about the CONTAINERs bind - // method call. + /// Lookup notification. int notify_find (int result, ATTRIBUTES &attr); - // Lookup notification. + /// This method acts as a notification about the CONTAINERs unbind + /// method call int notify_unbind (int result, const ATTRIBUTES &attr); - // This method acts as a notification about the CONTAINERs unbind - // method call + /// This method acts as a notification about the CONTAINERs trybind + /// method call int notify_trybind (int result, ATTRIBUTES &attr); - // This method acts as a notification about the CONTAINERs trybind - // method call + /// This method acts as a notification about the CONTAINERs rebind + /// method call int notify_rebind (int result, const ATTRIBUTES &attr); - // This method acts as a notification about the CONTAINERs rebind - // method call + /// Purge the cache. CACHING_UTILITY &caching_utility (void); - // Purge the cache. + /// Dumps the state of the object. void dump (void) const; - // Dumps the state of the object. private: + /// The level about which the purging will happen automagically. double purge_percent_; - // The level about which the purging will happen automagically. + /// This is the helper class which will decide and expunge entries + /// from the cache. CACHING_UTILITY caching_utility_; - // This is the helper class which will decide and expunge entries - // from the cache. }; ///////////////////////////////////////////////////////////// #define ACE_FIFO_Caching_Strategy AFIFO +/** + * @class ACE_FIFO_Caching_Strategy + * + * @brief The First In First Out strategy is implemented wherein each + * item is ordered. + * + * The order tag of each item is used to decide the item to be + * removed from the cache. The items with least order are removed. + * Explanation of the template parameter list: + * CONTAINER is any map with entries of type <KEY, VALUE>. + * The ATTRIBUTES are the deciding factor for purging of entries + * and should logically be included with the VALUE. Some ways of + * doing this are: As being a member of the VALUE or VALUE being + * ACE_Pair<x, ATTRIBUTES>. The CACHING_UTILITY is the + * class which can be plugged in and which decides the entries + * to purge. + */ template<class ATTRIBUTES, class CACHING_UTILITY> class ACE_FIFO_Caching_Strategy { - // = TITLE - // The First In First Out strategy is implemented wherein each - // item is ordered. - // - // = DESCRIPTION - // The order tag of each item is used to decide the item to be - // removed from the cache. The items with least order are removed. - // - // Explanation of the template parameter list: - // CONTAINER is any map with entries of type <KEY, VALUE>. - // The ATTRIBUTES are the deciding factor for purging of entries - // and should logically be included with the VALUE. Some ways of - // doing this are: As being a member of the VALUE or VALUE being - // ACE_Pair<x, ATTRIBUTES>. The CACHING_UTILITY is the - // class which can be plugged in and which decides the entries - // to purge. public: @@ -384,17 +392,19 @@ public: // = Initialisation and termination. + /** + * The <container> is the map in which the entries reside. The + * timer attribute is initialed to zero in this constructor. And + * the <purge_percent> field denotes the percentage of the entries + * in the cache which can be purged automagically and by default is + * set to 10%. + */ ACE_FIFO_Caching_Strategy (void); - // The <container> is the map in which the entries reside. The - // timer attribute is initialed to zero in this constructor. And - // the <purge_percent> field denotes the percentage of the entries - // in the cache which can be purged automagically and by default is - // set to 10%. // = Strategy methods. + /// Accessor method. ATTRIBUTES attributes (void); - // Accessor method. // = Accessor methods for the percentage of entries to purge. double purge_percent (void); @@ -403,62 +413,64 @@ public: // = Strategy related Operations + /// Notification for an item getting bound into the cache. int notify_bind (int result, const ATTRIBUTES &attr); - // Notification for an item getting bound into the cache. + /// This method acts as a notification about the CONTAINERs find + /// method call int notify_find (int result, ATTRIBUTES &attr); - // This method acts as a notification about the CONTAINERs find - // method call + /// This method acts as a notification about the CONTAINERs unbind + /// method call int notify_unbind (int result, const ATTRIBUTES &attr); - // This method acts as a notification about the CONTAINERs unbind - // method call + /// This method acts as a notification about the CONTAINERs trybind + /// method call int notify_trybind (int result, ATTRIBUTES &attr); - // This method acts as a notification about the CONTAINERs trybind - // method call + /// Notification for an item getting bound again into the cache. int notify_rebind (int result, const ATTRIBUTES &attr); - // Notification for an item getting bound again into the cache. + /// Purge the cache. CACHING_UTILITY &caching_utility (void); - // Purge the cache. + /// Dumps the state of the object. void dump (void) const; - // Dumps the state of the object. private: + /// The order is the deciding factor for the item to be removed from + /// the cache. ATTRIBUTES order_; - // The order is the deciding factor for the item to be removed from - // the cache. + /// The level about which the purging will happen automagically. double purge_percent_; - // The level about which the purging will happen automagically. + /// This is the helper class which will decide and expunge entries + /// from the cache. CACHING_UTILITY caching_utility_; - // This is the helper class which will decide and expunge entries - // from the cache. }; ////////////////////////////////////////////////////////////////////// #define ACE_Null_Caching_Strategy ANULL +/** + * @class ACE_Null_Caching_Strategy + * + * @brief The is a special caching strategy which doesnt have the purging + * feature. + * + * No purging provided. To be used when purging might be too expensive + * an operation. + */ template<class ATTRIBUTES, class CACHING_UTILITY> class ACE_Null_Caching_Strategy { - // = TITLE - // The is a special caching strategy which doesnt have the purging - // feature. - // - // = DESCRIPTION - // No purging provided. To be used when purging might be too expensive - // an operation. public: @@ -467,8 +479,8 @@ public: // = Strategy methods. All are NO_OP methods!!! + /// Accessor method. ATTRIBUTES attributes (void); - // Accessor method. // = Accessor methods for the percentage of entries to purge. double purge_percent (void); @@ -477,40 +489,40 @@ public: // = Strategy related Operations + /// Notification for an item getting bound into the cache. int notify_bind (int result, const ATTRIBUTES &attr); - // Notification for an item getting bound into the cache. + /// This method acts as a notification about the CONTAINERs find + /// method call int notify_find (int result, ATTRIBUTES &attr); - // This method acts as a notification about the CONTAINERs find - // method call + /// This method acts as a notification about the CONTAINERs unbind + /// method call int notify_unbind (int result, const ATTRIBUTES &attr); - // This method acts as a notification about the CONTAINERs unbind - // method call + /// This method acts as a notification about the CONTAINERs trybind + /// method call int notify_trybind (int result, ATTRIBUTES &attr); - // This method acts as a notification about the CONTAINERs trybind - // method call + /// Notification for an item getting bound again into the cache. int notify_rebind (int result, const ATTRIBUTES &attr); - // Notification for an item getting bound again into the cache. + /// Purge the cache. CACHING_UTILITY &caching_utility (void); - // Purge the cache. + /// Dumps the state of the object. void dump (void) const; - // Dumps the state of the object. private: + /// This is the helper class which will decide and expunge entries + /// from the cache. CACHING_UTILITY caching_utility_; - // This is the helper class which will decide and expunge entries - // from the cache. }; #if defined (__ACE_INLINE__) |