Files
xiaozhi-esp32/main/iot/thing_manager.h

43 lines
811 B
C
Raw Normal View History

2024-12-06 11:08:49 +08:00
#ifndef THING_MANAGER_H
#define THING_MANAGER_H
#include "thing.h"
#include <cJSON.h>
#include <vector>
#include <memory>
#include <functional>
#include <map>
namespace iot {
class ThingManager {
public:
static ThingManager& GetInstance() {
static ThingManager instance;
return instance;
}
ThingManager(const ThingManager&) = delete;
ThingManager& operator=(const ThingManager&) = delete;
void AddThing(Thing* thing);
std::string GetDescriptorsJson();
2025-03-08 04:04:40 +08:00
bool GetStatesJson(std::string& json, bool delta = false);
2024-12-06 11:08:49 +08:00
void Invoke(const cJSON* command);
private:
ThingManager() = default;
~ThingManager() = default;
std::vector<Thing*> things_;
2025-03-08 04:04:40 +08:00
std::map<std::string, std::string> last_states_;
2024-12-06 11:08:49 +08:00
};
} // namespace iot
#endif // THING_MANAGER_H