GroupStateCache.h 619 B

12345678910111213141516171819202122232425262728293031
  1. #include <LinkedList.h>
  2. #include <GroupStateStore.h>
  3. #ifndef _GROUP_STATE_CACHE_H
  4. #define _GROUP_STATE_CACHE_H
  5. struct GroupCacheNode {
  6. GroupCacheNode() {}
  7. GroupCacheNode(const GroupId& id, const GroupState& state)
  8. : id(id), state(state) { }
  9. GroupId id;
  10. GroupState state;
  11. };
  12. class GroupStateCache : public GroupStateStore {
  13. public:
  14. GroupStateCache(const size_t maxSize);
  15. GroupState* get(const GroupId& id);
  16. GroupState* set(const GroupId& id, const GroupState& state);
  17. private:
  18. LinkedList<GroupCacheNode*> cache;
  19. const size_t maxSize;
  20. GroupState* getInternal(const GroupId& id);
  21. };
  22. #endif