23 #ifndef ASIOLineBasedInterface20100715H 24 #define ASIOLineBasedInterface20100715H 26 #include <boost/array.hpp> 27 #include <boost/asio.hpp> 28 #include <boost/bind.hpp> 29 #include <boost/thread.hpp> 34 #include "goby/common/time.h" 35 #include "goby/util/protobuf/linebasedcomms.pb.h" 55 bool active() {
return active_; }
68 bool readline(std::string* s, AccessOrder order = OLDEST_FIRST);
72 void write(
const std::string& s)
84 void set_delimiter(
const std::string& s) { delimiter_ = s; }
85 std::string delimiter()
const {
return delimiter_; }
87 boost::asio::io_service& io_service() {
return io_service_; }
91 virtual void do_start() = 0;
93 virtual void do_close(
const boost::system::error_code& error) = 0;
95 void set_active(
bool active) { active_ = active; }
97 std::string delimiter_;
98 boost::asio::io_service io_service_;
99 std::deque<protobuf::Datagram> in_;
100 boost::mutex in_mutex_;
104 std::string& delimiter() {
return delimiter_; }
105 std::deque<goby::util::protobuf::Datagram>& in() {
return in_; }
106 boost::mutex& in_mutex() {
return in_mutex_; }
112 IOLauncher(boost::asio::io_service& io_service)
113 : io_service_(io_service), t_(boost::bind(&boost::asio::io_service::run, &io_service))
124 boost::asio::io_service& io_service_;
128 boost::shared_ptr<IOLauncher> io_launcher_;
130 boost::asio::io_service::work work_;
bool readline(std::string *s, AccessOrder order=OLDEST_FIRST)
returns string line (including delimiter)
The global namespace for the Goby project.
basic interface class for all the derived serial (and networking mimics) line-based nodes (serial...