5 // Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com)
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)
11 #ifndef BOOST_ASIO_BASIC_IO_OBJECT_HPP
12 #define BOOST_ASIO_BASIC_IO_OBJECT_HPP
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
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>
26 /// Base class for all I/O objects.
27 template <typename IoObjectService
>
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
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.
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();
66 /// Construct a basic_io_object.
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.
80 * @code service.destroy(implementation); @endcode
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
;
97 #include <boost/asio/detail/pop_options.hpp>
99 #endif // BOOST_ASIO_BASIC_IO_OBJECT_HPP