00001 /********** 00002 This library is free software; you can redistribute it and/or modify it under 00003 the terms of the GNU Lesser General Public License as published by the 00004 Free Software Foundation; either version 2.1 of the License, or (at your 00005 option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.) 00006 00007 This library is distributed in the hope that it will be useful, but WITHOUT 00008 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00009 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for 00010 more details. 00011 00012 You should have received a copy of the GNU Lesser General Public License 00013 along with this library; if not, write to the Free Software Foundation, Inc., 00014 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00015 **********/ 00016 // Copyright (c) 1996-2008 Live Networks, Inc. All rights reserved. 00017 // Basic Usage Environment: for a simple, non-scripted, console application 00018 // C++ header 00019 00020 #ifndef _BASIC_USAGE_ENVIRONMENT0_HH 00021 #define _BASIC_USAGE_ENVIRONMENT0_HH 00022 00023 #ifndef _BASICUSAGEENVIRONMENT_VERSION_HH 00024 #include "BasicUsageEnvironment_version.hh" 00025 #endif 00026 00027 #ifndef _USAGE_ENVIRONMENT_HH 00028 #include "UsageEnvironment.hh" 00029 #endif 00030 00031 #ifndef _DELAY_QUEUE_HH 00032 #include "DelayQueue.hh" 00033 #endif 00034 00035 #define RESULT_MSG_BUFFER_MAX 1000 00036 00037 // An abstract base class, useful for subclassing 00038 // (e.g., to redefine the implementation of "operator<<") 00039 class BasicUsageEnvironment0: public UsageEnvironment { 00040 public: 00041 // redefined virtual functions: 00042 virtual MsgString getResultMsg() const; 00043 00044 virtual void setResultMsg(MsgString msg); 00045 virtual void setResultMsg(MsgString msg1, 00046 MsgString msg2); 00047 virtual void setResultMsg(MsgString msg1, 00048 MsgString msg2, 00049 MsgString msg3); 00050 virtual void setResultErrMsg(MsgString msg); 00051 00052 virtual void appendToResultMsg(MsgString msg); 00053 00054 virtual void reportBackgroundError(); 00055 00056 protected: 00057 BasicUsageEnvironment0(TaskScheduler& taskScheduler); 00058 virtual ~BasicUsageEnvironment0(); 00059 00060 private: 00061 void reset(); 00062 00063 char fResultMsgBuffer[RESULT_MSG_BUFFER_MAX]; 00064 unsigned fCurBufferSize; 00065 unsigned fBufferMaxSize; 00066 }; 00067 00068 class HandlerSet; // forward 00069 00070 // An abstract base class, useful for subclassing 00071 // (e.g., to redefine the implementation of socket event handling) 00072 class BasicTaskScheduler0: public TaskScheduler { 00073 public: 00074 virtual ~BasicTaskScheduler0(); 00075 00076 virtual void SingleStep(unsigned maxDelayTime = 0) = 0; 00077 // "maxDelayTime" is in microseconds. It allows a subclass to impose a limit 00078 // on how long "select()" can delay, in case it wants to also do polling. 00079 // 0 (the default value) means: There's no maximum; just look at the delay queue 00080 00081 public: 00082 // Redefined virtual functions: 00083 virtual TaskToken scheduleDelayedTask(int64_t microseconds, TaskFunc* proc, 00084 void* clientData); 00085 virtual void unscheduleDelayedTask(TaskToken& prevTask); 00086 00087 virtual void doEventLoop(char* watchVariable); 00088 00089 protected: 00090 BasicTaskScheduler0(); 00091 00092 protected: 00093 // To implement delayed operations: 00094 DelayQueue fDelayQueue; 00095 00096 // To implement background reads: 00097 HandlerSet* fReadHandlers; 00098 int fLastHandledSocketNum; 00099 }; 00100 00101 #endif
1.5.2