GroupStateCache.h 666 B

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