Solar/cbf_cache_item.h
2025-08-23 16:59:05 +02:00

39 lines
1.5 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);
bool update(const cbf_store& newitem, bool& publish, const int *comparecolumns, int store_selector);
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;
// 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