![]() |
Main Page
Class Hierarchy
Alphabetical List
Compound List
File List
Compound Members
![]() |
00001 /******************************************************************************** 00002 * * 00003 * Process event manager * 00004 * * 00005 ********************************************************************************* 00006 * Copyright (C) 2003 by Mathew Robertson. All Rights Reserved. * 00007 ********************************************************************************* 00008 * This library is free software; you can redistribute it and/or * 00009 * modify it under the terms of the GNU Lesser General Public * 00010 * License as published by the Free Software Foundation; either * 00011 * version 2.1 of the License, or (at your option) any later version. * 00012 * * 00013 * This library is distributed in the hope that it will be useful, * 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00016 * Lesser General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU Lesser General Public * 00019 * License along with this library; if not, write to the Free Software * 00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * 00021 ********************************************************************************/ 00022 #ifndef FXPROCESSMANAGER_H 00023 #define FXPROCESSMANAGER_H 00024 00025 #ifndef FXBASEOBJECT_H 00026 #include "FXBaseObject.h" 00027 #endif 00028 namespace FXEX { 00029 class FXProcess; 00030 00031 /// An FXProcessList is a list of FXProcess objects 00032 typedef FXArray<FXProcess*> FXProcessList; 00033 00034 00035 /** 00036 * A Process Manager is required to be created in the main process, since there may be a 00037 * number of child processes, each capable of delivering signals and stdout/stderr output 00038 * to the main process. As such, this needs special handling so that the correct FOX 00039 * event is generated for each child process event. 00040 * 00041 * FXProcessManager is a singleton object, ie you can only create one of them. 00042 */ 00043 class FXAPI FXProcessManager : public FXBaseObject { 00044 FXDECLARE(FXProcessManager) 00045 00046 private: 00047 FXProcessList processlist; // list of currently executing processes 00048 FXIntList pidlist; // list of currently executing processes, by process ID 00049 FXint last; // last pointed-to process 00050 00051 static FXProcessManager* manager; // process manager instance 00052 00053 protected: 00054 /// serialisation 00055 FXProcessManager(); 00056 00057 /// handle child exited signal 00058 void wait(); 00059 00060 public: 00061 enum { 00062 ID_PROCESS_MANAGER=FXBaseObject::ID_LAST, 00063 ID_CHILD_SIGNAL, 00064 ID_LAST 00065 }; 00066 00067 public: 00068 long onChildSignal(FXObject*,FXSelector,void*); 00069 00070 public: 00071 /** 00072 * Create a process manager 00073 * A process manager can itself generate FOX events 00074 */ 00075 FXProcessManager(FXApp *a,FXObject *tgt=NULL,FXSelector sel=0); 00076 00077 /// get the current process manager instance 00078 static FXProcessManager* instance(); 00079 00080 /// add a process to the list of managed processes 00081 void add(FXProcess *p); 00082 00083 /// remove an existing process 00084 void remove(FXProcess *p); 00085 00086 /// return the number of active processes (not including the main process) 00087 FXint size(); 00088 00089 /// return the next available process 00090 FXProcess* next(); 00091 00092 /// dtor 00093 virtual ~FXProcessManager(); 00094 }; 00095 00096 } // namespace FXEX 00097 #endif // FXPROCESSMANAGER_H