Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

ACE_Handler_Caching_Utility Class Template Reference

Defines a helper class for the Caching Strategies. More...

#include <Caching_Utility_T.h>

Collaboration diagram for ACE_Handler_Caching_Utility:

Collaboration graph
[legend]
List of all members.

Public Types

typedef ACE_Handler_Cleanup_Strategy<
KEY, VALUE, CONTAINER > 
CLEANUP_STRATEGY
typedef ACE_Cleanup_Strategy<
KEY, VALUE, CONTAINER > 
CLEANUP_STRATEGY_BASE

Public Methods

 ACE_Handler_Caching_Utility (ACE_Cleanup_Strategy< KEY, VALUE, CONTAINER > *cleanup_strategy=0, int delete_cleanup_strategy=0)
 Constructor. More...

 ~ACE_Handler_Caching_Utility (void)
 Destructor. More...

int clear_cache (CONTAINER &container, double purge_percent)

Protected Methods

void minimum (CONTAINER &container, KEY *&key_to_remove, VALUE *&value_to_remove)

Protected Attributes

CLEANUP_STRATEGY_BASEcleanup_strategy_
 The cleanup strategy which can be used to destroy the entries of the container. More...

int delete_cleanup_strategy_
 Whether the cleanup_strategy should be destroyed or not. More...


Private Methods

void operator= (const ACE_Handler_Caching_Utility< KEY, VALUE, CONTAINER, ITERATOR, ATTRIBUTES > &)
 ACE_Handler_Caching_Utility (const ACE_Handler_Caching_Utility< KEY, VALUE, CONTAINER, ITERATOR, ATTRIBUTES > &)

Detailed Description

template<class KEY, class VALUE, class CONTAINER, class ITERATOR, class ATTRIBUTES>
class ACE_Handler_Caching_Utility< KEY, VALUE, CONTAINER, ITERATOR, ATTRIBUTES >

Defines a helper class for the Caching Strategies.

This class defines the methods commonly used by the different caching strategies. For instance: <clear_cache> method which decides and purges the entry from the container. Note: This class helps in the caching_strategies using a container containing entries of <KEY, HANDLER> kind where the HANDLER contains the caching attributes which help in deciding the entries to be purged. The Cleanup_Strategy is the callback class to which the entries to be cleaned up will be delegated.

Definition at line 226 of file Caching_Utility_T.h.


Member Typedef Documentation

template<class KEY, class VALUE, class CONTAINER, class ITERATOR, class ATTRIBUTES>
typedef ACE_Handler_Cleanup_Strategy<KEY, VALUE, CONTAINER> ACE_Handler_Caching_Utility::CLEANUP_STRATEGY
 

Definition at line 230 of file Caching_Utility_T.h.

template<class KEY, class VALUE, class CONTAINER, class ITERATOR, class ATTRIBUTES>
typedef ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> ACE_Handler_Caching_Utility::CLEANUP_STRATEGY_BASE
 

Definition at line 231 of file Caching_Utility_T.h.


Constructor & Destructor Documentation

template<class KEY, class VALUE, class CONTAINER, class ITERATOR, class ATTRIBUTES>
ACE_Handler_Caching_Utility< KEY, VALUE, CONTAINER, ITERATOR, ATTRIBUTES >::ACE_Handler_Caching_Utility ACE_Cleanup_Strategy< KEY, VALUE, CONTAINER > *    cleanup_strategy = 0,
int    delete_cleanup_strategy = 0
 

Constructor.

Definition at line 368 of file Caching_Utility_T.cpp.

References ACE_NEW, and delete_cleanup_strategy_.

00370   : cleanup_strategy_ (cleanup_strategy),
00371     delete_cleanup_strategy_ (delete_cleanup_strategy)
00372 {
00373   if (cleanup_strategy == 0)
00374     {
00375       ACE_NEW (this->cleanup_strategy_,
00376                CLEANUP_STRATEGY);
00377       this->delete_cleanup_strategy_ = 1;
00378     }
00379 }

template<class KEY, class VALUE, class CONTAINER, class ITERATOR, class ATTRIBUTES>
ACE_Handler_Caching_Utility< KEY, VALUE, CONTAINER, ITERATOR, ATTRIBUTES >::~ACE_Handler_Caching_Utility void   
 

Destructor.

Definition at line 382 of file Caching_Utility_T.cpp.

References cleanup_strategy_, and delete_cleanup_strategy_.

00383 {
00384   if (this->delete_cleanup_strategy_)
00385     delete this->cleanup_strategy_;
00386 }

template<class KEY, class VALUE, class CONTAINER, class ITERATOR, class ATTRIBUTES>
ACE_Handler_Caching_Utility< KEY, VALUE, CONTAINER, ITERATOR, ATTRIBUTES >::ACE_Handler_Caching_Utility const ACE_Handler_Caching_Utility< KEY, VALUE, CONTAINER, ITERATOR, ATTRIBUTES > &    [private]
 


