34 #ifndef ROSSERIAL_SERVER_ASYNC_READ_BUFFER_H 35 #define ROSSERIAL_SERVER_ASYNC_READ_BUFFER_H 37 #include <boost/bind.hpp> 38 #include <boost/asio.hpp> 39 #include <boost/function.hpp> 46 template<
typename AsyncReadStream>
51 boost::function<
void(
const boost::system::error_code&)> error_callback)
54 mem_.resize(capacity);
75 " bytes, but buffer capacity is only " <<
mem_.size() <<
".");
76 error_callback_(boost::system::errc::make_error_code(boost::system::errc::no_buffer_space));
83 if (transfer_bytes > 0)
95 boost::asio::async_read(
stream_,
97 boost::asio::transfer_at_least(transfer_bytes),
99 boost::asio::placeholders::error,
100 boost::asio::placeholders::bytes_transferred));
130 void callback(
const boost::system::error_code& error,
size_t bytes_transferred)
138 if (error == boost::asio::error::operation_aborted)
195 #endif // ROSSERIAL_SERVER_ASYNC_READ_BUFFER_H void callback(const boost::system::error_code &error, size_t bytes_transferred)
The internal callback which is called by the boost::asio::async_read invocation in the public read me...
#define ROS_DEBUG_STREAM_NAMED(name, args)
#define ROS_ERROR_STREAM_NAMED(name, args)
std::vector< uint8_t > mem_
AsyncReadStream & stream_
AsyncReadBuffer(AsyncReadStream &s, size_t capacity, boost::function< void(const boost::system::error_code &)> error_callback)
boost::function< void(ros::serialization::IStream &)> read_success_callback_
#define ROS_ASSERT_MSG(cond,...)
boost::function< void(const boost::system::error_code &)> error_callback_
void read(size_t requested_bytes, boost::function< void(ros::serialization::IStream &)> callback)
Commands a fixed number of bytes from the buffer. This may be fulfilled from existing buffer content...
void callSuccessCallback()
Calls the user's callback. This is a separate function because it gets called from two places...
size_t read_requested_bytes_