00001 // 00002 // basic_io_object.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_BASIC_IO_OBJECT_HPP 00012 #define ASIO_BASIC_IO_OBJECT_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/io_service.hpp" 00021 #include "asio/detail/noncopyable.hpp" 00022 00023 namespace asio { 00024 00026 template <typename IoObjectService> 00027 class basic_io_object 00028 : private noncopyable 00029 { 00030 public: 00032 typedef IoObjectService service_type; 00033 00035 typedef typename service_type::implementation_type implementation_type; 00036 00039 00046 asio::io_service& io_service() 00047 { 00048 return service.get_io_service(); 00049 } 00050 00052 00059 asio::io_service& get_io_service() 00060 { 00061 return service.get_io_service(); 00062 } 00063 00064 protected: 00066 00070 explicit basic_io_object(asio::io_service& io_service) 00071 : service(asio::use_service<IoObjectService>(io_service)) 00072 { 00073 service.construct(implementation); 00074 } 00075 00077 00081 ~basic_io_object() 00082 { 00083 service.destroy(implementation); 00084 } 00085 00087 service_type& service; 00088 00090 implementation_type implementation; 00091 }; 00092 00093 } // namespace asio 00094 00095 #include "asio/detail/pop_options.hpp" 00096 00097 #endif // ASIO_BASIC_IO_OBJECT_HPP