filmout_display/include/state.hpp

65 lines
1.2 KiB
C++
Raw Normal View History

#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 width;
uint64_t height;
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);
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, width, height }; }
bool isError () { return ERROR; }
void setActive () { active = true; }
bool isActive () { return active; }
};
#endif