#ifndef STATE_h #define STATE_h #include "json/single_include/nlohmann/json.hpp" #include #include using json = nlohmann::json; using namespace std; enum Action { NONE, LOAD, DISPLAY, STOP }; enum Mode { RGB, BW, INVERT, BW_INVERT, RGB_CHANNELS, INVERT_CHANNELS }; class State { private: Action action = STOP; Mode mode = RGB; string image; vector exposure = {}; uint64_t x; uint64_t y; uint64_t w; uint64_t h; bool active = false; bool ERROR = false; void error(); bool imageExists(string& image); void setAction(json& msgData); void setImage(json& msgData); void setMode(json& msgData); void setExposure(json& msgData); void setNoExposure(); void setPosition(json& msgData); void setActive () { active = true; } public : State(); void receiveMessage(string msgString); string createMessage(bool success, uint64_t data); Action getAction () { return action; } Mode getMode() { return mode; } string getImage () { return image; } vector getExposure() { return exposure; } vector getPosition() { return { x, y, w, h }; } bool isError () { return ERROR; } void setInactive () { active = false; } bool isActive () { return active; } }; #endif