17 #ifndef SCIP2_PROTOCOL_H 18 #define SCIP2_PROTOCOL_H 20 #include <boost/asio.hpp> 21 #include <boost/bind/bind.hpp> 38 boost::asio::streambuf &buf,
39 const boost::posix_time::ptime &time_read)
41 std::istream stream(&buf);
42 std::string echo_back;
43 if (!std::getline(stream, echo_back))
45 std::cerr <<
"Failed to get echo back" << std::endl;
49 if (!std::getline(stream, status))
51 std::cerr <<
"Failed to get status" << std::endl;
59 while (std::getline(stream, line))
65 using Ptr = std::shared_ptr<Protocol>;
68 : connection_(connection)
70 connection_->registerReceiveCallback(
75 const std::string &command,
78 connection_->send(command +
"\n", cb);
81 template <
typename TResponse>
90 #endif // SCIP2_PROTOCOL_H void cbReceive(boost::asio::streambuf &buf, const boost::posix_time::ptime &time_read)
ResponseProcessor response_processor_
std::shared_ptr< Connection > Ptr
boost::function< void(const boost::posix_time::ptime &)> CallbackSend
Protocol(Connection::Ptr connection)
Connection::Ptr connection_
void registerCallback(typename TResponse::Callback cb)
std::shared_ptr< Protocol > Ptr
void sendCommand(const std::string &command, Connection::CallbackSend cb=Connection::CallbackSend())
void registerCallback(typename TResponse::Callback cb)