]> git.tdb.fi Git - builder.git/blob - source/externaltask.h
Allow omitting workdir in ExternalTask constructor call
[builder.git] / source / externaltask.h
1 #ifndef EXTERNALTASK_H_
2 #define EXTERNALTASK_H_
3
4 #include <string>
5 #include <vector>
6 #include <msp/fs/path.h>
7 #include <msp/io/pipe.h>
8 #include "task.h"
9
10 class ExternalTask: public Task
11 {
12 public:
13         enum Destination
14         {
15                 PASSTHROUGH,
16                 CAPTURE,
17                 IGNORE
18         };
19
20         typedef std::vector<std::string> Arguments;
21
22 private:
23         Arguments argv;
24         Msp::FS::Path work_dir;
25         int pid;
26         int exit_code;
27         Destination stdout_dest;
28         Destination stderr_dest;
29         Msp::IO::Pipe *capture_pipe;
30         std::string output;
31
32 public:
33         ExternalTask(const Arguments &, const Msp::FS::Path & = Msp::FS::Path());
34         virtual ~ExternalTask();
35
36         virtual std::string get_command() const;
37         virtual void start();
38         virtual Status check();
39
40         void set_stdout(Destination);
41         void set_stderr(Destination);
42         const std::string &get_output() const { return output; }
43 };
44
45 #endif