30 template <
typename T> T
parseEval(
const std::string &code) {
32 auto result = stream.
read<T>();
38 void setValue(
const std::string &name,
const T &value) {
41 stream.
write(TYPEID<T>());
52 stream.
write(TYPEID<T>());
56 auto type = stream.
read<int32_t>();
57 if (type != TYPEID<T>())
59 auto result = stream.
read<T>();
64 template<
typename R,
typename... Params>
65 void setCallback(
const std::string &name, std::function<R(Params...)> &callback) {
67 int32_t result_type = TYPEID<R>();
68 size_t paramcount =
sizeof...(Params);
72 stream.
write(callback_id);
73 stream.
write(result_type);
74 stream.
write(paramcount);
79 std::function<void(void)> func = std::bind(callback_helper::call<R, Params...>, std::ref(callback), std::ref(stream));
87 void initPlot(uint32_t width=800, uint32_t height=600);
90 void runScript(
const std::string code, int32_t result_typeid);
92 char readReply(
bool accept_ok =
true,
bool accept_value =
false);
98 std::map<uint32_t, std::function<void(void)> >
callbacks;
RInsideClient(BinaryStream &stream)
bool had_unrecoverable_error
void unrecoverable_error(const std::string &error)
void setCallback(const std::string &name, std::function< R(Params...)> &callback)
char readReply(bool accept_ok=true, bool accept_value=false)
uint32_t next_callback_id
void setValue(const std::string &name, const T &value)
void write(const char *buffer, size_t len)
T parseEval(const std::string &code)
const char RIS_CMD_SETVALUE
T getValue(const std::string &name)
void initPlot(uint32_t width=800, uint32_t height=600)
std::map< uint32_t, std::function< void(void)> > callbacks
void writeCommand(char command)
const char RIS_CMD_GETVALUE
std::string getConsoleOutput()
void runScript(const std::string code, int32_t result_typeid)
size_t read(char *buffer, size_t len)
void parseEvalQ(const std::string &code)
const char RIS_CMD_SETCALLBACK