stream_descriptor_service.hpp
Go to the documentation of this file.
00001 //
00002 // stream_descriptor_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_POSIX_STREAM_DESCRIPTOR_SERVICE_HPP
00012 #define ASIO_POSIX_STREAM_DESCRIPTOR_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 "asio/detail/pop_options.hpp"
00024 
00025 #include "asio/error.hpp"
00026 #include "asio/io_service.hpp"
00027 #include "asio/detail/epoll_reactor.hpp"
00028 #include "asio/detail/kqueue_reactor.hpp"
00029 #include "asio/detail/select_reactor.hpp"
00030 #include "asio/detail/service_base.hpp"
00031 #include "asio/detail/reactive_descriptor_service.hpp"
00032 
00033 #if !defined(ASIO_DISABLE_POSIX_STREAM_DESCRIPTOR)
00034 # if !defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
00035 #  define ASIO_HAS_POSIX_STREAM_DESCRIPTOR 1
00036 # endif // !defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
00037 #endif // !defined(ASIO_DISABLE_POSIX_STREAM_DESCRIPTOR)
00038 
00039 #if defined(ASIO_HAS_POSIX_STREAM_DESCRIPTOR) \
00040   || defined(GENERATING_DOCUMENTATION)
00041 
00042 namespace asio {
00043 namespace posix {
00044 
00046 class stream_descriptor_service
00047 #if defined(GENERATING_DOCUMENTATION)
00048   : public asio::io_service::service
00049 #else
00050   : public asio::detail::service_base<stream_descriptor_service>
00051 #endif
00052 {
00053 public:
00054 #if defined(GENERATING_DOCUMENTATION)
00055 
00056   static asio::io_service::id id;
00057 #endif
00058 
00059 private:
00060   // The type of the platform-specific implementation.
00061 #if defined(ASIO_HAS_EPOLL)
00062   typedef detail::reactive_descriptor_service<
00063       detail::epoll_reactor<false> > service_impl_type;
00064 #elif defined(ASIO_HAS_KQUEUE)
00065   typedef detail::reactive_descriptor_service<
00066       detail::kqueue_reactor<false> > service_impl_type;
00067 #elif defined(ASIO_HAS_DEV_POLL)
00068   typedef detail::reactive_descriptor_service<
00069       detail::dev_poll_reactor<false> > service_impl_type;
00070 #else
00071   typedef detail::reactive_descriptor_service<
00072       detail::select_reactor<false> > service_impl_type;
00073 #endif
00074 
00075 public:
00077 #if defined(GENERATING_DOCUMENTATION)
00078   typedef implementation_defined implementation_type;
00079 #else
00080   typedef service_impl_type::implementation_type implementation_type;
00081 #endif
00082 
00084 #if defined(GENERATING_DOCUMENTATION)
00085   typedef implementation_defined native_type;
00086 #else
00087   typedef service_impl_type::native_type native_type;
00088 #endif
00089 
00091   explicit stream_descriptor_service(asio::io_service& io_service)
00092     : asio::detail::service_base<stream_descriptor_service>(io_service),
00093       service_impl_(asio::use_service<service_impl_type>(io_service))
00094   {
00095   }
00096 
00098   void shutdown_service()
00099   {
00100   }
00101 
00103   void construct(implementation_type& impl)
00104   {
00105     service_impl_.construct(impl);
00106   }
00107 
00109   void destroy(implementation_type& impl)
00110   {
00111     service_impl_.destroy(impl);
00112   }
00113 
00115   asio::error_code assign(implementation_type& impl,
00116       const native_type& native_descriptor, asio::error_code& ec)
00117   {
00118     return service_impl_.assign(impl, native_descriptor, ec);
00119   }
00120 
00122   bool is_open(const implementation_type& impl) const
00123   {
00124     return service_impl_.is_open(impl);
00125   }
00126 
00128   asio::error_code close(implementation_type& impl,
00129       asio::error_code& ec)
00130   {
00131     return service_impl_.close(impl, ec);
00132   }
00133 
00135   native_type native(implementation_type& impl)
00136   {
00137     return service_impl_.native(impl);
00138   }
00139 
00141   asio::error_code cancel(implementation_type& impl,
00142       asio::error_code& ec)
00143   {
00144     return service_impl_.cancel(impl, ec);
00145   }
00146 
00148   template <typename IoControlCommand>
00149   asio::error_code io_control(implementation_type& impl,
00150       IoControlCommand& command, asio::error_code& ec)
00151   {
00152     return service_impl_.io_control(impl, command, ec);
00153   }
00154 
00156   template <typename ConstBufferSequence>
00157   std::size_t write_some(implementation_type& impl,
00158       const ConstBufferSequence& buffers, asio::error_code& ec)
00159   {
00160     return service_impl_.write_some(impl, buffers, ec);
00161   }
00162 
00164   template <typename ConstBufferSequence, typename WriteHandler>
00165   void async_write_some(implementation_type& impl,
00166       const ConstBufferSequence& buffers, WriteHandler descriptorr)
00167   {
00168     service_impl_.async_write_some(impl, buffers, descriptorr);
00169   }
00170 
00172   template <typename MutableBufferSequence>
00173   std::size_t read_some(implementation_type& impl,
00174       const MutableBufferSequence& buffers, asio::error_code& ec)
00175   {
00176     return service_impl_.read_some(impl, buffers, ec);
00177   }
00178 
00180   template <typename MutableBufferSequence, typename ReadHandler>
00181   void async_read_some(implementation_type& impl,
00182       const MutableBufferSequence& buffers, ReadHandler descriptorr)
00183   {
00184     service_impl_.async_read_some(impl, buffers, descriptorr);
00185   }
00186 
00187 private:
00188   // The service that provides the platform-specific implementation.
00189   service_impl_type& service_impl_;
00190 };
00191 
00192 } // namespace posix
00193 } // namespace asio
00194 
00195 #endif // defined(ASIO_HAS_POSIX_STREAM_DESCRIPTOR)
00196        //   || defined(GENERATING_DOCUMENTATION)
00197 
00198 #include "asio/detail/pop_options.hpp"
00199 
00200 #endif // ASIO_POSIX_STREAM_DESCRIPTOR_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