diff options
author | kirthika <kirthika@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-06-10 23:11:47 +0000 |
---|---|---|
committer | kirthika <kirthika@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-06-10 23:11:47 +0000 |
commit | 685597cd7e3f19b0740f4ccc2bd76523822192db (patch) | |
tree | 7e001abf19642a86dd5938aeefd34f32c012c4c2 /ace/Caching_Strategies_T.h | |
parent | 7ff46e1f4758300c4b3575c53c2f54bf0d226065 (diff) | |
download | ATCD-685597cd7e3f19b0740f4ccc2bd76523822192db.tar.gz |
Added extra parameters to the template parameter list to care for g++
warnings.
Diffstat (limited to 'ace/Caching_Strategies_T.h')
-rw-r--r-- | ace/Caching_Strategies_T.h | 208 |
1 files changed, 158 insertions, 50 deletions
diff --git a/ace/Caching_Strategies_T.h b/ace/Caching_Strategies_T.h index 686c5331d9e..8e7db943ba7 100644 --- a/ace/Caching_Strategies_T.h +++ b/ace/Caching_Strategies_T.h @@ -27,7 +27,7 @@ #include "ace/Cleanup_Strategies_T.h" -template <class CONTAINER> +template <class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> class ACE_LRU_Caching_Strategy { // = TITLE @@ -39,17 +39,28 @@ class ACE_LRU_Caching_Strategy // 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_STRATEGY_UTILITY is the + // class which can be plugged in and which decides the entries + // to purge. public: // Traits. - typedef int ATTRIBUTES; + typedef ATTRIBUTES CACHING_ATTRIBUTES; typedef CONTAINER CACHE; // = Initialisation and termination. - ACE_LRU_Caching_Strategy (ACE_Cleanup_Strategy<CONTAINER> *cleanup_s = 0, - int delete_cleanup_strategy = 1); + ACE_LRU_Caching_Strategy (ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_s = 0, + int delete_cleanup_strategy = 1, + CACHING_STRATEGY_UTILITY *utility_s = 0, + int delete_caching_strategy_utility = 1); // The <container> is the map in which the entries reside. // The Cleanup_Strategy is the callback class to which the entries // to be cleaned up will be delegated. The <delete_cleanup_strategy> @@ -57,23 +68,29 @@ public: // Also, 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%. + // set to 10%. The ultility which helps the caching strategy in the + // purging of entries needs to be specified. By default a new one + // will be created of type CACHING_STRATEGY_UTILITY and + // <delete_caching_strategy_utility> decides whether to destroy the + // utility object or not. ~ACE_LRU_Caching_Strategy (void); // = Operations of the strategy. - int open (ACE_Cleanup_Strategy<CONTAINER> *cleanup_s = 0, - int delete_cleanup_strategy = 1); + int open (ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_s = 0, + int delete_cleanup_strategy = 1, + CACHING_STRATEGY_UTILITY *utility_s = 0, + int delete_caching_strategy_utility = 1); // This method which does the actual initialisation. ATTRIBUTES attributes (void); // Accessor method for the timer attributes. // = Accessor methods for the percentage of entries to purge. - int purge_percent (void); + unsigned int purge_percent (void); - void purge_percent (int percentage); + void purge_percent (unsigned int percentage); // = Strategy related Operations @@ -107,12 +124,20 @@ public: // This is the method which looks at each ITEM's attributes and // then decides on the one to remove. + int clear_cache (CONTAINER &container, + unsigned int &total_container_entries); + // This is the method which looks at each ITEM's attributes and + // then decides on the one to remove. The <total_container_entries> + // can be specified explicitly and facilitates use of the caching + // strategy even when the <entries_> is not maintained by the + // strategy itself. + void dump (void) const; // Dumps the state of the object. private: - typedef ACE_Default_Cleanup_Strategy<CONTAINER> CLEANUP_STRATEGY; + typedef ACE_Default_Cleanup_Strategy<KEY, VALUE, CONTAINER> CLEANUP_STRATEGY; ATTRIBUTES timer_; // This element is the one which is the deciding factor for purging @@ -124,7 +149,7 @@ private: unsigned int entries_; // The no of entries bound in the cache. - ACE_Cleanup_Strategy<CONTAINER> *cleanup_strategy_; + ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_strategy_; // The cleanup strategy which can be used to destroy the entries of // the container. @@ -132,15 +157,20 @@ private: // The flag which denotes the ownership of the cleanup strategy. // If 1 then this class itself will destroy the strategy. - ACE_Caching_Strategy_Utility<CONTAINER, ATTRIBUTES> caching_strategy_utility_; + CACHING_STRATEGY_UTILITY *caching_strategy_utility_; // This is the helper class which will decide and expunge entries // from the cache. + + int delete_caching_strategy_utility_; + // The flag which denotes the ownership of the + // caching_strategy_utility. If 1 then this class itself will + // destroy the strategy utility object. }; ////////////////////////////////////////////////////////////////////////// -template <class CONTAINER> +template <class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> class ACE_LFU_Caching_Strategy { // = TITLE @@ -152,15 +182,28 @@ class ACE_LFU_Caching_Strategy // 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_STRATEGY_UTILITY is the + // class which can be plugged in and which decides the entries + // to purge. + public: // Traits. - typedef int ATTRIBUTES; + typedef ATTRIBUTES CACHING_ATTRIBUTES; + typedef CONTAINER CACHE; // = Initialisation and termination methods. - ACE_LFU_Caching_Strategy (ACE_Cleanup_Strategy<CONTAINER> *cleanup_s = 0, - int delete_cleanup_strategy = 1); + ACE_LFU_Caching_Strategy (ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_s = 0, + int delete_cleanup_strategy = 1, + CACHING_STRATEGY_UTILITY *utility_s = 0, + int delete_caching_strategy_utility = 1); // The <container> is the map in which the entries reside. // The Cleanup_Strategy is the callback class to which the entries // to be cleaned up will be delegated. The <delete_cleanup_strategy> @@ -168,12 +211,18 @@ public: // Also, 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%. + // set to 10%.The ultility which helps the caching strategy in the + // purging of entries will be default be the + // ACE_Caching_Strategy_Utility and the + // <delete_caching_strategy_utility> decides whether to destroy the + // utility or not. ~ACE_LFU_Caching_Strategy (void); - int open (ACE_Cleanup_Strategy<CONTAINER> *cleanup_s = 0, - int delete_cleanup_strategy = 1); + int open (ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_s = 0, + int delete_cleanup_strategy = 1, + CACHING_STRATEGY_UTILITY *utility_s = 0, + int delete_caching_strategy_utility = 1); // This method which does the actual initialisation. // = Strategy methods. @@ -182,9 +231,9 @@ public: // Access the attributes. // = Accessor methods for the percentage of entries to purge. - int purge_percent (void); + unsigned int purge_percent (void); - void purge_percent (int percentage); + void purge_percent (unsigned int percentage); // = Strategy related Operations @@ -217,20 +266,28 @@ public: // This is the method which looks at each ITEM's attributes and // then decides on the one to remove. + int clear_cache (CONTAINER &container, + unsigned int &total_container_entries); + // This is the method which looks at each ITEM's attributes and + // then decides on the one to remove. The <total_container_entries> + // can be specified explicitly and facilitates use of the caching + // strategy even when the <entries_> is not maintained by the + // strategy itself. + void dump (void) const; // Dumps the state of the object. private: - typedef ACE_Default_Cleanup_Strategy<CONTAINER> CLEANUP_STRATEGY; - + typedef ACE_Default_Cleanup_Strategy<KEY, VALUE, CONTAINER> CLEANUP_STRATEGY; + unsigned int purge_percent_; // The level about which the purging will happen automagically. unsigned int entries_; // The no of entries bound in the cache. - ACE_Cleanup_Strategy<CONTAINER> *cleanup_strategy_; + ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_strategy_; // The cleanup strategy which can be used to destroy the entries of // the container. @@ -238,32 +295,49 @@ private: // The flag which denotes the ownership of the cleanup strategy. // If 1 then this class itself will destroy the strategy. - ACE_Caching_Strategy_Utility<CONTAINER, ATTRIBUTES> caching_strategy_utility_; + CACHING_STRATEGY_UTILITY *caching_strategy_utility_; // This is the helper class which will decide and expunge entries // from the cache. + int delete_caching_strategy_utility_; + // The flag which denotes the ownership of the + // caching_strategy_utility. If 1 then this class itself will + // destroy the strategy utility object. }; ///////////////////////////////////////////////////////////// -template<class CONTAINER> +template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> class ACE_FIFO_Caching_Strategy { // = TITLE - // The First In First Out strategy is implemented wherein each - // item is ordered. + // 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. + // 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_STRATEGY_UTILITY is the + // class which can be plugged in and which decides the entries + // to purge. + public: - typedef int ATTRIBUTES; + typedef ATTRIBUTES CACHING_ATTRIBUTES; + typedef CONTAINER CACHE; // = Initialisation and termination. - ACE_FIFO_Caching_Strategy (ACE_Cleanup_Strategy<CONTAINER> *cleanup_s = 0, - int delete_cleanup_strategy = 1); + ACE_FIFO_Caching_Strategy (ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_s = 0, + int delete_cleanup_strategy = 1, + CACHING_STRATEGY_UTILITY *utility_s = 0, + int delete_caching_strategy_utility = 1); // The <container> is the map in which the entries reside. // The Cleanup_Strategy is the callback class to which the entries // to be cleaned up will be delegated. The <delete_cleanup_strategy> @@ -271,12 +345,18 @@ public: // Also, 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%. + // set to 10%.The ultility which helps the caching strategy in the + // purging of entries will be default be the + // ACE_Caching_Strategy_Utility and the + // <delete_caching_strategy_utility> decides whether to destroy the + // utility or not. ~ACE_FIFO_Caching_Strategy (void); - int open (ACE_Cleanup_Strategy<CONTAINER> *cleanup_s = 0, - int delete_cleanup_strategy = 1); + int open (ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_s = 0, + int delete_cleanup_strategy = 1, + CACHING_STRATEGY_UTILITY *utility_s = 0, + int delete_caching_strategy_utility = 1); // This method which does the actual initialisation. // = Strategy methods. @@ -285,9 +365,9 @@ public: // Accessor method. // = Accessor methods for the percentage of entries to purge. - int purge_percent (void); + unsigned int purge_percent (void); - void purge_percent (int percentage); + void purge_percent (unsigned int percentage); // = Strategy related Operations @@ -318,13 +398,21 @@ public: // This is the method which looks at each ITEM's attributes and // then decides on the one to remove. + int clear_cache (CONTAINER &container, + unsigned int &total_container_entries); + // This is the method which looks at each ITEM's attributes and + // then decides on the one to remove. The <total_container_entries> + // can be specified explicitly and facilitates use of the caching + // strategy even when the <entries_> is not maintained by the + // strategy itself. + void dump (void) const; // Dumps the state of the object. private: - typedef ACE_Default_Cleanup_Strategy<CONTAINER> CLEANUP_STRATEGY; - + typedef ACE_Default_Cleanup_Strategy<KEY, VALUE, CONTAINER> CLEANUP_STRATEGY; + ATTRIBUTES order_; // The order is the deciding factor for the item to be removed from // the cache. @@ -335,7 +423,7 @@ private: unsigned int entries_; // The no of entries bound in the cache. - ACE_Cleanup_Strategy<CONTAINER> *cleanup_strategy_; + ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_strategy_; // The cleanup strategy which can be used to destroy the entries of // the container. @@ -343,12 +431,18 @@ private: // The flag which denotes the ownership of the cleanup strategy. // If 1 then this class itself will destroy the strategy. - ACE_Caching_Strategy_Utility<CONTAINER, ATTRIBUTES> caching_strategy_utility_; + CACHING_STRATEGY_UTILITY *caching_strategy_utility_; // This is the helper class which will decide and expunge entries // from the cache. + + int delete_caching_strategy_utility_; + // The flag which denotes the ownership of the + // caching_strategy_utility. If 1 then this class itself will + // destroy the strategy utility object. + }; -template<class CONTAINER> +template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> class ACE_Null_Caching_Strategy { // = TITLE @@ -361,18 +455,24 @@ class ACE_Null_Caching_Strategy public: - typedef int ATTRIBUTES; + // = Traits. + typedef ATTRIBUTES CACHING_ATTRIBUTES; + typedef CONTAINER CACHE; // = Initialisation and termination. - ACE_Null_Caching_Strategy (ACE_Cleanup_Strategy<CONTAINER> *cleanup_s = 0, - int delete_cleanup_strategy = 1); + ACE_Null_Caching_Strategy (ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_s = 0, + int delete_cleanup_strategy = 1, + CACHING_STRATEGY_UTILITY *utility_s = 0, + int delete_caching_strategy_utility = 1); ~ACE_Null_Caching_Strategy (void); - int open (ACE_Cleanup_Strategy<CONTAINER> *cleanup_s = 0, - int delete_cleanup_strategy = 1); + int open (ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_s = 0, + int delete_cleanup_strategy = 1, + CACHING_STRATEGY_UTILITY *utility_s = 0, + int delete_caching_strategy_utility = 1); // This method which does the actual initialisation. // = Strategy methods. All are NO_OP methods!!! @@ -381,9 +481,9 @@ public: // Accessor method. // = Accessor methods for the percentage of entries to purge. - int purge_percent (void); + unsigned int purge_percent (void); - void purge_percent (int percentage); + void purge_percent (unsigned int percentage); // = Strategy related Operations @@ -414,6 +514,14 @@ public: // This is the method which looks at each ITEM's attributes and // then decides on the one to remove. + int clear_cache (CONTAINER &container, + unsigned int &total_container_entries); + // This is the method which looks at each ITEM's attributes and + // then decides on the one to remove. The <total_container_entries> + // can be specified explicitly and facilitates use of the caching + // strategy even when the <entries_> is not maintained by the + // strategy itself. + void dump (void) const; // Dumps the state of the object. |