You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
811 B
43 lines
811 B
4 months ago
|
#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();
|
||
|
bool GetStatesJson(std::string& json, bool delta = false);
|
||
|
void Invoke(const cJSON* command);
|
||
|
|
||
|
private:
|
||
|
ThingManager() = default;
|
||
|
~ThingManager() = default;
|
||
|
|
||
|
std::vector<Thing*> things_;
|
||
|
std::map<std::string, std::string> last_states_;
|
||
|
};
|
||
|
|
||
|
|
||
|
} // namespace iot
|
||
|
|
||
|
#endif // THING_MANAGER_H
|