summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '3rdParty/Boost/src/boost/asio/basic_serial_port.hpp')
-rw-r--r--3rdParty/Boost/src/boost/asio/basic_serial_port.hpp161
1 files changed, 116 insertions, 45 deletions
diff --git a/3rdParty/Boost/src/boost/asio/basic_serial_port.hpp b/3rdParty/Boost/src/boost/asio/basic_serial_port.hpp
index 744fd3b..31ee955 100644
--- a/3rdParty/Boost/src/boost/asio/basic_serial_port.hpp
+++ b/3rdParty/Boost/src/boost/asio/basic_serial_port.hpp
@@ -2,7 +2,7 @@
// basic_serial_port.hpp
// ~~~~~~~~~~~~~~~~~~~~~
//
-// Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2008 Rep Invariant Systems, Inc. (info@repinvariant.com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
@@ -23,6 +23,7 @@
#include <string>
#include <boost/asio/basic_io_object.hpp>
+#include <boost/asio/detail/handler_type_requirements.hpp>
#include <boost/asio/detail/throw_error.hpp>
#include <boost/asio/error.hpp>
#include <boost/asio/serial_port_base.hpp>
@@ -48,8 +49,12 @@ class basic_serial_port
public serial_port_base
{
public:
+ /// (Deprecated: Use native_handle_type.) The native representation of a
+ /// serial port.
+ typedef typename SerialPortService::native_handle_type native_type;
+
/// The native representation of a serial port.
- typedef typename SerialPortService::native_type native_type;
+ typedef typename SerialPortService::native_handle_type native_handle_type;
/// A basic_serial_port is always the lowest layer.
typedef basic_serial_port<SerialPortService> lowest_layer_type;
@@ -82,8 +87,8 @@ public:
: basic_io_object<SerialPortService>(io_service)
{
boost::system::error_code ec;
- this->service.open(this->implementation, device, ec);
- boost::asio::detail::throw_error(ec);
+ this->get_service().open(this->get_implementation(), device, ec);
+ boost::asio::detail::throw_error(ec, "open");
}
/// Construct and open a basic_serial_port.
@@ -102,8 +107,8 @@ public:
: basic_io_object<SerialPortService>(io_service)
{
boost::system::error_code ec;
- this->service.open(this->implementation, device, ec);
- boost::asio::detail::throw_error(ec);
+ this->get_service().open(this->get_implementation(), device, ec);
+ boost::asio::detail::throw_error(ec, "open");
}
/// Construct a basic_serial_port on an existing native serial port.
@@ -119,13 +124,49 @@ public:
* @throws boost::system::system_error Thrown on failure.
*/
basic_serial_port(boost::asio::io_service& io_service,
- const native_type& native_serial_port)
+ const native_handle_type& native_serial_port)
: basic_io_object<SerialPortService>(io_service)
{
boost::system::error_code ec;
- this->service.assign(this->implementation, native_serial_port, ec);
- boost::asio::detail::throw_error(ec);
+ this->get_service().assign(this->get_implementation(),
+ native_serial_port, ec);
+ boost::asio::detail::throw_error(ec, "assign");
+ }
+
+#if defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
+ /// Move-construct a basic_serial_port from another.
+ /**
+ * This constructor moves a serial port from one object to another.
+ *
+ * @param other The other basic_serial_port object from which the move will
+ * occur.
+ *
+ * @note Following the move, the moved-from object is in the same state as if
+ * constructed using the @c basic_serial_port(io_service&) constructor.
+ */
+ basic_serial_port(basic_serial_port&& other)
+ : basic_io_object<SerialPortService>(
+ BOOST_ASIO_MOVE_CAST(basic_serial_port)(other))
+ {
+ }
+
+ /// Move-assign a basic_serial_port from another.
+ /**
+ * This assignment operator moves a serial port from one object to another.
+ *
+ * @param other The other basic_serial_port object from which the move will
+ * occur.
+ *
+ * @note Following the move, the moved-from object is in the same state as if
+ * constructed using the @c basic_serial_port(io_service&) constructor.
+ */
+ basic_serial_port& operator=(basic_serial_port&& other)
+ {
+ basic_io_object<SerialPortService>::operator=(
+ BOOST_ASIO_MOVE_CAST(basic_serial_port)(other));
+ return *this;
}
+#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
/// Get a reference to the lowest layer.
/**
@@ -166,8 +207,8 @@ public:
void open(const std::string& device)
{
boost::system::error_code ec;
- this->service.open(this->implementation, device, ec);
- boost::asio::detail::throw_error(ec);
+ this->get_service().open(this->get_implementation(), device, ec);
+ boost::asio::detail::throw_error(ec, "open");
}
/// Open the serial port using the specified device name.
@@ -182,7 +223,7 @@ public:
boost::system::error_code open(const std::string& device,
boost::system::error_code& ec)
{
- return this->service.open(this->implementation, device, ec);
+ return this->get_service().open(this->get_implementation(), device, ec);
}
/// Assign an existing native serial port to the serial port.
@@ -193,11 +234,12 @@ public:
*
* @throws boost::system::system_error Thrown on failure.
*/
- void assign(const native_type& native_serial_port)
+ void assign(const native_handle_type& native_serial_port)
{
boost::system::error_code ec;
- this->service.assign(this->implementation, native_serial_port, ec);
- boost::asio::detail::throw_error(ec);
+ this->get_service().assign(this->get_implementation(),
+ native_serial_port, ec);
+ boost::asio::detail::throw_error(ec, "assign");
}
/// Assign an existing native serial port to the serial port.
@@ -208,16 +250,17 @@ public:
*
* @param ec Set to indicate what error occurred, if any.
*/
- boost::system::error_code assign(const native_type& native_serial_port,
+ boost::system::error_code assign(const native_handle_type& native_serial_port,
boost::system::error_code& ec)
{
- return this->service.assign(this->implementation, native_serial_port, ec);
+ return this->get_service().assign(this->get_implementation(),
+ native_serial_port, ec);
}
/// Determine whether the serial port is open.
bool is_open() const
{
- return this->service.is_open(this->implementation);
+ return this->get_service().is_open(this->get_implementation());
}
/// Close the serial port.
@@ -231,8 +274,8 @@ public:
void close()
{
boost::system::error_code ec;
- this->service.close(this->implementation, ec);
- boost::asio::detail::throw_error(ec);
+ this->get_service().close(this->get_implementation(), ec);
+ boost::asio::detail::throw_error(ec, "close");
}
/// Close the serial port.
@@ -245,10 +288,11 @@ public:
*/
boost::system::error_code close(boost::system::error_code& ec)
{
- return this->service.close(this->implementation, ec);
+ return this->get_service().close(this->get_implementation(), ec);
}
- /// Get the native serial port representation.
+ /// (Deprecated: Use native_handle().) Get the native serial port
+ /// representation.
/**
* This function may be used to obtain the underlying representation of the
* serial port. This is intended to allow access to native serial port
@@ -256,7 +300,18 @@ public:
*/
native_type native()
{
- return this->service.native(this->implementation);
+ return this->get_service().native_handle(this->get_implementation());
+ }
+
+ /// Get the native serial port representation.
+ /**
+ * This function may be used to obtain the underlying representation of the
+ * serial port. This is intended to allow access to native serial port
+ * functionality that is not otherwise provided.
+ */
+ native_handle_type native_handle()
+ {
+ return this->get_service().native_handle(this->get_implementation());
}
/// Cancel all asynchronous operations associated with the serial port.
@@ -270,8 +325,8 @@ public:
void cancel()
{
boost::system::error_code ec;
- this->service.cancel(this->implementation, ec);
- boost::asio::detail::throw_error(ec);
+ this->get_service().cancel(this->get_implementation(), ec);
+ boost::asio::detail::throw_error(ec, "cancel");
}
/// Cancel all asynchronous operations associated with the serial port.
@@ -284,7 +339,7 @@ public:
*/
boost::system::error_code cancel(boost::system::error_code& ec)
{
- return this->service.cancel(this->implementation, ec);
+ return this->get_service().cancel(this->get_implementation(), ec);
}
/// Send a break sequence to the serial port.
@@ -297,8 +352,8 @@ public:
void send_break()
{
boost::system::error_code ec;
- this->service.send_break(this->implementation, ec);
- boost::asio::detail::throw_error(ec);
+ this->get_service().send_break(this->get_implementation(), ec);
+ boost::asio::detail::throw_error(ec, "send_break");
}
/// Send a break sequence to the serial port.
@@ -310,7 +365,7 @@ public:
*/
boost::system::error_code send_break(boost::system::error_code& ec)
{
- return this->service.send_break(this->implementation, ec);
+ return this->get_service().send_break(this->get_implementation(), ec);
}
/// Set an option on the serial port.
@@ -332,8 +387,8 @@ public:
void set_option(const SettableSerialPortOption& option)
{
boost::system::error_code ec;
- this->service.set_option(this->implementation, option, ec);
- boost::asio::detail::throw_error(ec);
+ this->get_service().set_option(this->get_implementation(), option, ec);
+ boost::asio::detail::throw_error(ec, "set_option");
}
/// Set an option on the serial port.
@@ -355,7 +410,8 @@ public:
boost::system::error_code set_option(const SettableSerialPortOption& option,
boost::system::error_code& ec)
{
- return this->service.set_option(this->implementation, option, ec);
+ return this->get_service().set_option(
+ this->get_implementation(), option, ec);
}
/// Get an option from the serial port.
@@ -378,8 +434,8 @@ public:
void get_option(GettableSerialPortOption& option)
{
boost::system::error_code ec;
- this->service.get_option(this->implementation, option, ec);
- boost::asio::detail::throw_error(ec);
+ this->get_service().get_option(this->get_implementation(), option, ec);
+ boost::asio::detail::throw_error(ec, "get_option");
}
/// Get an option from the serial port.
@@ -402,7 +458,8 @@ public:
boost::system::error_code get_option(GettableSerialPortOption& option,
boost::system::error_code& ec)
{
- return this->service.get_option(this->implementation, option, ec);
+ return this->get_service().get_option(
+ this->get_implementation(), option, ec);
}
/// Write some data to the serial port.
@@ -436,8 +493,9 @@ public:
std::size_t write_some(const ConstBufferSequence& buffers)
{
boost::system::error_code ec;
- std::size_t s = this->service.write_some(this->implementation, buffers, ec);
- boost::asio::detail::throw_error(ec);
+ std::size_t s = this->get_service().write_some(
+ this->get_implementation(), buffers, ec);
+ boost::asio::detail::throw_error(ec, "write_some");
return s;
}
@@ -461,7 +519,8 @@ public:
std::size_t write_some(const ConstBufferSequence& buffers,
boost::system::error_code& ec)
{
- return this->service.write_some(this->implementation, buffers, ec);
+ return this->get_service().write_some(
+ this->get_implementation(), buffers, ec);
}
/// Start an asynchronous write.
@@ -501,9 +560,14 @@ public:
*/
template <typename ConstBufferSequence, typename WriteHandler>
void async_write_some(const ConstBufferSequence& buffers,
- WriteHandler handler)
+ BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
{
- this->service.async_write_some(this->implementation, buffers, handler);
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a WriteHandler.
+ BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
+
+ this->get_service().async_write_some(this->get_implementation(),
+ buffers, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
}
/// Read some data from the serial port.
@@ -538,8 +602,9 @@ public:
std::size_t read_some(const MutableBufferSequence& buffers)
{
boost::system::error_code ec;
- std::size_t s = this->service.read_some(this->implementation, buffers, ec);
- boost::asio::detail::throw_error(ec);
+ std::size_t s = this->get_service().read_some(
+ this->get_implementation(), buffers, ec);
+ boost::asio::detail::throw_error(ec, "read_some");
return s;
}
@@ -564,7 +629,8 @@ public:
std::size_t read_some(const MutableBufferSequence& buffers,
boost::system::error_code& ec)
{
- return this->service.read_some(this->implementation, buffers, ec);
+ return this->get_service().read_some(
+ this->get_implementation(), buffers, ec);
}
/// Start an asynchronous read.
@@ -605,9 +671,14 @@ public:
*/
template <typename MutableBufferSequence, typename ReadHandler>
void async_read_some(const MutableBufferSequence& buffers,
- ReadHandler handler)
+ BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
{
- this->service.async_read_some(this->implementation, buffers, handler);
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a ReadHandler.
+ BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
+
+ this->get_service().async_read_some(this->get_implementation(),
+ buffers, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
}
};