Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

Manager.h

Go to the documentation of this file.
00001 #ifndef Impala_Process_Manager_h
00002 #define Impala_Process_Manager_h
00003 
00004 namespace Impala
00005 {
00006 namespace Process
00007 {
00008 
00009 /****************************************************************************
00010 This class serves as an interface for implementations of process management.
00011 *****************************************************************************/
00012 
00013 class Manager
00014 {
00015 
00016 public:
00017 
00018     // process state codes:
00019     static const int STATE_RUNNING = -1;
00020     static const int STATE_TERM_SUCCESS = 0;
00021     static const int STATE_TERM_ERROR = 1;
00022     static const int STATE_TERM_ABNORMAL = 2;
00023     static const int STATE_UNKNOWN = 9;
00024 
00025     static const int WAIT_INTERVAL_SEC = 5;
00026 
00027     virtual ~Manager()
00028     {
00029     }
00030 
00031     // Creates a process for the specified command line.
00032     // See the CreateProcess() function of the Win platform SDK for info on setting application and cmd line.
00033     // Returns handle for referencing the created process upon successful creation; 0 otherwise.
00034     virtual int Create(const std::string& cmdLine, std::string application = "") = 0;
00035 
00036     virtual int GetManagedProcessCount() const = 0;
00037 
00038     virtual bool IsRunning(int handle) = 0;
00039 
00040     // Did the process terminate with or witout errors, or forced?
00041     virtual bool IsTerminated(int handle) = 0;
00042 
00043     // Makes the manager sleep, and return on wakeup.
00044     virtual void Sleep(int sec) = 0;
00045 
00046     // Blocks until the process completes, crashes,
00047     // or runs longer than its specified max something (SK). 
00048     // Returns the process' termination code.
00049     //virtual int WaitFor(int handle) = 0; // SK: not used
00050 
00051     // Attempts to kill the process for the specified handle.
00052     virtual void Kill(int handle) = 0;
00053 
00054     // If necessary kills and then removes the process for the specified handle from the manager.
00055     virtual void Remove(int handle) = 0;
00056 
00057     // Is the process still running, did it terminate successfully, with errors or abnormally?
00058     virtual int GetState(int handle) = 0;
00059 
00060     // Returns the process' exit code as returned by the OS
00061     virtual int GetExitCode(int handle) = 0;
00062 
00063 protected:
00064 
00065 private:
00066 
00067 }; // class
00068 
00069 } // namespace 
00070 } // namespace 
00071 
00072 #endif

Generated on Fri Mar 19 09:31:29 2010 for ImpalaSrc by  doxygen 1.5.1