GroupStateCache.h 688 B

1234567891011121314151617181920212223242526272829303132333435
  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. ~GroupStateCache();
  16. GroupState* get(const BulbId& id);
  17. GroupState* set(const BulbId& id, const GroupState& state);
  18. BulbId getLru();
  19. bool isFull() const;
  20. ListNode<GroupCacheNode*>* getHead();
  21. private:
  22. LinkedList<GroupCacheNode*> cache;
  23. const size_t maxSize;
  24. GroupState* getInternal(const BulbId& id);
  25. };
  26. #endif