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>
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 CacheMethod * | clone ()=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 | |
| Cache * | cache |
| The Cache this CacheMethod will use. | |
| ProtocolLayer * | protocol |
| 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. | |
Base class for a method of caching frames. Works in partnership with Cache to cache frames. CacheMethod determains how to cache the frames.
| 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.
| list | The set of Ids. |
References waiters.
| void TPProto::CacheMethod::getAllIds | ( | const IdSetCallback & | cb | ) |
Gets all the ids.
| 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] |
Gets a item from the cache by Id.
Returned by call to Cache::newItem or Cache::existingItem
| id | The Id of the item to get. |
Implemented in TPProto::CacheNoneMethod.
Referenced by TPProto::BoardCache::requestBoard(), TPProto::CommandDescCache::requestCommandDescription(), TPProto::ComponentCache::requestComponent(), and TPProto::ObjectCache::requestObject().
| 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.
| 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.
| 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.
| 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.
| 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.
| cb | The IdSetCallback to call when the IdSet changes. |
References getIdList(), waiters, and watchers.
Referenced by TPProto::CommandDescCache::watchCommandTypes().
1.6.1