Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Source / CTest / cmProcess.h
blob788b33efb29064bdf3b895ffff9c7bef9b59e78e
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmProcess.h,v $
5 Language: C++
6 Date: $Date: 2008-12-29 22:49:17 $
7 Version: $Revision: 1.3 $
9 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
10 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
17 #ifndef cmProcess_h
18 #define cmProcess_h
21 #include "cmStandardIncludes.h"
22 #include <cmsys/Process.h>
25 /** \class cmProcess
26 * \brief run a process with c++
28 * cmProcess wraps the kwsys process stuff in a c++ class.
30 class cmProcess
32 public:
33 cmProcess();
34 ~cmProcess();
35 const char* GetCommand() { return this->Command.c_str();}
36 void SetCommand(const char* command);
37 void SetCommandArguments(std::vector<std::string> const& arg);
38 void SetWorkingDirectory(const char* dir) { this->WorkingDirectory = dir;}
39 void SetTimeout(double t) { this->Timeout = t;}
40 // Return true if the process starts
41 bool StartProcess();
43 // return process state
44 int CheckOutput(double timeout,
45 std::string& stdOutLine,
46 std::string& stdErrLine);
47 // return the process status
48 int GetProcessStatus();
49 // return true if the process is running
50 bool IsRunning();
51 // Report the status of the program
52 int ReportStatus();
53 int GetId() { return this->Id; }
54 void SetId(int id) { this->Id = id;}
55 int GetExitValue() { return this->ExitValue;}
56 private:
57 int LastOutputPipe;
58 double Timeout;
59 double StartTime;
60 double TotalTime;
61 cmsysProcess* Process;
62 std::vector<char> StdErrorBuffer;
63 std::vector<char> StdOutBuffer;
64 std::string Command;
65 std::string WorkingDirectory;
66 std::vector<std::string> Arguments;
67 std::vector<const char*> ProcessArgs;
68 std::string Output;
69 int Id;
70 int ExitValue;
73 #endif