31 lines
961 B
C++
31 lines
961 B
C++
// NB! A lot of comments in .h and .cpp files were auto generated by CoPilot. Applicable comments have been retained, others removed.
|
|
|
|
#ifndef __SOLAR_CBF_CACHE
|
|
#define __SOLAR_CBF_CACHE
|
|
#include <utility>
|
|
#include <map>
|
|
#include "esphome.h"
|
|
#include "cbf_store_pylon.h"
|
|
#include "cbf_cache_item.h"
|
|
using namespace esphome;
|
|
|
|
namespace solar
|
|
{
|
|
class cbf_cache {
|
|
private:
|
|
std::map<uint32_t, cbf_cache_item> cache_map; // map of CAN IDs to cache items
|
|
public:
|
|
cbf_cache() = default;
|
|
void clear();
|
|
int size() const;
|
|
bool hasitem(uint32_t can_id) const;
|
|
cbf_cache_item& getitem(uint32_t can_id);
|
|
const cbf_cache_item& getitem(uint32_t can_id) const;
|
|
// Add a new item to the cache or update an existing one
|
|
bool additem(const cbf_store& item);
|
|
// using default (compiler auto generated) copy and move constructors and assignment operators
|
|
};
|
|
|
|
} // namespace solar
|
|
|
|
#endif // __SOLAR_CBF_CACHE
|