summaryrefslogtreecommitdiff
path: root/ace/Caching_Strategies_T.h
diff options
context:
space:
mode:
authorirfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-07-12 19:20:35 +0000
committerirfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-07-12 19:20:35 +0000
commit5cfb4bb5ed96220ac41075f64c56288f587ea894 (patch)
tree4152f0e4a98529cb2b54703bf873c9371a83af24 /ace/Caching_Strategies_T.h
parent288a68560e3b423ce5b02d4e48675ba7d6df505b (diff)
downloadATCD-5cfb4bb5ed96220ac41075f64c56288f587ea894.tar.gz
ChangeLogTag:Mon Jul 12 13:54:34 1999 Kirthika Parameswaran <kirthika@cs.wustl.edu>
Diffstat (limited to 'ace/Caching_Strategies_T.h')
-rw-r--r--ace/Caching_Strategies_T.h240
1 files changed, 49 insertions, 191 deletions
diff --git a/ace/Caching_Strategies_T.h b/ace/Caching_Strategies_T.h
index 44b5e31f096..41966b677f0 100644
--- a/ace/Caching_Strategies_T.h
+++ b/ace/Caching_Strategies_T.h
@@ -25,9 +25,11 @@
#define ACE_LACKS_PRAGMA_ONCE
#endif /* ACE_LACKS_PRAGMA_ONCE */
-#include "ace/Cleanup_Strategies_T.h"
+#if defined(_MSC_VER)
+#pragma warning(disable:4503)
+#endif /* _MSC_VER */
-template <class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY>
+template <class ATTRIBUTES, class CACHING_UTILITY>
class ACE_Caching_Strategy
{
// = TITLE
@@ -42,12 +44,6 @@ public:
virtual ~ACE_Caching_Strategy (void);
// Destructor.
- virtual 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) = 0;
- // This method which does the actual initialisation.
-
virtual ATTRIBUTES attributes (void) = 0;
// Accessor method for the timer attributes.
@@ -82,9 +78,8 @@ public:
// This method acts as a notification about the CONTAINERs rebind
// method call
- virtual int clear_cache (CONTAINER &container) = 0;
- // This is the method which looks at each ITEM's attributes and
- // then decides on the one to remove.
+ virtual CACHING_UTILITY &caching_utility (void) = 0;
+ // Purge the cache.
virtual void dump (void) const = 0;
// Dumps the state of the object.
@@ -92,8 +87,8 @@ public:
//////////////////////////////////////////////////////////////////////////
-template <class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY, class IMPLEMENTATION>
-class ACE_Caching_Strategy_Adapter : public ACE_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>
+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
@@ -114,12 +109,6 @@ public:
~ACE_Caching_Strategy_Adapter (void);
// Destructor.
- 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.
@@ -154,13 +143,12 @@ public:
// This method acts as a notification about the CONTAINERs rebind
// method call
- int clear_cache (CONTAINER &container);
- // This is the method which looks at each ITEM's attributes and
- // then decides on the one to remove.
-
IMPLEMENTATION &implementation (void);
// Accessor to the implementation.
+ CACHING_UTILITY &caching_utility (void);
+ // Purge the cache.
+
void dump (void) const;
// Dumps the state of the object.
@@ -175,7 +163,7 @@ private:
//////////////////////////////////////////////////////////////////////////
-template <class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY>
+template <class ATTRIBUTES, class CACHING_UTILITY>
class ACE_LRU_Caching_Strategy
{
// = TITLE
@@ -193,7 +181,7 @@ class ACE_LRU_Caching_Strategy
// 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
+ // ACE_Pair<x, ATTRIBUTES>. The CACHING_UTILITY is the
// class which can be plugged in and which decides the entries
// to purge.
@@ -201,37 +189,18 @@ public:
// Traits.
typedef ATTRIBUTES CACHING_ATTRIBUTES;
- typedef CONTAINER CACHE;
// = Initialisation and termination.
- 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>
- // flag is needed to decide the ownership of the cleanup strategy.
- // Also, the timer attribute is initialed to zero in this constructor.
- // And the <purge_percent> field denotes the percentage of the entries
+ 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%. 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);
+ // set to 10%.
// = Operations of the strategy.
- 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.
@@ -268,17 +237,14 @@ public:
// This method acts as a notification about the CONTAINERs rebind
// method call
- int clear_cache (CONTAINER &container);
- // This is the method which looks at each ITEM's attributes and
- // then decides on the one to remove.
+ CACHING_UTILITY &caching_utility (void);
+ // Purge the cache.
void dump (void) const;
// Dumps the state of the object.
private:
- typedef ACE_Default_Cleanup_Strategy<KEY, VALUE, CONTAINER> CLEANUP_STRATEGY;
-
ATTRIBUTES timer_;
// This element is the one which is the deciding factor for purging
// of an ITEM.
@@ -286,31 +252,14 @@ private:
double 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<KEY, VALUE, CONTAINER> *cleanup_strategy_;
- // The cleanup strategy which can be used to destroy the entries of
- // the container.
-
- int delete_cleanup_strategy_;
- // The flag which denotes the ownership of the cleanup strategy.
- // If 1 then this class itself will destroy the strategy.
-
- CACHING_STRATEGY_UTILITY *caching_strategy_utility_;
+ CACHING_UTILITY caching_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 KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY>
+template <class ATTRIBUTES, class CACHING_UTILITY>
class ACE_LFU_Caching_Strategy
{
// = TITLE
@@ -328,7 +277,7 @@ class ACE_LFU_Caching_Strategy
// 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
+ // ACE_Pair<x, ATTRIBUTES>. The CACHING_UTILITY is the
// class which can be plugged in and which decides the entries
// to purge.
@@ -336,34 +285,15 @@ public:
// Traits.
typedef ATTRIBUTES CACHING_ATTRIBUTES;
- typedef CONTAINER CACHE;
// = Initialisation and termination methods.
- 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>
- // flag is needed to decide the ownership of the cleanup strategy.
- // Also, the timer attribute is initialed to zero in this constructor.
- // And the <purge_percent> field denotes the percentage of the entries
+ 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%.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<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.
+ // set to 10%.
// = Strategy methods.
@@ -401,45 +331,25 @@ public:
// This method acts as a notification about the CONTAINERs rebind
// method call
-
- int clear_cache (CONTAINER &container);
- // This is the method which looks at each ITEM's attributes and
- // then decides on the one to remove.
+ CACHING_UTILITY &caching_utility (void);
+ // Purge the cache.
void dump (void) const;
// Dumps the state of the object.
private:
- typedef ACE_Default_Cleanup_Strategy<KEY, VALUE, CONTAINER> CLEANUP_STRATEGY;
-
double 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<KEY, VALUE, CONTAINER> *cleanup_strategy_;
- // The cleanup strategy which can be used to destroy the entries of
- // the container.
-
- int delete_cleanup_strategy_;
- // The flag which denotes the ownership of the cleanup strategy.
- // If 1 then this class itself will destroy the strategy.
-
- CACHING_STRATEGY_UTILITY *caching_strategy_utility_;
+ CACHING_UTILITY caching_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 KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY>
+template<class ATTRIBUTES, class CACHING_UTILITY>
class ACE_FIFO_Caching_Strategy
{
// = TITLE
@@ -455,41 +365,22 @@ class ACE_FIFO_Caching_Strategy
// 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
+ // ACE_Pair<x, ATTRIBUTES>. The CACHING_UTILITY is the
// class which can be plugged in and which decides the entries
// to purge.
public:
typedef ATTRIBUTES CACHING_ATTRIBUTES;
- typedef CONTAINER CACHE;
// = Initialisation and termination.
- 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>
- // flag is needed to decide the ownership of the cleanup strategy.
- // Also, the timer attribute is initialed to zero in this constructor.
- // And the <purge_percent> field denotes the percentage of the entries
+ 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%.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<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.
+ // set to 10%.
// = Strategy methods.
@@ -526,17 +417,14 @@ public:
const ATTRIBUTES &attr);
// Notification for an item getting bound again into the cache.
- int clear_cache (CONTAINER &container);
- // This is the method which looks at each ITEM's attributes and
- // then decides on the one to remove.
+ CACHING_UTILITY &caching_utility (void);
+ // Purge the cache.
void dump (void) const;
// Dumps the state of the object.
private:
- 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.
@@ -544,29 +432,12 @@ private:
double 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<KEY, VALUE, CONTAINER> *cleanup_strategy_;
- // The cleanup strategy which can be used to destroy the entries of
- // the container.
-
- int delete_cleanup_strategy_;
- // The flag which denotes the ownership of the cleanup strategy.
- // If 1 then this class itself will destroy the strategy.
-
- CACHING_STRATEGY_UTILITY *caching_strategy_utility_;
+ CACHING_UTILITY caching_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 KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY>
+template<class ATTRIBUTES, class CACHING_UTILITY>
class ACE_Null_Caching_Strategy
{
// = TITLE
@@ -581,23 +452,6 @@ public:
// = Traits.
typedef ATTRIBUTES CACHING_ATTRIBUTES;
- typedef CONTAINER CACHE;
-
- // = Initialisation and termination.
-
- 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<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!!!
@@ -634,13 +488,17 @@ public:
const ATTRIBUTES &attr);
// Notification for an item getting bound again into the cache.
- int clear_cache (CONTAINER &container);
- // This is the method which looks at each ITEM's attributes and
- // then decides on the one to remove.
+ CACHING_UTILITY &caching_utility (void);
+ // Purge the cache.
void dump (void) const;
// Dumps the state of the object.
+private:
+
+ CACHING_UTILITY caching_utility_;
+ // This is the helper class which will decide and expunge entries
+ // from the cache.
};
#if defined (__ACE_INLINE__)