1 // Copyright (c) 2016 Klemens D. Morgenstern 2 // 3 // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 6 7 #ifndef BOOST_PROCESS_DETAIL_HANDLER_HPP_ 8 #define BOOST_PROCESS_DETAIL_HANDLER_HPP_ 9 10 #include <boost/process/detail/config.hpp> 11 12 #if defined(BOOST_POSIX_API) 13 #include <boost/process/detail/posix/handler.hpp> 14 #elif defined(BOOST_WINDOWS_API) 15 #include <boost/process/detail/windows/handler.hpp> 16 #endif 17 18 19 namespace boost { namespace process { namespace detail { 20 21 //extended handler base. 22 typedef api::handler_base_ext handler; 23 24 25 template <class Handler> 26 struct on_setup_ : handler 27 { on_setup_boost::process::detail::on_setup_28 explicit on_setup_(Handler handler) : handler_(handler) {} 29 30 template <class Executor> on_setupboost::process::detail::on_setup_31 void on_setup(Executor &e) 32 { 33 handler_(e); 34 } 35 private: 36 Handler handler_; 37 }; 38 39 template <class Handler> 40 struct on_error_ : handler 41 { on_error_boost::process::detail::on_error_42 explicit on_error_(Handler handler) : handler_(handler) {} 43 44 template <class Executor> on_errorboost::process::detail::on_error_45 void on_error(Executor &e, const std::error_code &ec) 46 { 47 handler_(e, ec); 48 } 49 private: 50 Handler handler_; 51 }; 52 53 template <class Handler> 54 struct on_success_ : handler 55 { on_success_boost::process::detail::on_success_56 explicit on_success_(Handler handler) : handler_(handler) {} 57 58 template <class Executor> on_successboost::process::detail::on_success_59 void on_success(Executor &e) 60 { 61 handler_(e); 62 } 63 private: 64 Handler handler_; 65 }; 66 67 } 68 69 70 71 }} 72 73 74 75 #endif /* BOOST_PROCESS_DETAIL_HANDLER_HPP_ */ 76