#pragma once #include #include #include #include #include #include #include extern "C" { #define AFB_BINDING_VERSION 2 #include }; struct TimedEvent { int interval; afb_event event; std::string name; std::string eventName; }; struct Property { /** * alternatively, instead of a value per type, we could use boost::any, or in c++17 variant. */ std::string type; std::string description; std::string lowMessageName; int interval; bool value_bool; std::string value_string; double value_double; int value_int; }; class High { public: High(); void treatMessage(json_object *message); bool subscribe(afb_req request); bool unsubscribe(afb_req request); bool get(afb_req request, json_object **json); void tick(sd_event_source *source, const long &now, void *interv); void startTimer(const int &t); ~High(); void parseConfigAndSubscribe(); static bool startsWith(const std::string &s, const std::string &val); static void callBackFromSubscribe(void *handle, int iserror, json_object *result); private: std::map events; std::map> timedEvents; std::map> registeredObjects; std::map> lowMessagesToObjects; std::set timers; std::string generateId() const; json_object *generateJson(const std::string &messageObject, std::vector *fields = NULL); };