filmout_display/include/state.hpp

66 lines
1.2 KiB
C++

#ifndef STATE_h
#define STATE_h
#include "json/single_include/nlohmann/json.hpp"
#include <iostream>
#include <sys/stat.h>
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<uint64_t> 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 setPosition(json& msgData);
void setActive () { active = true; }
public :
State();
void receiveMessage(string msgString);
string createMessage(bool success);
Action getAction () { return action; }
Mode getMode() { return mode; }
string getImage () { return image; }
vector<uint64_t> getExposure() { return exposure; }
vector<uint64_t> getPosition() { return { x, y, w, h }; }
bool isError () { return ERROR; }
void setInactive () { active = false; }
bool isActive () { return active; }
};
#endif