1 /** 2 Support for running stopping of project executable. 3 4 */ 5 module ddebug.common.execution; 6 7 enum ExecutionStatus { 8 NotStarted, 9 Running, 10 Finished, // finished normally 11 Killed, // killed 12 Error // error while trying to start program 13 } 14 15 interface ProgramExecutionStatusListener { 16 /// called when program execution is stopped 17 void onProgramExecutionStatus(ProgramExecution process, ExecutionStatus status, int exitCode); 18 } 19 20 // Interface to run program and control program execution 21 interface ProgramExecution { 22 /// set executable parameters before execution 23 void setExecutableParams(string executableFile, string[] args, string workingDir, string[string] envVars); 24 /// set external terminal parameters before execution 25 void setTerminalExecutable(string terminalExecutable); 26 /// set external terminal tty before execution 27 void setTerminalTty(string terminalTty); 28 29 /// returns true if it's debugger 30 @property bool isDebugger(); 31 /// returns true if it's mago debugger 32 @property bool isMagoDebugger(); 33 /// executable file 34 @property string executableFile(); 35 /// returns execution status 36 //@property ExecutionStatus status(); 37 /// start execution 38 void run(); 39 /// stop execution 40 void stop(); 41 } 42 43 /// provides _executableFile, _executableArgs, _executableWorkingDir, _executableEnvVars parameters and setter function setExecutableParams 44 mixin template ExecutableParams() { 45 protected string _executableFile; 46 protected string[] _executableArgs; 47 protected string _executableWorkingDir; 48 protected string[string] _executableEnvVars; 49 50 /// set executable parameters before execution 51 void setExecutableParams(string executableFile, string[] args, string workingDir, string[string] envVars) { 52 _executableFile = executableFile; 53 _executableArgs = args; 54 _executableWorkingDir = workingDir; 55 _executableEnvVars = envVars; 56 } 57 } 58 59 60 /// provides _terminalExecutable, _terminalTty, setTerminalExecutable, and setTerminalTty 61 mixin template TerminalParams() { 62 63 /// executable file name for external console/terminal 64 protected string _terminalExecutable; 65 protected string _terminalTty; 66 67 /// set external terminal parameters before execution 68 void setTerminalExecutable(string terminalExecutable) { 69 _terminalExecutable = terminalExecutable; 70 } 71 72 void setTerminalTty(string terminalTty) { 73 _terminalTty = terminalTty; 74 } 75 } 76