stream_service.hpp
Go to the documentation of this file.
00001 //
00002 // stream_service.hpp
00003 // ~~~~~~~~~~~~~~~~~~
00004 //
00005 // Copyright (c) 2005 Voipster / Indrek dot Juhani at voipster dot com
00006 // Copyright (c) 2005-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com)
00007 //
00008 // Distributed under the Boost Software License, Version 1.0. (See accompanying
00009 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
00010 //
00011 
00012 #ifndef ASIO_SSL_STREAM_SERVICE_HPP
00013 #define ASIO_SSL_STREAM_SERVICE_HPP
00014 
00015 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
00016 # pragma once
00017 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
00018 
00019 #include "asio/detail/push_options.hpp"
00020 
00021 #include "asio/detail/push_options.hpp"
00022 #include <cstddef>
00023 #include <boost/config.hpp>
00024 #include <boost/noncopyable.hpp>
00025 #include "asio/detail/pop_options.hpp"
00026 
00027 #include "asio/io_service.hpp"
00028 #include "asio/detail/service_base.hpp"
00029 #include "asio/ssl/basic_context.hpp"
00030 #include "asio/ssl/stream_base.hpp"
00031 #include "asio/ssl/detail/openssl_stream_service.hpp"
00032 
00033 namespace asio {
00034 namespace ssl {
00035 
00037 class stream_service
00038 #if defined(GENERATING_DOCUMENTATION)
00039   : public asio::io_service::service
00040 #else
00041   : public asio::detail::service_base<stream_service>
00042 #endif
00043 {
00044 private:
00045   // The type of the platform-specific implementation.
00046   typedef detail::openssl_stream_service service_impl_type;
00047 
00048 public:
00049 #if defined(GENERATING_DOCUMENTATION)
00050 
00051   static asio::io_service::id id;
00052 #endif
00053 
00055 #if defined(GENERATING_DOCUMENTATION)
00056   typedef implementation_defined impl_type;
00057 #else
00058   typedef service_impl_type::impl_type impl_type;
00059 #endif
00060 
00062   explicit stream_service(asio::io_service& io_service)
00063     : asio::detail::service_base<stream_service>(io_service),
00064       service_impl_(asio::use_service<service_impl_type>(io_service))
00065   {
00066   }
00067 
00069   void shutdown_service()
00070   {
00071   }
00072 
00074   impl_type null() const
00075   {
00076     return service_impl_.null();
00077   }
00078 
00080   template <typename Stream, typename Context_Service>
00081   void create(impl_type& impl, Stream& next_layer,
00082       basic_context<Context_Service>& context)
00083   {
00084     service_impl_.create(impl, next_layer, context);
00085   }
00086 
00088   template <typename Stream>
00089   void destroy(impl_type& impl, Stream& next_layer)
00090   {
00091     service_impl_.destroy(impl, next_layer);
00092   }
00093 
00095   template <typename Stream>
00096   asio::error_code handshake(impl_type& impl, Stream& next_layer,
00097       stream_base::handshake_type type, asio::error_code& ec)
00098   {
00099     return service_impl_.handshake(impl, next_layer, type, ec);
00100   }
00101 
00103   template <typename Stream, typename HandshakeHandler>
00104   void async_handshake(impl_type& impl, Stream& next_layer,
00105       stream_base::handshake_type type, HandshakeHandler handler)
00106   {
00107     service_impl_.async_handshake(impl, next_layer, type, handler);
00108   }
00109 
00111   template <typename Stream>
00112   asio::error_code shutdown(impl_type& impl, Stream& next_layer,
00113       asio::error_code& ec)
00114   {
00115     return service_impl_.shutdown(impl, next_layer, ec);
00116   }
00117 
00119   template <typename Stream, typename ShutdownHandler>
00120   void async_shutdown(impl_type& impl, Stream& next_layer,
00121       ShutdownHandler handler)
00122   {
00123     service_impl_.async_shutdown(impl, next_layer, handler);
00124   }
00125 
00127   template <typename Stream, typename ConstBufferSequence>
00128   std::size_t write_some(impl_type& impl, Stream& next_layer,
00129       const ConstBufferSequence& buffers, asio::error_code& ec)
00130   {
00131     return service_impl_.write_some(impl, next_layer, buffers, ec);
00132   }
00133 
00135   template <typename Stream, typename ConstBufferSequence,
00136       typename WriteHandler>
00137   void async_write_some(impl_type& impl, Stream& next_layer,
00138       const ConstBufferSequence& buffers, WriteHandler handler)
00139   {
00140     service_impl_.async_write_some(impl, next_layer, buffers, handler);
00141   }
00142 
00144   template <typename Stream, typename MutableBufferSequence>
00145   std::size_t read_some(impl_type& impl, Stream& next_layer,
00146       const MutableBufferSequence& buffers, asio::error_code& ec)
00147   {
00148     return service_impl_.read_some(impl, next_layer, buffers, ec);
00149   }
00150 
00152   template <typename Stream, typename MutableBufferSequence,
00153       typename ReadHandler>
00154   void async_read_some(impl_type& impl, Stream& next_layer,
00155       const MutableBufferSequence& buffers, ReadHandler handler)
00156   {
00157     service_impl_.async_read_some(impl, next_layer, buffers, handler);
00158   }
00159 
00161   template <typename Stream, typename MutableBufferSequence>
00162   std::size_t peek(impl_type& impl, Stream& next_layer,
00163       const MutableBufferSequence& buffers, asio::error_code& ec)
00164   {
00165     return service_impl_.peek(impl, next_layer, buffers, ec);
00166   }
00167 
00169   template <typename Stream>
00170   std::size_t in_avail(impl_type& impl, Stream& next_layer,
00171       asio::error_code& ec)
00172   {
00173     return service_impl_.in_avail(impl, next_layer, ec);
00174   }
00175 
00176 private:
00177   // The service that provides the platform-specific implementation.
00178   service_impl_type& service_impl_;
00179 };
00180 
00181 } // namespace ssl
00182 } // namespace asio
00183 
00184 #include "asio/detail/pop_options.hpp"
00185 
00186 #endif // ASIO_SSL_STREAM_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