fix doc example typo
[boost.git] / boost / asio / basic_io_object.hpp
blob1cbf9bb3893f65afe2200807ef47d4b8d1d27f78
1 //
2 // basic_io_object.hpp
3 // ~~~~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 //
7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 //
11 #ifndef BOOST_ASIO_BASIC_IO_OBJECT_HPP
12 #define BOOST_ASIO_BASIC_IO_OBJECT_HPP
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 # pragma once
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
18 #include <boost/asio/detail/push_options.hpp>
20 #include <boost/asio/io_service.hpp>
21 #include <boost/asio/detail/noncopyable.hpp>
23 namespace boost {
24 namespace asio {
26 /// Base class for all I/O objects.
27 template <typename IoObjectService>
28 class basic_io_object
29 : private noncopyable
31 public:
32 /// The type of the service that will be used to provide I/O operations.
33 typedef IoObjectService service_type;
35 /// The underlying implementation type of I/O object.
36 typedef typename service_type::implementation_type implementation_type;
38 /// (Deprecated: use get_io_service().) Get the io_service associated with
39 /// the object.
40 /**
41 * This function may be used to obtain the io_service object that the I/O
42 * object uses to dispatch handlers for asynchronous operations.
44 * @return A reference to the io_service object that the I/O object will use
45 * to dispatch handlers. Ownership is not transferred to the caller.
47 boost::asio::io_service& io_service()
49 return service.get_io_service();
52 /// Get the io_service associated with the object.
53 /**
54 * This function may be used to obtain the io_service object that the I/O
55 * object uses to dispatch handlers for asynchronous operations.
57 * @return A reference to the io_service object that the I/O object will use
58 * to dispatch handlers. Ownership is not transferred to the caller.
60 boost::asio::io_service& get_io_service()
62 return service.get_io_service();
65 protected:
66 /// Construct a basic_io_object.
67 /**
68 * Performs:
69 * @code service.construct(implementation); @endcode
71 explicit basic_io_object(boost::asio::io_service& io_service)
72 : service(boost::asio::use_service<IoObjectService>(io_service))
74 service.construct(implementation);
77 /// Protected destructor to prevent deletion through this type.
78 /**
79 * Performs:
80 * @code service.destroy(implementation); @endcode
82 ~basic_io_object()
84 service.destroy(implementation);
87 /// The service associated with the I/O object.
88 service_type& service;
90 /// The underlying implementation of the I/O object.
91 implementation_type implementation;
94 } // namespace asio
95 } // namespace boost
97 #include <boost/asio/detail/pop_options.hpp>
99 #endif // BOOST_ASIO_BASIC_IO_OBJECT_HPP