live
BasicUsageEnvironment0.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-2023 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_ENVIRONMENT0_HH
21#define _BASIC_USAGE_ENVIRONMENT0_HH
22
23#ifndef _BASICUSAGEENVIRONMENT_VERSION_HH
25#endif
26
27#ifndef _USAGE_ENVIRONMENT_HH
28#include "UsageEnvironment.hh"
29#endif
30
31#ifndef _DELAY_QUEUE_HH
32#include "DelayQueue.hh"
33#endif
34
35#define RESULT_MSG_BUFFER_MAX 1000
36
37// An abstract base class, useful for subclassing
38// (e.g., to redefine the implementation of "operator<<")
40public:
41 // redefined virtual functions:
42 virtual MsgString getResultMsg() const;
43
44 virtual void setResultMsg(MsgString msg);
45 virtual void setResultMsg(MsgString msg1,
46 MsgString msg2);
47 virtual void setResultMsg(MsgString msg1,
48 MsgString msg2,
49 MsgString msg3);
50 virtual void setResultErrMsg(MsgString msg, int err = 0);
51
52 virtual void appendToResultMsg(MsgString msg);
53
54 virtual void reportBackgroundError();
55
56protected:
59
60private:
61 void reset();
62
66};
67
68class HandlerSet; // forward
69
70#define MAX_NUM_EVENT_TRIGGERS 32
71
72// An abstract base class, useful for subclassing
73// (e.g., to redefine the implementation of socket event handling)
75public:
77
78 virtual void SingleStep(unsigned maxDelayTime = 0) = 0;
79 // "maxDelayTime" is in microseconds. It allows a subclass to impose a limit
80 // on how long "select()" can delay, in case it wants to also do polling.
81 // 0 (the default value) means: There's no maximum; just look at the delay queue
82
83public:
84 // Redefined virtual functions:
85 virtual TaskToken scheduleDelayedTask(int64_t microseconds, TaskFunc* proc,
86 void* clientData);
87 virtual void unscheduleDelayedTask(TaskToken& prevTask);
88
89 virtual void doEventLoop(char volatile* watchVariable);
90
91 virtual EventTriggerId createEventTrigger(TaskFunc* eventHandlerProc);
92 virtual void deleteEventTrigger(EventTriggerId eventTriggerId);
93 virtual void triggerEvent(EventTriggerId eventTriggerId, void* clientData = NULL);
94
95protected:
97
98protected:
99 // To implement delayed operations:
102
103 // To implement background reads:
106
107 // To implement event triggers:
108 EventTriggerId volatile fTriggersAwaitingHandling; // implemented as a 32-bit bitmap
109 EventTriggerId fLastUsedTriggerMask; // implemented as a 32-bit bitmap
112 unsigned fLastUsedTriggerNum; // in the range [0,MAX_NUM_EVENT_TRIGGERS)
113};
114
115#endif
#define MAX_NUM_EVENT_TRIGGERS
#define RESULT_MSG_BUFFER_MAX
#define NULL
void TaskFunc(void *clientData)
u_int32_t EventTriggerId
void * TaskToken
virtual EventTriggerId createEventTrigger(TaskFunc *eventHandlerProc)
void * fTriggeredEventClientDatas[MAX_NUM_EVENT_TRIGGERS]
virtual void unscheduleDelayedTask(TaskToken &prevTask)
virtual void SingleStep(unsigned maxDelayTime=0)=0
EventTriggerId volatile fTriggersAwaitingHandling
virtual void deleteEventTrigger(EventTriggerId eventTriggerId)
virtual void triggerEvent(EventTriggerId eventTriggerId, void *clientData=NULL)
virtual ~BasicTaskScheduler0()
TaskFunc * fTriggeredEventHandlers[MAX_NUM_EVENT_TRIGGERS]
virtual void doEventLoop(char volatile *watchVariable)
virtual TaskToken scheduleDelayedTask(int64_t microseconds, TaskFunc *proc, void *clientData)
EventTriggerId fLastUsedTriggerMask
virtual void setResultMsg(MsgString msg)
virtual void setResultMsg(MsgString msg1, MsgString msg2, MsgString msg3)
char fResultMsgBuffer[RESULT_MSG_BUFFER_MAX]
BasicUsageEnvironment0(TaskScheduler &taskScheduler)
virtual MsgString getResultMsg() const
virtual void setResultErrMsg(MsgString msg, int err=0)
virtual ~BasicUsageEnvironment0()
virtual void appendToResultMsg(MsgString msg)
virtual void setResultMsg(MsgString msg1, MsgString msg2)
virtual void reportBackgroundError()
char const * MsgString
TaskScheduler & taskScheduler() const