]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // |
2 | // detail/base_from_completion_cond.hpp | |
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
4 | // | |
5 | // Copyright (c) 2003-2016 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 | // | |
10 | ||
11 | #ifndef BOOST_ASIO_DETAIL_BASE_FROM_COMPLETION_COND_HPP | |
12 | #define BOOST_ASIO_DETAIL_BASE_FROM_COMPLETION_COND_HPP | |
13 | ||
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) | |
15 | # pragma once | |
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) | |
17 | ||
18 | #include <boost/asio/detail/config.hpp> | |
19 | #include <boost/asio/completion_condition.hpp> | |
20 | ||
21 | #include <boost/asio/detail/push_options.hpp> | |
22 | ||
23 | namespace boost { | |
24 | namespace asio { | |
25 | namespace detail { | |
26 | ||
27 | template <typename CompletionCondition> | |
28 | class base_from_completion_cond | |
29 | { | |
30 | protected: | |
31 | explicit base_from_completion_cond(CompletionCondition completion_condition) | |
32 | : completion_condition_(completion_condition) | |
33 | { | |
34 | } | |
35 | ||
36 | std::size_t check_for_completion( | |
37 | const boost::system::error_code& ec, | |
38 | std::size_t total_transferred) | |
39 | { | |
40 | return detail::adapt_completion_condition_result( | |
41 | completion_condition_(ec, total_transferred)); | |
42 | } | |
43 | ||
44 | private: | |
45 | CompletionCondition completion_condition_; | |
46 | }; | |
47 | ||
48 | template <> | |
49 | class base_from_completion_cond<transfer_all_t> | |
50 | { | |
51 | protected: | |
52 | explicit base_from_completion_cond(transfer_all_t) | |
53 | { | |
54 | } | |
55 | ||
56 | static std::size_t check_for_completion( | |
57 | const boost::system::error_code& ec, | |
58 | std::size_t total_transferred) | |
59 | { | |
60 | return transfer_all_t()(ec, total_transferred); | |
61 | } | |
62 | }; | |
63 | ||
64 | } // namespace detail | |
65 | } // namespace asio | |
66 | } // namespace boost | |
67 | ||
68 | #include <boost/asio/detail/pop_options.hpp> | |
69 | ||
70 | #endif // BOOST_ASIO_DETAIL_BASE_FROM_COMPLETION_COND_HPP |