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