diff options
Diffstat (limited to 'boost/asio/basic_serial_port.hpp')
-rw-r--r-- | boost/asio/basic_serial_port.hpp | 89 |
1 files changed, 41 insertions, 48 deletions
diff --git a/boost/asio/basic_serial_port.hpp b/boost/asio/basic_serial_port.hpp index bfc78afaf6..af2193f7cb 100644 --- a/boost/asio/basic_serial_port.hpp +++ b/boost/asio/basic_serial_port.hpp @@ -18,6 +18,8 @@ #include <boost/asio/detail/config.hpp> +#if defined(BOOST_ASIO_ENABLE_OLD_SERVICES) + #if defined(BOOST_ASIO_HAS_SERIAL_PORT) \ || defined(GENERATING_DOCUMENTATION) @@ -49,10 +51,6 @@ 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_handle_type native_handle_type; @@ -63,11 +61,11 @@ public: /** * This constructor creates a serial port without opening it. * - * @param io_service The io_service object that the serial port will use to + * @param io_context The io_context object that the serial port will use to * dispatch handlers for any asynchronous operations performed on the port. */ - explicit basic_serial_port(boost::asio::io_service& io_service) - : basic_io_object<SerialPortService>(io_service) + explicit basic_serial_port(boost::asio::io_context& io_context) + : basic_io_object<SerialPortService>(io_context) { } @@ -76,15 +74,15 @@ public: * This constructor creates and opens a serial port for the specified device * name. * - * @param io_service The io_service object that the serial port will use to + * @param io_context The io_context object that the serial port will use to * dispatch handlers for any asynchronous operations performed on the port. * * @param device The platform-specific device name for this serial * port. */ - explicit basic_serial_port(boost::asio::io_service& io_service, + explicit basic_serial_port(boost::asio::io_context& io_context, const char* device) - : basic_io_object<SerialPortService>(io_service) + : basic_io_object<SerialPortService>(io_context) { boost::system::error_code ec; this->get_service().open(this->get_implementation(), device, ec); @@ -96,15 +94,15 @@ public: * This constructor creates and opens a serial port for the specified device * name. * - * @param io_service The io_service object that the serial port will use to + * @param io_context The io_context object that the serial port will use to * dispatch handlers for any asynchronous operations performed on the port. * * @param device The platform-specific device name for this serial * port. */ - explicit basic_serial_port(boost::asio::io_service& io_service, + explicit basic_serial_port(boost::asio::io_context& io_context, const std::string& device) - : basic_io_object<SerialPortService>(io_service) + : basic_io_object<SerialPortService>(io_context) { boost::system::error_code ec; this->get_service().open(this->get_implementation(), device, ec); @@ -116,16 +114,16 @@ public: * This constructor creates a serial port object to hold an existing native * serial port. * - * @param io_service The io_service object that the serial port will use to + * @param io_context The io_context object that the serial port will use to * dispatch handlers for any asynchronous operations performed on the port. * * @param native_serial_port A native serial port. * * @throws boost::system::system_error Thrown on failure. */ - basic_serial_port(boost::asio::io_service& io_service, + basic_serial_port(boost::asio::io_context& io_context, const native_handle_type& native_serial_port) - : basic_io_object<SerialPortService>(io_service) + : basic_io_object<SerialPortService>(io_context) { boost::system::error_code ec; this->get_service().assign(this->get_implementation(), @@ -142,7 +140,7 @@ public: * 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. + * constructed using the @c basic_serial_port(io_context&) constructor. */ basic_serial_port(basic_serial_port&& other) : basic_io_object<SerialPortService>( @@ -158,7 +156,7 @@ public: * 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. + * constructed using the @c basic_serial_port(io_context&) constructor. */ basic_serial_port& operator=(basic_serial_port&& other) { @@ -220,10 +218,11 @@ public: * * @param ec Set the indicate what error occurred, if any. */ - boost::system::error_code open(const std::string& device, + BOOST_ASIO_SYNC_OP_VOID open(const std::string& device, boost::system::error_code& ec) { - return this->get_service().open(this->get_implementation(), device, ec); + this->get_service().open(this->get_implementation(), device, ec); + BOOST_ASIO_SYNC_OP_VOID_RETURN(ec); } /// Assign an existing native serial port to the serial port. @@ -250,11 +249,12 @@ public: * * @param ec Set to indicate what error occurred, if any. */ - boost::system::error_code assign(const native_handle_type& native_serial_port, + BOOST_ASIO_SYNC_OP_VOID assign(const native_handle_type& native_serial_port, boost::system::error_code& ec) { - return this->get_service().assign(this->get_implementation(), + this->get_service().assign(this->get_implementation(), native_serial_port, ec); + BOOST_ASIO_SYNC_OP_VOID_RETURN(ec); } /// Determine whether the serial port is open. @@ -286,21 +286,10 @@ public: * * @param ec Set to indicate what error occurred, if any. */ - boost::system::error_code close(boost::system::error_code& ec) + BOOST_ASIO_SYNC_OP_VOID close(boost::system::error_code& ec) { - return this->get_service().close(this->get_implementation(), ec); - } - - /// (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 - * functionality that is not otherwise provided. - */ - native_type native() - { - return this->get_service().native_handle(this->get_implementation()); + this->get_service().close(this->get_implementation(), ec); + BOOST_ASIO_SYNC_OP_VOID_RETURN(ec); } /// Get the native serial port representation. @@ -337,9 +326,10 @@ public: * * @param ec Set to indicate what error occurred, if any. */ - boost::system::error_code cancel(boost::system::error_code& ec) + BOOST_ASIO_SYNC_OP_VOID cancel(boost::system::error_code& ec) { - return this->get_service().cancel(this->get_implementation(), ec); + this->get_service().cancel(this->get_implementation(), ec); + BOOST_ASIO_SYNC_OP_VOID_RETURN(ec); } /// Send a break sequence to the serial port. @@ -363,9 +353,10 @@ public: * * @param ec Set to indicate what error occurred, if any. */ - boost::system::error_code send_break(boost::system::error_code& ec) + BOOST_ASIO_SYNC_OP_VOID send_break(boost::system::error_code& ec) { - return this->get_service().send_break(this->get_implementation(), ec); + this->get_service().send_break(this->get_implementation(), ec); + BOOST_ASIO_SYNC_OP_VOID_RETURN(ec); } /// Set an option on the serial port. @@ -407,11 +398,11 @@ public: * boost::asio::serial_port_base::character_size */ template <typename SettableSerialPortOption> - boost::system::error_code set_option(const SettableSerialPortOption& option, + BOOST_ASIO_SYNC_OP_VOID set_option(const SettableSerialPortOption& option, boost::system::error_code& ec) { - return this->get_service().set_option( - this->get_implementation(), option, ec); + this->get_service().set_option(this->get_implementation(), option, ec); + BOOST_ASIO_SYNC_OP_VOID_RETURN(ec); } /// Get an option from the serial port. @@ -455,11 +446,11 @@ public: * boost::asio::serial_port_base::character_size */ template <typename GettableSerialPortOption> - boost::system::error_code get_option(GettableSerialPortOption& option, + BOOST_ASIO_SYNC_OP_VOID get_option(GettableSerialPortOption& option, boost::system::error_code& ec) { - return this->get_service().get_option( - this->get_implementation(), option, ec); + this->get_service().get_option(this->get_implementation(), option, ec); + BOOST_ASIO_SYNC_OP_VOID_RETURN(ec); } /// Write some data to the serial port. @@ -543,7 +534,7 @@ public: * Regardless of whether the asynchronous operation completes immediately or * not, the handler will not be invoked from within this function. Invocation * of the handler will be performed in a manner equivalent to using - * boost::asio::io_service::post(). + * boost::asio::io_context::post(). * * @note The write operation may not transmit all of the data to the peer. * Consider using the @ref async_write function if you need to ensure that all @@ -655,7 +646,7 @@ public: * Regardless of whether the asynchronous operation completes immediately or * not, the handler will not be invoked from within this function. Invocation * of the handler will be performed in a manner equivalent to using - * boost::asio::io_service::post(). + * boost::asio::io_context::post(). * * @note The read operation may not read all of the requested number of bytes. * Consider using the @ref async_read function if you need to ensure that the @@ -694,4 +685,6 @@ public: #endif // defined(BOOST_ASIO_HAS_SERIAL_PORT) // || defined(GENERATING_DOCUMENTATION) +#endif // defined(BOOST_ASIO_ENABLE_OLD_SERVICES) + #endif // BOOST_ASIO_BASIC_SERIAL_PORT_HPP |