executor.hpp
Go to the documentation of this file.
1 // Copyright (c) 2006, 2007 Julio M. Merino Vidal
2 // Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
3 // Copyright (c) 2009 Boris Schaeling
4 // Copyright (c) 2010 Felipe Tanus, Boris Schaeling
5 // Copyright (c) 2011, 2012 Jeff Flinn, Boris Schaeling
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 #pragma once
11 
13 #include <boost/fusion/algorithm/iteration/for_each.hpp>
14 #include <Windows.h>
15 
17 {
18 
19  struct executor
20  {
22  inherit_handles(FALSE),
23 #if (_WIN32_WINNT >= 0x0600)
24  creation_flags(EXTENDED_STARTUPINFO_PRESENT),
25 #else
26  creation_flags(0),
27 #endif
28  env(0), work_dir(0)
29 #if (_WIN32_WINNT >= 0x0600)
30  , startup_info(startup_info_ex.StartupInfo)
31 #endif
32  {
33 #if (_WIN32_WINNT >= 0x0600)
34  ZeroMemory(&startup_info_ex, sizeof(STARTUPINFOEX));
35  startup_info.cb = sizeof(STARTUPINFOEX);
36 #else
37  ZeroMemory(&startup_info, sizeof(STARTUPINFO));
38  startup_info.cb = sizeof(STARTUPINFO);
39 #endif
40  startup_info.hStdInput = INVALID_HANDLE_VALUE;
41  startup_info.hStdOutput = INVALID_HANDLE_VALUE;
42  startup_info.hStdError = INVALID_HANDLE_VALUE;
43  }
44 
46  {
48 
50 
51  template <class Arg>
52  void operator()(Arg& arg) const
53  {
54  arg.on_CreateProcess_setup(e_);
55  }
56  };
57 
59  {
61 
63 
64  template <class Arg>
65  void operator()(Arg& arg) const
66  {
67  arg.on_CreateProcess_error(e_);
68  }
69  };
70 
72  {
74 
76 
77  template <class Arg>
78  void operator()(Arg& arg) const
79  {
80  arg.on_CreateProcess_success(e_);
81  }
82  };
83 
84  template <class InitializerSequence>
85  child operator()(const InitializerSequence& seq)
86  {
87  boost::fusion::for_each(seq, call_on_CreateProcess_setup(*this));
88 
89  if (!::CreateProcess(
90  exe,
91  cmd_line,
92  proc_attrs,
96  env,
97  work_dir,
98  &startup_info,
99  &proc_info))
100  {
101  boost::fusion::for_each(seq, call_on_CreateProcess_error(*this));
102  }
103  else
104  {
105  boost::fusion::for_each(seq, call_on_CreateProcess_success(*this));
106  }
107 
108  return child(proc_info);
109  }
110 
111  LPCTSTR exe;
112  LPTSTR cmd_line;
113  LPSECURITY_ATTRIBUTES proc_attrs;
114  LPSECURITY_ATTRIBUTES thread_attrs;
117  LPVOID env;
118  LPCTSTR work_dir;
119 #if (_WIN32_WINNT >= 0x0600)
120  STARTUPINFOEX startup_info_ex;
121  STARTUPINFO& startup_info;
122 #else
123  STARTUPINFO startup_info;
124 #endif
125  PROCESS_INFORMATION proc_info;
126  };
127 
128 }
boost::process::windows::executor::operator()
child operator()(const InitializerSequence &seq)
Definition: executor.hpp:85
boost::process::windows::executor::call_on_CreateProcess_error::e_
executor & e_
Definition: executor.hpp:60
boost::process::windows
Definition: child.hpp:15
boost::process::windows::executor::call_on_CreateProcess_setup::operator()
void operator()(Arg &arg) const
Definition: executor.hpp:52
boost::process::windows::executor::proc_attrs
LPSECURITY_ATTRIBUTES proc_attrs
Definition: executor.hpp:113
boost::process::windows::executor::call_on_CreateProcess_success::operator()
void operator()(Arg &arg) const
Definition: executor.hpp:78
boost::process::windows::executor::work_dir
LPCTSTR work_dir
Definition: executor.hpp:118
boost::process::windows::executor::call_on_CreateProcess_success::e_
executor & e_
Definition: executor.hpp:73
boost::process::windows::child
Definition: child.hpp:18
boost::process::windows::executor::thread_attrs
LPSECURITY_ATTRIBUTES thread_attrs
Definition: executor.hpp:114
boost::process::windows::executor::call_on_CreateProcess_error::operator()
void operator()(Arg &arg) const
Definition: executor.hpp:65
boost::process::windows::executor::call_on_CreateProcess_setup::e_
executor & e_
Definition: executor.hpp:47
boost::process::windows::executor::cmd_line
LPTSTR cmd_line
Definition: executor.hpp:112
boost::process::windows::executor::call_on_CreateProcess_success
Definition: executor.hpp:71
boost::process::windows::executor::call_on_CreateProcess_setup::call_on_CreateProcess_setup
call_on_CreateProcess_setup(executor &e)
Definition: executor.hpp:49
boost::process::windows::executor::exe
LPCTSTR exe
Definition: executor.hpp:111
boost::process::windows::executor::proc_info
PROCESS_INFORMATION proc_info
Definition: executor.hpp:125
child.hpp
boost::process::windows::executor::env
LPVOID env
Definition: executor.hpp:117
if
if(!yyvaluep)
Definition: Grammar.cpp:724
boost::process::windows::executor::call_on_CreateProcess_setup
Definition: executor.hpp:45
boost::process::windows::executor::startup_info
STARTUPINFO startup_info
Definition: executor.hpp:123
boost::process::windows::executor::creation_flags
DWORD creation_flags
Definition: executor.hpp:116
boost::process::windows::executor::call_on_CreateProcess_success::call_on_CreateProcess_success
call_on_CreateProcess_success(executor &e)
Definition: executor.hpp:75
boost::process::windows::executor::inherit_handles
BOOL inherit_handles
Definition: executor.hpp:115
boost::process::windows::executor::executor
executor()
Definition: executor.hpp:21
else
else() message("You can set OpenCV_3_DIR to a directory OpenCV 3.1.") message("Using OpenCV_DIR
Definition: CMakeLists.txt:34
boost::process::windows::executor
Definition: executor.hpp:19
boost::process::windows::executor::call_on_CreateProcess_error
Definition: executor.hpp:58
boost::process::windows::executor::call_on_CreateProcess_error::call_on_CreateProcess_error
call_on_CreateProcess_error(executor &e)
Definition: executor.hpp:62
endif
endif() find_package(Simox QUIET) armarx_build_if(Simox_FOUND "Simox not available") find_package(PythonLibs 3.6 QUIET) armarx_build_if(PYTHONLIBS_FOUND "Python libs not available") if(PYTHONLIBS_FOUND) include_directories($
Definition: CMakeLists.txt:10