浏览代码

Implemented child.hpp.

git-svn-id: https://svn.microneil.com/svn/CodeDweller/branches/adeniz_1@29 d34b734f-a00e-4b39-a726-e4eeb87269ab
adeniz_1
adeniz 10 年前
父节点
当前提交
1fac3ab4bc
共有 2 个文件被更改,包括 173 次插入0 次删除
  1. 55
    0
      child.cpp
  2. 118
    0
      child.hpp

+ 55
- 0
child.cpp 查看文件

@@ -0,0 +1,55 @@
// child.cpp
// Copyright (C) 2014 MicroNeil Research Corporation.
//
// This program is part of the MicroNeil Research Open Library Project. For
// more information go to http://www.microneil.com/OpenLibrary/index.html
//
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2 of the License, or (at your
// option) any later version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
// more details.
//
// You should have received a copy of the GNU General Public License along with
// this program; if not, write to the Free Software Foundation, Inc., 59 Temple
// Place, Suite 330, Boston, MA 02111-1307 USA
//==============================================================================
// See child.hpp for notes.
#include <stdexcept>
#include "child.hpp"
namespace CodeDweller {
Child::Child(std::vector<std::string> args) {
}
Child::Child(std::string childpath) {
}
Child::~Child() {
}
void
Child::run() {
throw std::runtime_error("Not implemented");
}
void
Child::terminate() {
throw std::runtime_error("Not implemented");
}
int32_t
Child::result() {
throw std::runtime_error("Not implemented");
return 0;
}
}

+ 118
- 0
child.hpp 查看文件

@@ -0,0 +1,118 @@
/// \file child.hpp
//
// Copyright (C) 2014 MicroNeil Research Corporation.
//
// This program is part of the MicroNeil Research Open Library Project. For
// more information go to http://www.microneil.com/OpenLibrary/index.html
//
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2 of the License, or (at your
// option) any later version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
// more details.
//
// You should have received a copy of the GNU General Public License along with
// this program; if not, write to the Free Software Foundation, Inc., 59 Temple
// Place, Suite 330, Boston, MA 02111-1307 USA
//==============================================================================

/*
\brief The child module provides classes to spawn and communicate
with child processes.
*/

#ifndef CHILD_HPP
#define CHILD_HPP

#include <cstdint>
#include <istream>
#include <ostream>
#include <string>
#include <vector>

namespace CodeDweller {

/**
\namespace CodeDweller

The CodeDweller namespace contains components providing high-level
functionality for applications.

*/

/** Class that abstracts the creation of child processes.

This class provides functionality to create a child process,
communicate with the child process via streams and signals, and
obtain the exit code of the child process.

*/

class Child {

public:

/** Constructor for spawning with command-line parameters.

The constructor configures the object, but doesn't spawn the
child process.

\param[in] args contains the child executable file name and
command-line parameters. args[0] contains the full path of the
executable, and args[1] thru args[n] are the command-line
parameters.

*/
Child(std::vector<std::string> args);

/** Constructor for spawning without command-line parameters.

The constructor configures the object, but doesn't spawn the
child process.

\param[in] childpath contains the child executable file name.

*/
Child(std::string childpath);

/** Destructor terminates the child process. */
~Child();

/// Stream that is seen by the child as standard output.
std::istream reader;

/// Stream that is seen by the child as standard input.
std::ostream writer;

/** Spawn the child process.

If an error occurs, an exception is thrown.

*/
void run();

/** Terminite the child process.

If an error occurs, an exception is thrown.

*/
void terminate();

/** Get the exit value of the child process.

\returns The exit value of the child process if the child
process has exited. If the child process has not exited, an
exception is thrown.

*/
int32_t result();

};

}

#endif // CHILD_HPP

正在加载...
取消
保存