serial_port_service.hpp
Go to the documentation of this file.
00001 //
00002 // serial_port_service.hpp
00003 // ~~~~~~~~~~~~~~~~~~~~~~~
00004 //
00005 // Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com)
00006 //
00007 // Distributed under the Boost Software License, Version 1.0. (See accompanying
00008 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
00009 //
00010 
00011 #ifndef ASIO_SERIAL_PORT_SERVICE_HPP
00012 #define ASIO_SERIAL_PORT_SERVICE_HPP
00013 
00014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
00015 # pragma once
00016 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
00017 
00018 #include "asio/detail/push_options.hpp"
00019 
00020 #include "asio/detail/push_options.hpp"
00021 #include <cstddef>
00022 #include <boost/config.hpp>
00023 #include <string>
00024 #include "asio/detail/pop_options.hpp"
00025 
00026 #include "asio/error.hpp"
00027 #include "asio/io_service.hpp"
00028 #include "asio/detail/service_base.hpp"
00029 #include "asio/detail/reactive_serial_port_service.hpp"
00030 #include "asio/detail/win_iocp_serial_port_service.hpp"
00031 
00032 #if !defined(ASIO_DISABLE_SERIAL_PORT)
00033 # if defined(ASIO_HAS_IOCP) \
00034     || !defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
00035 #  define ASIO_HAS_SERIAL_PORT 1
00036 # endif // defined(ASIO_HAS_IOCP)
00037 #endif // !defined(ASIO_DISABLE_STREAM_HANDLE)
00038 
00039 #if defined(ASIO_HAS_SERIAL_PORT) \
00040   || defined(GENERATING_DOCUMENTATION)
00041 
00042 namespace asio {
00043 
00045 class serial_port_service
00046 #if defined(GENERATING_DOCUMENTATION)
00047   : public asio::io_service::service
00048 #else
00049   : public asio::detail::service_base<serial_port_service>
00050 #endif
00051 {
00052 public:
00053 #if defined(GENERATING_DOCUMENTATION)
00054 
00055   static asio::io_service::id id;
00056 #endif
00057 
00058 private:
00059   // The type of the platform-specific implementation.
00060 #if defined(ASIO_HAS_IOCP)
00061   typedef detail::win_iocp_serial_port_service service_impl_type;
00062 #elif defined(ASIO_HAS_EPOLL)
00063   typedef detail::reactive_serial_port_service<
00064       detail::epoll_reactor<false> > service_impl_type;
00065 #elif defined(ASIO_HAS_KQUEUE)
00066   typedef detail::reactive_serial_port_service<
00067       detail::kqueue_reactor<false> > service_impl_type;
00068 #elif defined(ASIO_HAS_DEV_POLL)
00069   typedef detail::reactive_serial_port_service<
00070       detail::dev_poll_reactor<false> > service_impl_type;
00071 #else
00072   typedef detail::reactive_serial_port_service<
00073       detail::select_reactor<false> > service_impl_type;
00074 #endif
00075 
00076 public:
00078 #if defined(GENERATING_DOCUMENTATION)
00079   typedef implementation_defined implementation_type;
00080 #else
00081   typedef service_impl_type::implementation_type implementation_type;
00082 #endif
00083 
00085 #if defined(GENERATING_DOCUMENTATION)
00086   typedef implementation_defined native_type;
00087 #else
00088   typedef service_impl_type::native_type native_type;
00089 #endif
00090 
00092   explicit serial_port_service(asio::io_service& io_service)
00093     : asio::detail::service_base<serial_port_service>(io_service),
00094       service_impl_(asio::use_service<service_impl_type>(io_service))
00095   {
00096   }
00097 
00099   void shutdown_service()
00100   {
00101   }
00102 
00104   void construct(implementation_type& impl)
00105   {
00106     service_impl_.construct(impl);
00107   }
00108 
00110   void destroy(implementation_type& impl)
00111   {
00112     service_impl_.destroy(impl);
00113   }
00114 
00116   asio::error_code open(implementation_type& impl,
00117       const std::string& device, asio::error_code& ec)
00118   {
00119     return service_impl_.open(impl, device, ec);
00120   }
00121 
00123   asio::error_code assign(implementation_type& impl,
00124       const native_type& native_handle, asio::error_code& ec)
00125   {
00126     return service_impl_.assign(impl, native_handle, ec);
00127   }
00128 
00130   bool is_open(const implementation_type& impl) const
00131   {
00132     return service_impl_.is_open(impl);
00133   }
00134 
00136   asio::error_code close(implementation_type& impl,
00137       asio::error_code& ec)
00138   {
00139     return service_impl_.close(impl, ec);
00140   }
00141 
00143   native_type native(implementation_type& impl)
00144   {
00145     return service_impl_.native(impl);
00146   }
00147 
00149   asio::error_code cancel(implementation_type& impl,
00150       asio::error_code& ec)
00151   {
00152     return service_impl_.cancel(impl, ec);
00153   }
00154 
00156   template <typename SettableSerialPortOption>
00157   asio::error_code set_option(implementation_type& impl,
00158       const SettableSerialPortOption& option, asio::error_code& ec)
00159   {
00160     return service_impl_.set_option(impl, option, ec);
00161   }
00162 
00164   template <typename GettableSerialPortOption>
00165   asio::error_code get_option(const implementation_type& impl,
00166       GettableSerialPortOption& option, asio::error_code& ec) const
00167   {
00168     return service_impl_.get_option(impl, option, ec);
00169   }
00170 
00172   asio::error_code send_break(implementation_type& impl,
00173       asio::error_code& ec)
00174   {
00175     return service_impl_.send_break(impl, ec);
00176   }
00177 
00179   template <typename ConstBufferSequence>
00180   std::size_t write_some(implementation_type& impl,
00181       const ConstBufferSequence& buffers, asio::error_code& ec)
00182   {
00183     return service_impl_.write_some(impl, buffers, ec);
00184   }
00185 
00187   template <typename ConstBufferSequence, typename WriteHandler>
00188   void async_write_some(implementation_type& impl,
00189       const ConstBufferSequence& buffers, WriteHandler handler)
00190   {
00191     service_impl_.async_write_some(impl, buffers, handler);
00192   }
00193 
00195   template <typename MutableBufferSequence>
00196   std::size_t read_some(implementation_type& impl,
00197       const MutableBufferSequence& buffers, asio::error_code& ec)
00198   {
00199     return service_impl_.read_some(impl, buffers, ec);
00200   }
00201 
00203   template <typename MutableBufferSequence, typename ReadHandler>
00204   void async_read_some(implementation_type& impl,
00205       const MutableBufferSequence& buffers, ReadHandler handler)
00206   {
00207     service_impl_.async_read_some(impl, buffers, handler);
00208   }
00209 
00210 private:
00211   // The service that provides the platform-specific implementation.
00212   service_impl_type& service_impl_;
00213 };
00214 
00215 } // namespace asio
00216 
00217 #endif // defined(ASIO_HAS_SERIAL_PORT)
00218        //   || defined(GENERATING_DOCUMENTATION)
00219 
00220 #include "asio/detail/pop_options.hpp"
00221 
00222 #endif // ASIO_SERIAL_PORT_SERVICE_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


Castor
Author(s): Carpe Noctem
autogenerated on Fri Nov 8 2013 11:05:39