26 boost::property_tree::ptree
const &cfg,
35 std::array<char, 4096> txt;
36 std::cin.getline(&txt[0], 4096);
37 std::string tmp(&txt[0]);
38 std::stringstream ss(tmp);
42 std::vector<std::string> cmds;
51 endpoints_[target] = std::shared_ptr<zmqpp::socket>(
52 new zmqpp::socket(
ctx_, zmqpp::socket_type::req));
53 endpoints_[target]->connect(
"inproc://" + target);
56 DEBUG(
"Read {" << std::string(&txt[0]) <<
"}, target = " << target);
65 static bool is_number(
const std::string &s)
67 return !s.empty() && std::find_if(s.begin(), s.end(), [](
char c) {
68 return !std::isdigit(c);
73 const std::vector<std::string> &cmds)
77 for (
const auto &str : cmds)
82 std::stringstream ss(str);
95 p.add(*target.get(), zmqpp::poller::poll_in);
98 WARN(
"No response from target (" << target <<
")");
107 INFO(
"response = " << rep);
std::map< std::string, std::shared_ptr< zmqpp::socket > > endpoints_
StdinControllerModule(zmqpp::context &ctx, zmqpp::socket *pipe, boost::property_tree::ptree const &cfg, CoreUtilsPtr utils)
All modules that provides features to Leosac shall be in this namespace.
Base class for module implementation.
zmqpp::context & ctx_
A reference to the ZeroMQ context in case you need it to create additional socket.
void handleStdin(void)
We can read from standard input;.
zmqpp::reactor reactor_
The reactor object we poll() on in the main loop.
std::shared_ptr< CoreUtils > CoreUtilsPtr
bool send_request(std::shared_ptr< zmqpp::socket > target, const std::vector< std::string > &cmds)
Send the request to the target and handle the response.