// Copyright (c) 2016 Klemens D. Morgenstern // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_PROCESS_DETAIL_USED_HANDLES_HPP_ #define BOOST_PROCESS_DETAIL_USED_HANDLES_HPP_ #include #include #include #if defined(BOOST_POSIX_API) #include #include #else #include #include #endif namespace boost { namespace process { namespace detail { struct uses_handles { //If you get an error here, you must add a `get_handles` function that returns a range or a single handle value void get_used_handles() const; }; template struct does_use_handle: std::is_base_of {}; template struct does_use_handle : std::is_base_of {}; template struct does_use_handle : std::is_base_of {}; template class executor; template struct foreach_handle_invocator { Func & func; foreach_handle_invocator(Func & func) : func(func) {} template void invoke(const Range & range) const { for (auto handle_ : range) func(handle_); } void invoke(::boost::process::detail::api::native_handle_type handle) const {func(handle);}; template void operator()(T & val) const {invoke(val.get_used_handles());} }; template void foreach_used_handle(Executor &exec, Function &&func) { boost::fusion::for_each(boost::fusion::filter_if>(exec.seq), foreach_handle_invocator(func)); } template std::vector<::boost::process::detail::api::native_handle_type> get_used_handles(Executor &exec) { std::vector<::boost::process::detail::api::native_handle_type> res; foreach_used_handle(exec, [&](::boost::process::detail::api::native_handle_type handle){res.push_back(handle);}); return res; } }}} #endif /* BOOST_PROCESS_DETAIL_USED_HANDLES_HPP_ */