hce-node application  1.4.3
HCE Hierarchical Cluster Engine node application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ProcExec.hpp
Go to the documentation of this file.
1 
14 #ifndef PROC_EXEC_HPP
15 #define PROC_EXEC_HPP
16 
17 #include <iostream>
18 #include <Poco/Process.h>
19 
20 namespace HCE
21 {
22 //-----------------------------------------------------------------------------
23 class ProcExec
24 {
25 public:
26  explicit ProcExec(const std::string& command_);
27  ProcExec(const std::string& command_, const Poco::Process::Args& args_);
28  ProcExec(const std::string& command_, const Poco::Process::Args& args_, const Poco::Process::Env& env_);
29  virtual ~ProcExec(void) {};
30 
31  bool exec(std::ostream& os=std::cout, std::ostream& es=std::cerr);
32 
33  void setCommand(const std::string& command_) {command=command_;}
34  std::string getCommand(void) const {return command;}
35 
36  void setArgs(const Poco::Process::Args& args_) {args=args_;}
37  Poco::Process::Args& getArgs(void) {return args;}
38 
39  void setEnv(const Poco::Process::Env& env_) {env=env_;}
40  Poco::Process::Env& getEnv(void) {return env;}
41 
42  void setInitialDirectory(const std::string& initialDirectory_) {initialDirectory=initialDirectory_;}
43  std::string getInitialDirectory(void) const {return initialDirectory;}
44 
45  bool isError(void) const {return _IsError;}
46  unsigned int getExitStatus(void) const {return exitStatus;}
47 private:
48  std::string command;
49  Poco::Process::Args args;
50  Poco::Process::Env env;
51  std::string initialDirectory;
52  bool _IsError;
53  unsigned int exitStatus;
54 
55 
56  friend std::ostream& operator << (std::ostream& os, const ProcExec& procExec);
57  friend std::string& operator << (std::string& str, const ProcExec& procExec);
58 };
59 //-----------------------------------------------------------------------------
60 //-----------------------------------------------------------------------------
61 } // end namespace HCE
62 
63 #endif // PROC_EXEC_HPP
64