Member Function Documentation

template<class KEY, class VALUE, class CONTAINER, class ITERATOR, class ATTRIBUTES>
int ACE_Handler_Caching_Utility< KEY, VALUE, CONTAINER, ITERATOR, ATTRIBUTES >::clear_cache CONTAINER &    container,
double    purge_percent
 

Purge entries from the <container>. The Cleanup_Strategy will do the actual job of cleanup once the entries to be cleaned up are decided.

Definition at line 389 of file Caching_Utility_T.cpp.

References ACE_MAX, ACE_Cleanup_Strategy::cleanup, cleanup_strategy_, and minimum.

00391 {
00392   // Check that the purge_percent is non-zero.
00393   if (purge_percent == 0)
00394     return 0;
00395 
00396   // Get the number of entries in the container.
00397   size_t current_map_size = container.current_size ();
00398 
00399   // Also whether the number of entries in the cache is just one!
00400   // Oops! then there is no way out but exiting. So return an error.
00401   if (current_map_size == 0)
00402     return 0;
00403 
00404   // Calculate the no of entries to remove from the cache depending
00405   // upon the <purge_percent>.
00406   size_t entries_to_remove
00407     = ACE_MAX (ACE_static_cast (size_t, 1),
00408                ACE_static_cast(size_t,
00409                                ACE_static_cast(double, purge_percent)
00410                                / 100 * current_map_size));
00411 
00412   KEY *key_to_remove = 0;
00413   VALUE *value_to_remove = 0;
00414 
00415   for (size_t i = 0; i < entries_to_remove ; ++i)
00416     {
00417       this->minimum (container,
00418                      key_to_remove,
00419                      value_to_remove);
00420 
00421       if (this->cleanup_strategy_->cleanup (container,
00422                                             key_to_remove,
00423                                             value_to_remove) == -1)
00424         return -1;
00425     }
00426 
00427   return 0;
00428 }

template<class KEY, class VALUE, class CONTAINER, class ITERATOR, class ATTRIBUTES>
void ACE_Handler_Caching_Utility< KEY, VALUE, CONTAINER, ITERATOR, ATTRIBUTES >::minimum CONTAINER &    container,
KEY *&    key_to_remove,
VALUE *&    value_to_remove
[protected]
 

Find the entry with minimum caching attributes. This is handler specific since this utility is to be used very specifically for handler who have caching_attributes for server side acched connection management.

Definition at line 431 of file Caching_Utility_T.cpp.

Referenced by clear_cache.

00434 {
00435   // Starting values.
00436   ITERATOR iter = container.begin ();
00437   ITERATOR end = container.end ();
00438   ATTRIBUTES min = (*iter).int_id_->caching_attributes ();
00439   key_to_remove = &(*iter).ext_id_;
00440   value_to_remove = &(*iter).int_id_;
00441 
00442   // The iterator moves thru the container searching for the entry
00443   // with the lowest ATTRIBUTES.
00444   for (++iter;
00445        iter != end;
00446        ++iter)
00447     {
00448       if (min > (*iter).int_id_->caching_attributes () &&
00449           (*iter).int_id_->active () != 1)
00450         {
00451           // Ah! an item with lower ATTTRIBUTES...
00452           min = (*iter).int_id_->caching_attributes ();
00453           key_to_remove = &(*iter).ext_id_;
00454           value_to_remove = &(*iter).int_id_;
00455         }
00456     }
00457 }

template<class KEY, class VALUE, class CONTAINER, class ITERATOR, class ATTRIBUTES>
void ACE_Handler_Caching_Utility< KEY, VALUE, CONTAINER, ITERATOR, ATTRIBUTES >::operator= const ACE_Handler_Caching_Utility< KEY, VALUE, CONTAINER, ITERATOR, ATTRIBUTES > &    [private]
 


Member Data Documentation

template<class KEY, class VALUE, class CONTAINER, class ITERATOR, class ATTRIBUTES>
CLEANUP_STRATEGY_BASE* ACE_Handler_Caching_Utility::cleanup_strategy_ [protected]
 

The cleanup strategy which can be used to destroy the entries of the container.

Definition at line 262 of file Caching_Utility_T.h.

Referenced by clear_cache, and ~ACE_Handler_Caching_Utility.

template<class KEY, class VALUE, class CONTAINER, class ITERATOR, class ATTRIBUTES>
int ACE_Handler_Caching_Utility::delete_cleanup_strategy_ [protected]
 

Whether the cleanup_strategy should be destroyed or not.

Definition at line 265 of file Caching_Utility_T.h.

Referenced by ACE_Handler_Caching_Utility, and ~ACE_Handler_Caching_Utility.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 12:48:23 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002