TPProto::CacheMethod Class Reference

Base class for a method of caching frames. Works in partnership with Cache to cache frames. CacheMethod determains how to cache the frames. More...

#include <cachemethod.h>

Inheritance diagram for TPProto::CacheMethod:
TPProto::CacheNoneMethod

List of all members.

Public Member Functions

 CacheMethod ()
 Default Constructor.
 CacheMethod (const CacheMethod &rhs)
 Copy Constructor, sets all fields to NULL. Subclasses should call this, and initialise any fields it might have.
virtual ~CacheMethod ()
 Destructor, virtual.
virtual void update ()=0
 Called when the client wants to update the cache. Can do nothing.
void setCache (Cache *c)
 Sets the Cache object this CacheMethod is for. CacheMethods can (and need to) use the Cache to get useful information.
void setProtocolLayer (ProtocolLayer *pl)
 Sets the ProtocolLayer to use.
virtual void getById (uint32_t id)=0
 Gets a item from the cache by Id.
virtual void markInvalid (uint32_t id)=0
 Marks an item as invalid. If a method wishes to it can refetch it from the server. The pointer to the frame should not be consided valid, and does not get deleted by the CacheMethod.
void getAllIds (const IdSetCallback &cb)
 Gets all the ids.
boost::signals::connection watchAllIds (const IdSetCallback &cb)
 Add an IdSetCallback to watch for changes to IdSet.
virtual CacheMethodclone ()=0
 Returns an empty clone of this CacheMethod. body should be return new CacheMethodNameCopyConstructor(this);.

Protected Member Functions

virtual void getIdList ()=0
 Called to retreve the list of Ids from the server.
void newIdList (std::set< uint32_t > list)
 Sends a new set of Ids from the cache. The list is sent to all the waiters and the watches.
void existingList (std::set< uint32_t > list)
 Sends an existing list of Ids from the cache. The list is only sent to the waiters, as there are no changes the watchers would be interested it.

Protected Attributes

Cachecache
 The Cache this CacheMethod will use.
ProtocolLayerprotocol
 The ProtocolLayer that will be used.
IdSetSignal waiters
 The waiters are waiting for the IdSet, and are removed after it is send to them.
IdSetSignal watchers
 The watches are sent the signal each timer the IdSet changes.

Detailed Description

Base class for a method of caching frames. Works in partnership with Cache to cache frames. CacheMethod determains how to cache the frames.


Member Function Documentation

void TPProto::CacheMethod::existingList ( std::set< uint32_t >  list  )  [protected]

Sends an existing list of Ids from the cache. The list is only sent to the waiters, as there are no changes the watchers would be interested it.

Parameters:
list The set of Ids.

References waiters.

void TPProto::CacheMethod::getAllIds ( const IdSetCallback &  cb  ) 

Gets all the ids.

Parameters:
cb The callback to send the set of ids to..

References getIdList(), and waiters.

Referenced by TPProto::BoardCache::requestBoardIds(), TPProto::CommandDescCache::requestCommandTypes(), and TPProto::ObjectCache::requestObjectIds().

virtual void TPProto::CacheMethod::getById ( uint32_t  id  )  [pure virtual]
virtual void TPProto::CacheMethod::markInvalid ( uint32_t  id  )  [pure virtual]

Marks an item as invalid. If a method wishes to it can refetch it from the server. The pointer to the frame should not be consided valid, and does not get deleted by the CacheMethod.

Parameters:
id The id of the item that is invalid.

Implemented in TPProto::CacheNoneMethod.

Referenced by TPProto::BoardCache::invalidateBoard(), TPProto::CategoryCache::invalidateCategory(), TPProto::DesignCache::invalidateDesign(), and TPProto::ObjectCache::invalidateObject().

void TPProto::CacheMethod::newIdList ( std::set< uint32_t >  list  )  [protected]

Sends a new set of Ids from the cache. The list is sent to all the waiters and the watches.

Parameters:
list The set of Ids.

References waiters, and watchers.

Referenced by TPProto::CacheNoneMethod::receiveIdList().

void TPProto::CacheMethod::setCache ( Cache c  ) 

Sets the Cache object this CacheMethod is for. CacheMethods can (and need to) use the Cache to get useful information.

Parameters:
c The Cache this cache method will be used for.

References cache.

Referenced by TPProto::Cache::Cache(), and TPProto::Cache::setCacheMethod().

void TPProto::CacheMethod::setProtocolLayer ( ProtocolLayer pl  ) 

Sets the ProtocolLayer to use.

Parameters:
pl The ProtocolLayer to use.

References protocol.

Referenced by TPProto::Cache::setCacheMethod(), and TPProto::Cache::setProtocolLayer().

boost::signals::connection TPProto::CacheMethod::watchAllIds ( const IdSetCallback &  cb  ) 

Add an IdSetCallback to watch for changes to IdSet.

Parameters:
cb The IdSetCallback to call when the IdSet changes.
Returns:
Connection to the signal for the callback. Allows management of the Signal connection.

References getIdList(), waiters, and watchers.

Referenced by TPProto::CommandDescCache::watchCommandTypes().


The documentation for this class was generated from the following files:

Generated on Sun Mar 14 01:15:05 2010 for libtpproto-cpp by  doxygen 1.6.1