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-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_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#ifndef NO_STD_LIB
36#ifndef _LIBCPP_ATOMIC
37#include <atomic>
38#endif
39#endif
40
41#define RESULT_MSG_BUFFER_MAX 1000
42
43// An abstract base class, useful for subclassing
44// (e.g., to redefine the implementation of "operator<<")
46public:
47 // redefined virtual functions:
48 virtual MsgString getResultMsg() const;
49
50 virtual void setResultMsg(MsgString msg);
51 virtual void setResultMsg(MsgString msg1,
52 MsgString msg2);
53 virtual void setResultMsg(MsgString msg1,
54 MsgString msg2,
55 MsgString msg3);
56 virtual void setResultErrMsg(MsgString msg, int err = 0);
57
58 virtual void appendToResultMsg(MsgString msg);
59
60 virtual void reportBackgroundError();
61
62protected:
65
66private:
67 void reset();
68
72};
73
74class HandlerSet; // forward
75
76// Note: You may redefine MAX_NUM_EVENT_TRIGGERS,
77// but it must be <= the number of bits in an "EventTriggerId"
78#ifndef MAX_NUM_EVENT_TRIGGERS
79#define MAX_NUM_EVENT_TRIGGERS 32
80#endif
81#define EVENT_TRIGGER_ID_HIGH_BIT (1 << (MAX_NUM_EVENT_TRIGGERS-1))
82
83// An abstract base class, useful for subclassing
84// (e.g., to redefine the implementation of socket event handling)
86public:
88
89 virtual void SingleStep(unsigned maxDelayTime = 0) = 0;
90 // "maxDelayTime" is in microseconds. It allows a subclass to impose a limit
91 // on how long "select()" can delay, in case it wants to also do polling.
92 // 0 (the default value) means: There's no maximum; just look at the delay queue
93
94public:
95 // Redefined virtual functions:
96 virtual TaskToken scheduleDelayedTask(int64_t microseconds, TaskFunc* proc,
97 void* clientData);
98 virtual void unscheduleDelayedTask(TaskToken& prevTask);
99
100 virtual void doEventLoop(char volatile* watchVariable);
101
102 virtual EventTriggerId createEventTrigger(TaskFunc* eventHandlerProc);
103 virtual void deleteEventTrigger(EventTriggerId eventTriggerId);
104 virtual void triggerEvent(EventTriggerId eventTriggerId, void* clientData = NULL);
105
106protected:
108
109protected:
110 // To implement delayed operations:
113
114 // To implement background reads:
117
118 // To implement event triggers:
119#ifndef NO_STD_LIB
121#else
123#endif
124 u_int32_t fLastUsedTriggerMask; // implemented as a 32-bit bitmap
127 unsigned fLastUsedTriggerNum; // in the range [0,MAX_NUM_EVENT_TRIGGERS)
129};
130
131#endif
#define MAX_NUM_EVENT_TRIGGERS
#define RESULT_MSG_BUFFER_MAX
unsigned char Boolean
Definition: Boolean.hh:25
#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
virtual void deleteEventTrigger(EventTriggerId eventTriggerId)
virtual void triggerEvent(EventTriggerId eventTriggerId, void *clientData=NULL)
virtual ~BasicTaskScheduler0()
TaskFunc * fTriggeredEventHandlers[MAX_NUM_EVENT_TRIGGERS]
std::atomic_flag fTriggersAwaitingHandling[MAX_NUM_EVENT_TRIGGERS]
virtual void doEventLoop(char volatile *watchVariable)
virtual TaskToken scheduleDelayedTask(int64_t microseconds, TaskFunc *proc, void *clientData)
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