42 lines
1.8 KiB
C++
42 lines
1.8 KiB
C++
#ifndef __SOLAR_CBF_CACHE_ITEM
|
|
#define __SOLAR_CBF_CACHE_ITEM
|
|
#include <utility>
|
|
#include <map>
|
|
#include "esphome.h"
|
|
#include "cbf_store_pylon.h"
|
|
using namespace esphome;
|
|
|
|
namespace solar
|
|
{
|
|
class cbf_cache_item {
|
|
private:
|
|
const int storecount = 2;
|
|
public:
|
|
std::shared_ptr<cbf_store> store0;
|
|
std::shared_ptr<cbf_store> store1;
|
|
|
|
cbf_cache_item(); // to allow object to be used as a value element in map operator[] method
|
|
cbf_cache_item(const cbf_store& store0);
|
|
void clear();
|
|
void swap(cbf_cache_item &s);
|
|
bool update(const cbf_store& newitem);
|
|
cbf_store::cbf_updateresult update(const cbf_store& newitem, const int *comparecolumns, int store_selector);
|
|
const cb_frame& get_frame() const; // returns the most recent valid frame
|
|
const cbf_store& get_store() const; // returns the most recent valid store
|
|
virtual std::string tag0(const std::string& prefix = "") const;
|
|
virtual std::string tag1(const std::string& prefix = "") const;
|
|
virtual std::string tag(const std::string& prefix = "") const;
|
|
virtual std::string to_string() const;
|
|
virtual std::string st0_tostring() const; // string of store 0
|
|
virtual std::string st1_tostring() const; // string of store 1
|
|
// the default copy and move constructors and assignment operators are fine
|
|
// because shared_ptr takes care of the underlying memory management
|
|
cbf_cache_item(const cbf_cache_item& b) = default;
|
|
cbf_cache_item& operator=(const cbf_cache_item& b) = default;
|
|
cbf_cache_item(cbf_cache_item&& src) = default;
|
|
cbf_cache_item& operator=(cbf_cache_item&& src) = default;
|
|
virtual ~cbf_cache_item() = default; // virtual destructor for base class
|
|
};
|
|
|
|
} // namespace solar
|
|
#endif // __SOLAR_CBF_CACHE
|