Realistic 3D camera system
3D camera system components
stream.hpp
Go to the documentation of this file.
1 //
2 // ssl/old/stream.hpp
3 // ~~~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2005 Voipster / Indrek dot Juhani at voipster dot com
6 // Copyright (c) 2005-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
7 //
8 // Distributed under the Boost Software License, Version 1.0. (See accompanying
9 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
10 //
11 
12 #ifndef ASIO_SSL_OLD_STREAM_HPP
13 #define ASIO_SSL_OLD_STREAM_HPP
14 
15 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
16 # pragma once
17 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
18 
19 #include "asio/detail/config.hpp"
20 #include <cstddef>
21 #include <boost/noncopyable.hpp>
24 #include "asio/error.hpp"
26 #include "asio/ssl/stream_base.hpp"
28 
30 
31 namespace asio {
32 namespace ssl {
33 namespace old {
34 
36 
55 template <typename Stream, typename Service = old::stream_service>
56 class stream
57  : public stream_base,
58  private boost::noncopyable
59 {
60 public:
62  typedef typename remove_reference<Stream>::type next_layer_type;
63 
65  typedef typename next_layer_type::lowest_layer_type lowest_layer_type;
66 
68  typedef Service service_type;
69 
71  typedef typename service_type::impl_type impl_type;
72 
74 
82  template <typename Arg, typename Context_Service>
84  : next_layer_(arg),
85  service_(asio::use_service<Service>(next_layer_.get_io_service())),
86  impl_(service_.null())
87  {
88  service_.create(impl_, next_layer_, context);
89  }
90 
93  {
94  service_.destroy(impl_, next_layer_);
95  }
96 
98 
106  {
107  return next_layer_.get_io_service();
108  }
109 
111 
118  next_layer_type& next_layer()
119  {
120  return next_layer_;
121  }
122 
124 
131  lowest_layer_type& lowest_layer()
132  {
133  return next_layer_.lowest_layer();
134  }
135 
137 
144  const lowest_layer_type& lowest_layer() const
145  {
146  return next_layer_.lowest_layer();
147  }
148 
150 
155  impl_type impl()
156  {
157  return impl_;
158  }
159 
161 
171  {
172  asio::error_code ec;
173  service_.handshake(impl_, next_layer_, type, ec);
175  }
176 
178 
188  asio::error_code& ec)
189  {
190  return service_.handshake(impl_, next_layer_, type, ec);
191  }
192 
194 
208  template <typename HandshakeHandler>
209  void async_handshake(handshake_type type, HandshakeHandler handler)
210  {
211  service_.async_handshake(impl_, next_layer_, type, handler);
212  }
213 
215 
221  void shutdown()
222  {
223  asio::error_code ec;
224  service_.shutdown(impl_, next_layer_, ec);
226  }
227 
229 
236  {
237  return service_.shutdown(impl_, next_layer_, ec);
238  }
239 
241 
252  template <typename ShutdownHandler>
253  void async_shutdown(ShutdownHandler handler)
254  {
255  service_.async_shutdown(impl_, next_layer_, handler);
256  }
257 
259 
274  template <typename ConstBufferSequence>
275  std::size_t write_some(const ConstBufferSequence& buffers)
276  {
277  asio::error_code ec;
278  std::size_t s = service_.write_some(impl_, next_layer_, buffers, ec);
280  return s;
281  }
282 
284 
299  template <typename ConstBufferSequence>
300  std::size_t write_some(const ConstBufferSequence& buffers,
301  asio::error_code& ec)
302  {
303  return service_.write_some(impl_, next_layer_, buffers, ec);
304  }
305 
307 
328  template <typename ConstBufferSequence, typename WriteHandler>
329  void async_write_some(const ConstBufferSequence& buffers,
330  WriteHandler handler)
331  {
332  service_.async_write_some(impl_, next_layer_, buffers, handler);
333  }
334 
336 
351  template <typename MutableBufferSequence>
352  std::size_t read_some(const MutableBufferSequence& buffers)
353  {
354  asio::error_code ec;
355  std::size_t s = service_.read_some(impl_, next_layer_, buffers, ec);
357  return s;
358  }
359 
361 
376  template <typename MutableBufferSequence>
377  std::size_t read_some(const MutableBufferSequence& buffers,
378  asio::error_code& ec)
379  {
380  return service_.read_some(impl_, next_layer_, buffers, ec);
381  }
382 
384 
406  template <typename MutableBufferSequence, typename ReadHandler>
407  void async_read_some(const MutableBufferSequence& buffers,
408  ReadHandler handler)
409  {
410  service_.async_read_some(impl_, next_layer_, buffers, handler);
411  }
412 
414 
425  template <typename MutableBufferSequence>
426  std::size_t peek(const MutableBufferSequence& buffers)
427  {
428  asio::error_code ec;
429  std::size_t s = service_.peek(impl_, next_layer_, buffers, ec);
431  return s;
432  }
433 
435 
446  template <typename MutableBufferSequence>
447  std::size_t peek(const MutableBufferSequence& buffers,
448  asio::error_code& ec)
449  {
450  return service_.peek(impl_, next_layer_, buffers, ec);
451  }
452 
454 
462  std::size_t in_avail()
463  {
464  asio::error_code ec;
465  std::size_t s = service_.in_avail(impl_, next_layer_, ec);
467  return s;
468  }
469 
471 
479  std::size_t in_avail(asio::error_code& ec)
480  {
481  return service_.in_avail(impl_, next_layer_, ec);
482  }
483 
484 private:
486  Stream next_layer_;
487 
489  service_type& service_;
490 
492  impl_type impl_;
493 };
494 
495 } // namespace old
496 } // namespace ssl
497 } // namespace asio
498 
500 
501 #endif // ASIO_SSL_OLD_STREAM_HPP
std::size_t read_some(const MutableBufferSequence &buffers, asio::error_code &ec)
Read some data from the stream.
Definition: stream.hpp:377
next_layer_type & next_layer()
Get a reference to the next layer.
Definition: stream.hpp:118
void throw_error(const asio::error_code &err)
Definition: throw_error.hpp:31
Service service_type
The type of the service that will be used to provide stream operations.
Definition: stream.hpp:68
Provides core I/O functionality.
Definition: io_service.hpp:184
asio::error_code shutdown(asio::error_code &ec)
Shut down SSL on the stream.
Definition: stream.hpp:235
void async_shutdown(ShutdownHandler handler)
Asynchronously shut down SSL on the stream.
Definition: stream.hpp:253
std::size_t in_avail()
Determine the amount of data that may be read without blocking.
Definition: stream.hpp:462
SocketService & s
Definition: connect.hpp:521
service_type::impl_type impl_type
The native implementation type of the stream.
Definition: stream.hpp:71
std::size_t read_some(const MutableBufferSequence &buffers)
Read some data from the stream.
Definition: stream.hpp:352
void handshake(handshake_type type)
Perform SSL handshaking.
Definition: stream.hpp:170
Provides stream-oriented functionality using SSL.
Definition: stream.hpp:56
Service & use_service(io_service &ios)
Definition: io_service.hpp:26
void async_read_some(const MutableBufferSequence &buffers, ReadHandler handler)
Start an asynchronous read.
Definition: stream.hpp:407
asio::io_service & get_io_service()
Get the io_service associated with the object.
Definition: stream.hpp:105
handshake_type
Different handshake types.
Definition: stream_base.hpp:31
std::size_t in_avail(asio::error_code &ec)
Determine the amount of data that may be read without blocking.
Definition: stream.hpp:479
const MutableBufferSequence & buffers
Definition: read.hpp:521
impl_type impl()
Get the underlying implementation in the native type.
Definition: stream.hpp:155
std::size_t peek(const MutableBufferSequence &buffers, asio::error_code &ec)
Peek at the incoming data on the stream.
Definition: stream.hpp:447
void async_write_some(const ConstBufferSequence &buffers, WriteHandler handler)
Start an asynchronous write.
Definition: stream.hpp:329
asio::error_code handshake(handshake_type type, asio::error_code &ec)
Perform SSL handshaking.
Definition: stream.hpp:187
~stream()
Destructor.
Definition: stream.hpp:92
Class to represent an error code value.
Definition: error_code.hpp:80
std::size_t write_some(const ConstBufferSequence &buffers, asio::error_code &ec)
Write some data to the stream.
Definition: stream.hpp:300
const lowest_layer_type & lowest_layer() const
Get a const reference to the lowest layer.
Definition: stream.hpp:144
std::size_t peek(const MutableBufferSequence &buffers)
Peek at the incoming data on the stream.
Definition: stream.hpp:426
void async_handshake(handshake_type type, HandshakeHandler handler)
Start an asynchronous SSL handshake.
Definition: stream.hpp:209
next_layer_type::lowest_layer_type lowest_layer_type
The type of the lowest layer.
Definition: stream.hpp:65
std::size_t write_some(const ConstBufferSequence &buffers)
Write some data to the stream.
Definition: stream.hpp:275
stream(Arg &arg, basic_context< Context_Service > &context)
Construct a stream.
Definition: stream.hpp:83
lowest_layer_type & lowest_layer()
Get a reference to the lowest layer.
Definition: stream.hpp:131
remove_reference< Stream >::type next_layer_type
The type of the next layer.
Definition: stream.hpp:62
void shutdown()
Shut down SSL on the stream.
Definition: stream.hpp:221