comparison third_party/boost/process/child.hpp @ 0:add35537fdbb tip

Initial import
author irh <ian.r.hobson@gmail.com>
date Thu, 25 Aug 2011 11:05:55 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:add35537fdbb
1 //
2 // Boost.Process
3 // ~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2006, 2007 Julio M. Merino Vidal
6 // Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
7 // Copyright (c) 2009 Boris Schaeling
8 // Copyright (c) 2010 Felipe Tanus, Boris Schaeling
9 //
10 // Distributed under the Boost Software License, Version 1.0. (See accompanying
11 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
12 //
13
14 /**
15 * \file boost/process/child.hpp
16 *
17 * Includes the declaration of the child class.
18 */
19
20 #ifndef BOOST_PROCESS_CHILD_HPP
21 #define BOOST_PROCESS_CHILD_HPP
22
23 #include <boost/process/config.hpp>
24
25 #if defined(BOOST_POSIX_API)
26 #elif defined(BOOST_WINDOWS_API)
27 # include <windows.h>
28 #else
29 # error "Unsupported platform."
30 #endif
31
32 #include <boost/process/process.hpp>
33 #include <boost/process/pid_type.hpp>
34 #include <boost/process/stream_id.hpp>
35 #include <boost/process/handle.hpp>
36 #include <map>
37
38 namespace boost {
39 namespace process {
40
41 /**
42 * The child class provides access to a child process.
43 */
44 class child : public process
45 {
46 public:
47 /**
48 * Creates a new child object that represents the just spawned child
49 * process \a id.
50 */
51 child(pid_type id, std::map<stream_id, handle> handles)
52 : process(id),
53 handles_(handles)
54 {
55 }
56
57 #if defined(BOOST_WINDOWS_API)
58 /**
59 * Creates a new child object that represents the just spawned child
60 * process \a id.
61 *
62 * This operation is only available on Windows systems.
63 */
64 child(handle hprocess, std::map<stream_id, handle> handles)
65 : process(hprocess),
66 handles_(handles)
67 {
68 }
69 #endif
70
71 /**
72 * Gets a handle to a stream attached to the child.
73 *
74 * If the handle doesn't exist an invalid handle is returned.
75 */
76 handle get_handle(stream_id id) const
77 {
78 std::map<stream_id, handle>::const_iterator it = handles_.find(id);
79 return (it != handles_.end()) ? it->second : handle();
80 }
81
82 private:
83 /**
84 * Handles providing access to streams attached to the child process.
85 */
86 std::map<stream_id, handle> handles_;
87 };
88
89 }
90 }
91
92 #endif