live
BasicUsageEnvironment.hh
Go to the documentation of this file.
1/**********
2This library is free software; you can redistribute it and/or modify it under
3the terms of the GNU Lesser General Public License as published by the
4Free Software Foundation; either version 3 of the License, or (at your
5option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
6
7This library is distributed in the hope that it will be useful, but WITHOUT
8ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
10more details.
11
12You should have received a copy of the GNU Lesser General Public License
13along with this library; if not, write to the Free Software Foundation, Inc.,
1451 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15**********/
16// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
17// Basic Usage Environment: for a simple, non-scripted, console application
18// C++ header
19
20#ifndef _BASIC_USAGE_ENVIRONMENT_HH
21#define _BASIC_USAGE_ENVIRONMENT_HH
22
23#ifndef _BASIC_USAGE_ENVIRONMENT0_HH
25#endif
26
28public:
30
31 // redefined virtual functions:
32 virtual int getErrno() const;
33
34 virtual UsageEnvironment& operator<<(char const* str);
36 virtual UsageEnvironment& operator<<(unsigned u);
37 virtual UsageEnvironment& operator<<(double d);
38 virtual UsageEnvironment& operator<<(void* p);
39
40protected:
42 // called only by "createNew()" (or subclass constructors)
44};
45
46
48public:
49 static BasicTaskScheduler* createNew(unsigned maxSchedulerGranularity = 10000/*microseconds*/);
50 // "maxSchedulerGranularity" (default value: 10 ms) specifies the maximum time that we wait (in "select()") before
51 // returning to the event loop to handle non-socket or non-timer-based events, such as 'triggered events'.
52 // You can change this is you wish (but only if you know what you're doing!), or set it to 0, to specify no such maximum time.
53 // (You should set it to 0 only if you know that you will not be using 'event triggers'.)
55
56protected:
57 BasicTaskScheduler(unsigned maxSchedulerGranularity);
58 // called only by "createNew()"
59
60 static void schedulerTickTask(void* clientData);
62
63protected:
64 // Redefined virtual functions:
65 virtual void SingleStep(unsigned maxDelayTime);
66
67 virtual void setBackgroundHandling(int socketNum, int conditionSet, BackgroundHandlerProc* handlerProc, void* clientData);
68 virtual void moveSocketHandling(int oldSocketNum, int newSocketNum);
69
70protected:
72
73 // To implement background operations:
75 fd_set fReadSet;
76 fd_set fWriteSet;
78
79private:
80#if defined(__WIN32__) || defined(_WIN32)
81 // Hack to work around a bug in Windows' "select()" implementation:
82 int fDummySocketNum;
83#endif
84};
85
86#endif
static void schedulerTickTask(void *clientData)
virtual ~BasicTaskScheduler()
static BasicTaskScheduler * createNew(unsigned maxSchedulerGranularity=10000)
virtual void SingleStep(unsigned maxDelayTime)
virtual void setBackgroundHandling(int socketNum, int conditionSet, BackgroundHandlerProc *handlerProc, void *clientData)
BasicTaskScheduler(unsigned maxSchedulerGranularity)
virtual void moveSocketHandling(int oldSocketNum, int newSocketNum)
virtual UsageEnvironment & operator<<(void *p)
virtual UsageEnvironment & operator<<(double d)
static BasicUsageEnvironment * createNew(TaskScheduler &taskScheduler)
virtual UsageEnvironment & operator<<(char const *str)
virtual int getErrno() const
virtual UsageEnvironment & operator<<(int i)
virtual UsageEnvironment & operator<<(unsigned u)
virtual ~BasicUsageEnvironment()
BasicUsageEnvironment(TaskScheduler &taskScheduler)
void BackgroundHandlerProc(void *clientData, int mask)
TaskScheduler & taskScheduler() const