add iot framework

This commit is contained in:
Terrence
2024-12-06 11:08:49 +08:00
parent 43b1046df5
commit d31901e9e5
27 changed files with 686 additions and 76 deletions

41
main/iot/thing_manager.h Normal file
View File

@@ -0,0 +1,41 @@
#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();
std::string GetStatesJson();
void Invoke(const cJSON* command);
private:
ThingManager() = default;
~ThingManager() = default;
std::vector<Thing*> things_;
};
} // namespace iot
#endif // THING_MANAGER_H