00001 // 00002 // basic_io_object.hpp 00003 // ~~~~~~~~~~~~~~~~~~~ 00004 // 00005 // Copyright (c) 2003-2007 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 00038 00045 asio::io_service& io_service() 00046 { 00047 return service.io_service(); 00048 } 00049 00050 protected: 00052 explicit basic_io_object(asio::io_service& io_service) 00053 : service(asio::use_service<IoObjectService>(io_service)) 00054 { 00055 service.construct(implementation); 00056 } 00057 00059 ~basic_io_object() 00060 { 00061 service.destroy(implementation); 00062 } 00063 00064 // The backend service implementation. 00065 service_type& service; 00066 00067 // The underlying native implementation. 00068 implementation_type implementation; 00069 }; 00070 00071 } // namespace asio 00072 00073 #include "asio/detail/pop_options.hpp" 00074 00075 #endif // ASIO_BASIC_IO_OBJECT_HPP
1.5.6