Files
UvosSmartHomeInterface/src/items/itemstore.h
2022-04-15 13:28:47 +02:00

42 lines
767 B
C++

#pragma once
#include <vector>
#include <memory>
#include "item.h"
#include "../sensors/sensor.h"
#include <QJsonObject>
class ItemStore: public QObject
{
Q_OBJECT
private:
std::vector< std::shared_ptr<Item> > items_;
public:
ItemStore(QObject *parent = nullptr);
virtual ~ItemStore() {}
inline std::vector< std::shared_ptr<Item> >* getItems()
{
return &items_;
}
void store(QJsonObject &json);
void load(const QJsonObject &json);
void clear();
signals:
void itemDeleted(ItemData item);
void itemAdded(std::weak_ptr<Item> Item);
public slots:
void removeItem(const ItemData& item);
void addItem(std::shared_ptr<Item> item);
void addItems(const std::vector<std::shared_ptr<Item>>& itemsIn);
void itemStateChanged(const ItemData& item);
};