ian@0: // ian@0: // Boost.Process ian@0: // ~~~~~~~~~~~~~ ian@0: // ian@0: // Copyright (c) 2006, 2007 Julio M. Merino Vidal ian@0: // Copyright (c) 2008 Ilya Sokolov, Boris Schaeling ian@0: // Copyright (c) 2009 Boris Schaeling ian@0: // Copyright (c) 2010 Felipe Tanus, Boris Schaeling ian@0: // ian@0: // Distributed under the Boost Software License, Version 1.0. (See accompanying ian@0: // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ian@0: // ian@0: ian@0: /** ian@0: * \file boost/process/child.hpp ian@0: * ian@0: * Includes the declaration of the child class. ian@0: */ ian@0: ian@0: #ifndef BOOST_PROCESS_CHILD_HPP ian@0: #define BOOST_PROCESS_CHILD_HPP ian@0: ian@0: #include ian@0: ian@0: #if defined(BOOST_POSIX_API) ian@0: #elif defined(BOOST_WINDOWS_API) ian@0: # include ian@0: #else ian@0: # error "Unsupported platform." ian@0: #endif ian@0: ian@0: #include ian@0: #include ian@0: #include ian@0: #include ian@0: #include ian@0: ian@0: namespace boost { ian@0: namespace process { ian@0: ian@0: /** ian@0: * The child class provides access to a child process. ian@0: */ ian@0: class child : public process ian@0: { ian@0: public: ian@0: /** ian@0: * Creates a new child object that represents the just spawned child ian@0: * process \a id. ian@0: */ ian@0: child(pid_type id, std::map handles) ian@0: : process(id), ian@0: handles_(handles) ian@0: { ian@0: } ian@0: ian@0: #if defined(BOOST_WINDOWS_API) ian@0: /** ian@0: * Creates a new child object that represents the just spawned child ian@0: * process \a id. ian@0: * ian@0: * This operation is only available on Windows systems. ian@0: */ ian@0: child(handle hprocess, std::map handles) ian@0: : process(hprocess), ian@0: handles_(handles) ian@0: { ian@0: } ian@0: #endif ian@0: ian@0: /** ian@0: * Gets a handle to a stream attached to the child. ian@0: * ian@0: * If the handle doesn't exist an invalid handle is returned. ian@0: */ ian@0: handle get_handle(stream_id id) const ian@0: { ian@0: std::map::const_iterator it = handles_.find(id); ian@0: return (it != handles_.end()) ? it->second : handle(); ian@0: } ian@0: ian@0: private: ian@0: /** ian@0: * Handles providing access to streams attached to the child process. ian@0: */ ian@0: std::map handles_; ian@0: }; ian@0: ian@0: } ian@0: } ian@0: ian@0: #endif