Added check for rubbish move multipliers
[progcomp2012.git] / judge / manager / program.h
1 #ifndef PROGRAM_H
2 #define PROGRAM_H
3
4 #include "thread_util.h"
5
6 #include <string>
7 #include <unistd.h> //Needed to check permissions
8
9 /**
10  * A wrapping class for an external program, which can exchange messages with the current process through stdin/stdout
11  * Useful for attaching control of an operation to an external process - for example, AI for a game
12  */
13 class Program
14 {
15         public:
16                 Program(const char * executeablePath); //Constructor
17                 virtual ~Program(); //Destructor
18
19
20
21
22                 bool SendMessage(const char * print, ...); //Sends a formated message (NOTE: Prints a newline)
23                 bool SendMessage(const std::string & buffer) {return SendMessage(buffer.c_str());} //Sends a C++ string message
24                 bool GetMessage(std::string & buffer, double timeout=-1); //Retrieves a message, or waits for a timeout (if positive)
25
26                 bool Running() const;
27                 bool Paused() const;
28                 bool Pause();
29                 bool Continue();
30                 
31
32         protected:
33                 FILE * input;   //Stream used for sending information TO the process
34                 FILE * output; //Stream used for retrieving information FROM the process
35
36         private:
37                 pid_t pid; //Process ID of the program wrapped
38                 bool paused;
39                 
40 };
41
42 #endif //PROGRAM_H
43
44

UCC git Repository :: git.ucc.asn.au