Falcon
Loading...
Searching...
No Matches
commandsource.hpp
1// ---------------------------------------------------------------------
2// This file is part of falcon-core.
3//
4// Copyright (C) 2015, 2016, 2017 Neuro-Electronics Research Flanders
5//
6// Falcon-server is free software: you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
8// the Free Software Foundation, either version 3 of the License, or
9// (at your option) any later version.
10//
11// Falcon-server is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15//
16// You should have received a copy of the GNU General Public License
17// along with falcon-core. If not, see <http://www.gnu.org/licenses/>.
18// ---------------------------------------------------------------------
19
20#pragma once
21
22#include <cstring>
23#include <deque>
24#include <string>
25#include <zmq.hpp>
26#include "utilities/keyboard.hpp"
27
28namespace commands {
29
31 public:
32 virtual bool getcommand(std::deque<std::string>& command) { return false; }
33 virtual bool sendreply(const std::deque<std::string>& command, std::deque<std::string>& reply) {
34 return false;
35 }
36};
37
39 public:
40 void AddCommand(const std::deque<std::string>& command);
41 bool getcommand(std::deque<std::string>& command);
42 bool sendreply(const std::deque<std::string>& command, std::deque<std::string>& reply);
43
44 protected:
45 std::deque<std::deque<std::string>> queued_commands_;
46};
47
48class KeyboardCommands : public CommandSource {
49 public:
50 KeyboardCommands();
51 ~KeyboardCommands();
52
53 bool getcommand(std::deque<std::string>& command);
54 bool sendreply(const std::deque<std::string>& command, std::deque<std::string>& reply);
55};
56
57class ZMQCommands : public CommandSource {
58 public:
59 zmq::socket_t* socket;
60
61 ZMQCommands(zmq::context_t& context, int port);
62 ~ZMQCommands();
63
64 bool getcommand(std::deque<std::string>& command);
65 bool sendreply(const std::deque<std::string>& command, std::deque<std::string>& reply);
66};
67} // namespace commands
Definition commandsource.hpp:38
Definition commandsource.hpp:30