00001 /* 00002 * PROPRIETARY INFORMATION. This software is proprietary to 00003 * Side Effects Software Inc., and is not to be reproduced, 00004 * transmitted, or disclosed in any way without written permission. 00005 * 00006 * Produced by: 00007 * Mark Elendt 00008 * Side Effects Software Inc 00009 * 477 Richmond Street West 00010 * Toronto, Ontario 00011 * Canada M5V 3E7 00012 * 416-504-9876 00013 * 00014 * COMMENTS: 00015 * This class lets you read a line with a UT_CmdLineReader while 00016 * waiting for events from FS_EventGenerators. 00017 */ 00018 00019 #ifndef __CMD_EvtMonitoringReader_h__ 00020 #define __CMD_EvtMonitoringReader_h__ 00021 00022 #include "CMD_API.h" 00023 00024 #include <UT/UT_SysClone.h> 00025 #include <UT/UT_PtrArray.h> 00026 00027 class UT_CmdLineReader; 00028 class UT_WorkBuffer; 00029 class FS_EventGenerator; 00030 class cmd_PollingEvtGeneratorWrapper; 00031 00032 class CMD_API CMD_EvtMonitoringReader 00033 { 00034 public: 00035 00036 // The singleton instance of this class will only be created if the 00037 // static inst() method is called. When the instance is created, 00038 // it will register itself as the place where all generators should 00039 // be installed. 00040 static CMD_EvtMonitoringReader& inst(); 00041 00042 // Read a line of input using the command line reader into the buffer, 00043 // processing any events generated by installed event generators. 00044 // Returns true if a line of input was read. 00045 enum GetlineResult { SUCCESS, FAILED, INTERRUPTED }; 00046 GetlineResult getline(UT_CmdLineReader &cmdline_reader, UT_WorkBuffer &buf); 00047 00048 private: 00049 static int installGeneratorCallback(FS_EventGenerator *generator, int mode); 00050 static void pollEventGeneratorsCallback(bool /*drain_queue*/); 00051 00052 int installGenerator(FS_EventGenerator &gen, int mode); 00053 void pollEventGenerators(); 00054 00055 CMD_EvtMonitoringReader(); 00056 00057 UT_PtrArray<cmd_PollingEvtGeneratorWrapper*> myEventGenerators; 00058 }; 00059 00060 #endif 00061
1.5.9