MythTV master
Groups.h
Go to the documentation of this file.
1/* Groups.h
2
3 Copyright (C) David C. J. Matthews 2004 dm at prolingua.co.uk
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
18 Or, point your browser to http://www.gnu.org/copyleft/gpl.html
19
20*/
21
22
23#if !defined(GROUPCLASS_H)
24#define GROUPCLASS_H
25#include <QString>
26#include <QDateTime>
27#include <QElapsedTimer>
28#include <QList>
29
30#include "Root.h"
31#include "Ingredients.h"
32#include "BaseClasses.h"
33#include "BaseActions.h"
34
35class MHVisible;
36
37// Group Class and the two derived classes.
38
39//
40class MHTimer {
41 public:
42 int m_nTimerId {0};
43 QTime m_Time;
44};
45
46class MHGroup : public MHRoot
47{
48 public:
49 MHGroup() = default;
50 ~MHGroup() override;
51 void PrintMe(FILE *fd, int nTabs) const override; // MHRoot
52
53 void Preparation(MHEngine *engine) override; // MHRoot
54 void Activation(MHEngine *engine) override; // MHRoot
55 void Deactivation(MHEngine *engine) override; // MHRoot
56 void Destruction(MHEngine *engine) override; // MHRoot
57
58 MHRoot *FindByObjectNo(int n) override; // MHRoot
59
60 // Actions.
61 void SetTimer(int nTimerId, bool fAbsolute, int nMilliSecs, MHEngine *engine) override; // MHRoot
62 // This isn't an MHEG action as such but is used as part of the implementation of "Clone"
63 void MakeClone(MHRoot *pTarget, MHRoot *pRef, MHEngine *engine) override; // MHRoot
64
65 protected:
66 // Set this up from the parse tree.
67 void Initialise(MHParseNode *p, MHEngine *engine) override; // MHRoot
68 // Standard ID, Standard version, Object information aren't recorded.
72 bool m_fIsApp {false};
73 friend class MHEngine;
74
75 // Timers are an attribute of the scene class in the standard but have been moved
76 // to the group in UK MHEG. We start this timer when that the group starts
77 // running so we know how to calculate expiration times.
78 QElapsedTimer m_runTime;
79 QList<MHTimer*> m_timers;
80 // Checks the timers and fires any relevant events. Returns the
81 // millisecs to the next event or zero if there aren't any.
82 std::chrono::milliseconds CheckTimers(MHEngine *engine);
83 int m_nLastId {0}; // Highest numbered ingredient. Used to make new ids for clones.
84
85 friend class MHEGEngine;
86};
87
88class MHScene : public MHGroup
89{
90 public:
91 MHScene() = default;
92 // Set this up from the parse tree.
93 void Initialise(MHParseNode *p, MHEngine *engine) override; // MHGroup
94 const char *ClassName() override // MHRoot
95 { return "Scene"; }
96 void PrintMe(FILE *fd, int nTabs) const override; // MHGroup
97 void Activation(MHEngine *engine) override; // MHGroup
98
99 // Actions.
100 void SetInputRegister(int nReg, MHEngine *engine) override; // MHRoot
101 protected:
102 int m_nEventReg {0};
105
106 // TODO: In UK MHEG 1.06 the aspect ratio is optional and if not specified "the
107 // scene has no aspect ratio".
110 bool m_fMovingCursor {false};
111 // We don't use the Next-Scenes info at the moment.
112// MHSceneSeq m_NextScenes; // Preload info for next scenes.
113 friend class MHEngine;
114};
115
116
117class MHApplication : public MHGroup
118{
119 public:
121 ~MHApplication() override;
122 const char *ClassName() override // MHRoot
123 { return "Application"; }
124 // Set this up from the parse tree.
125 void Initialise(MHParseNode *p, MHEngine *engine) override; // MHGroup
126 void PrintMe(FILE *fd, int nTabs) const override; // MHGroup
127 bool IsShared() override // MHRoot
128 { return true; } // The application is "shared".
129 void Activation(MHEngine *engine) override; // MHGroup
130 protected:
132 // Default attributes.
133 int m_nCharSet {0};
136 int m_nIPCHook {0};
137 int m_nStrCHook {0};
142 int m_tuneInfo {0};
143
144 // Internal attributes and additional state
145 int m_nLockCount {0}; // Count for locking the screen
146 // Display stack. Visible items with the lowest item in the stack first.
147 // Later items may obscure earlier.
149 int FindOnStack(const MHRoot *pVis); // Returns the index on the stack or -1 if it's not there.
150
152 bool m_fRestarting {false};
153 QString m_path; // Path from the root directory to this application. Either the null string or
154 // a string of the form /a/b/c .
155
156 friend class MHEngine;
157};
158
160{
161 public:
162 MHLaunch(): MHElemAction(":Launch") {}
163 void Perform(MHEngine *engine) override; // MHElemAction
164};
165
166// Quit the application.
167class MHQuit: public MHElemAction
168{
169 public:
170 MHQuit(): MHElemAction(":Quit") {}
171 void Perform(MHEngine *engine) override; // MHElemAction
172};
173
174// SendEvent - generate an event
176{
177 public:
178 MHSendEvent(): MHElemAction(":SendEvent") {}
179 void Initialise(MHParseNode *p, MHEngine *engine) override; // MHElemAction
180 void Perform(MHEngine *engine) override; // MHElemAction
181 void PrintArgs(FILE *fd, int nTabs) const override; // MHElemAction
182 protected:
184 enum EventType m_eventType { EventIsAvailable }; // Event type
185 MHParameter m_eventData; // Optional - Null means not specified. Can only be bool, int or string.
186};
187
189{
190 public:
191 MHSetTimer(): MHElemAction(":SetTimer") {}
192 void Initialise(MHParseNode *p, MHEngine *engine) override; // MHElemAction
193 void Perform(MHEngine *engine) override; // MHElemAction
194 protected:
195 void PrintArgs(FILE *fd, int nTabs) const override; // MHElemAction
197 // A new timer may not be specified in which case this cancels the timer.
198 // If the timer is specified the "absolute" flag is optional.
199 enum : std::uint8_t {
203 } m_timerType { ST_NoNewTimer };
206};
207
209{
210 public:
211 MHSpawn(): MHElemAction(":Spawn") {}
212 void Perform(MHEngine *engine) override; // MHElemAction
213};
214
215// Read and Store persistent - read and save data to persistent store.
217{
218 public:
219 MHPersistent(const char *name, bool fIsLoad): MHElemAction(name), m_fIsLoad(fIsLoad) {}
220 void Initialise(MHParseNode *p, MHEngine *engine) override; // MHElemAction
221 void Perform(MHEngine *engine) override; // MHElemAction
222 protected:
223 void PrintArgs(FILE *fd, int nTabs) const override; // MHElemAction
228};
229
230
231// TransitionTo - move to a new scene.
233{
234 public:
236 void Initialise(MHParseNode *p, MHEngine *engine) override; // MHElemAction
237 void Perform(MHEngine *engine) override; // MHElemAction
238 protected:
239 void PrintArgs(FILE *fd, int nTabs) const override; // MHElemAction
240 bool m_fIsTagged { false };
243};
244
245// Lock and unlock functions.
247{
248 public:
249 MHLockScreen(): MHElemAction(":LockScreen") {}
250 void Perform(MHEngine *engine) override; // MHElemAction
251};
252
254{
255 public:
256 MHUnlockScreen(): MHElemAction(":UnlockScreen") {}
257 void Perform(MHEngine *engine) override; // MHElemAction
258};
259
261{
262 public:
263 MHGetEngineSupport(): MHElemAction(":GetEngineSupport") {}
264 void Initialise(MHParseNode *p, MHEngine *engine) override; // MHElemAction
265 void Perform(MHEngine *engine) override; // MHElemAction
266 protected:
267 void PrintArgs(FILE *fd, int /*nTabs*/) const override // MHElemAction
268 { m_feature.PrintMe(fd, 0); m_answer.PrintMe(fd, 0); }
271};
272
273// Actions added in UK MHEG profile.
275{
276 public:
277 MHSetInputRegister(): MHActionInt(":SetInputRegister") {}
278 void CallAction(MHEngine *engine, MHRoot *pTarget, int nArg) override // MHActionInt
279 { pTarget->SetInputRegister(nArg, engine); };
280};
281
282
283#endif
EventType
Definition: Root.h:34
@ EventIsAvailable
Definition: Root.h:34
MHColour m_buttonRefColour
Definition: Groups.h:134
MHColour m_textColour
Definition: Groups.h:134
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: Groups.cpp:438
int m_nLineArtCHook
Definition: Groups.h:139
int m_nLockCount
Definition: Groups.h:145
MHColour m_highlightRefColour
Definition: Groups.h:134
int m_nBitmapCHook
Definition: Groups.h:138
MHColour m_sliderRefColour
Definition: Groups.h:134
int m_nCharSet
Definition: Groups.h:133
int m_nTextCHook
Definition: Groups.h:135
~MHApplication() override
Definition: Groups.cpp:433
int FindOnStack(const MHRoot *pVis)
Definition: Groups.cpp:707
void Activation(MHEngine *engine) override
Definition: Groups.cpp:689
void PrintMe(FILE *fd, int nTabs) const override
Definition: Groups.cpp:569
MHSequence< MHVisible * > m_displayStack
Definition: Groups.h:148
MHOctetString m_fontAttrs
Definition: Groups.h:141
int m_tuneInfo
Definition: Groups.h:142
bool IsShared() override
Definition: Groups.h:127
QString m_path
Definition: Groups.h:153
MHActionSequence m_onRestart
Definition: Groups.h:131
MHScene * m_pCurrentScene
Definition: Groups.h:151
const char * ClassName() override
Definition: Groups.h:122
int m_nIPCHook
Definition: Groups.h:136
MHActionSequence m_onSpawnCloseDown
Definition: Groups.h:131
MHFontBody m_font
Definition: Groups.h:140
MHColour m_bgColour
Definition: Groups.h:134
int m_nStrCHook
Definition: Groups.h:137
MHApplication()
Definition: Groups.h:120
bool m_fRestarting
Definition: Groups.h:152
void PrintMe(FILE *fd, int nTabs) const
void Perform(MHEngine *engine) override
Definition: Groups.cpp:1037
MHObjectRef m_answer
Definition: Groups.h:270
void PrintArgs(FILE *fd, int) const override
Definition: Groups.h:267
MHGenericOctetString m_feature
Definition: Groups.h:269
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: Groups.cpp:1030
Definition: Groups.h:47
void MakeClone(MHRoot *pTarget, MHRoot *pRef, MHEngine *engine) override
Definition: Groups.cpp:422
void PrintMe(FILE *fd, int nTabs) const override
Definition: Groups.cpp:217
void Preparation(MHEngine *engine) override
Definition: Groups.cpp:258
MHActionSequence m_startUp
Definition: Groups.h:70
MHRoot * FindByObjectNo(int n) override
Definition: Groups.cpp:330
friend class MHEGEngine
Definition: Groups.h:85
MHActionSequence m_closeDown
Definition: Groups.h:70
void SetTimer(int nTimerId, bool fAbsolute, int nMilliSecs, MHEngine *engine) override
Definition: Groups.cpp:351
void Destruction(MHEngine *engine) override
Definition: Groups.cpp:319
MHOwnPtrSequence< MHIngredient > m_items
Definition: Groups.h:71
std::chrono::milliseconds CheckTimers(MHEngine *engine)
Definition: Groups.cpp:387
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: Groups.cpp:51
void Deactivation(MHEngine *engine) override
Definition: Groups.cpp:305
QElapsedTimer m_runTime
Definition: Groups.h:78
QList< MHTimer * > m_timers
Definition: Groups.h:79
void Activation(MHEngine *engine) override
Definition: Groups.cpp:275
int m_nLastId
Definition: Groups.h:83
MHGroup()=default
int m_nOrigGCPriority
Definition: Groups.h:69
~MHGroup() override
Definition: Groups.cpp:43
bool m_fIsApp
Definition: Groups.h:72
MHLaunch()
Definition: Groups.h:162
void Perform(MHEngine *engine) override
Definition: Groups.cpp:1005
MHLockScreen()
Definition: Groups.h:249
void Perform(MHEngine *engine) override
Definition: Groups.cpp:1021
void PrintMe(FILE *fd, int nTabs) const
void PrintArgs(FILE *fd, int nTabs) const override
Definition: Groups.cpp:930
MHObjectRef m_succeeded
Definition: Groups.h:225
void Perform(MHEngine *engine) override
Definition: Groups.cpp:944
bool m_fIsLoad
Definition: Groups.h:224
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: Groups.cpp:914
MHGenericOctetString m_fileName
Definition: Groups.h:227
MHOwnPtrSequence< MHObjectRef > m_variables
Definition: Groups.h:226
MHPersistent(const char *name, bool fIsLoad)
Definition: Groups.h:219
Definition: Groups.h:168
void Perform(MHEngine *engine) override
Definition: Groups.cpp:1011
MHQuit()
Definition: Groups.h:170
Definition: Root.h:45
Definition: Groups.h:89
int m_nAspectRatioH
Definition: Groups.h:109
bool m_fMovingCursor
Definition: Groups.h:110
void PrintMe(FILE *fd, int nTabs) const override
Definition: Groups.cpp:761
int m_nAspectRatioW
Definition: Groups.h:108
void Activation(MHEngine *engine) override
Definition: Groups.cpp:786
int m_nSceneCoordY
Definition: Groups.h:104
const char * ClassName() override
Definition: Groups.h:94
MHScene()=default
int m_nSceneCoordX
Definition: Groups.h:103
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: Groups.cpp:720
void SetInputRegister(int nReg, MHEngine *engine) override
Definition: Groups.cpp:798
int m_nEventReg
Definition: Groups.h:102
MHSendEvent()
Definition: Groups.h:178
MHGenericObjectRef m_eventSource
Definition: Groups.h:183
void PrintArgs(FILE *fd, int nTabs) const override
Definition: Groups.cpp:818
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: Groups.cpp:805
MHParameter m_eventData
Definition: Groups.h:185
void Perform(MHEngine *engine) override
Definition: Groups.cpp:831
void CallAction(MHEngine *engine, MHRoot *pTarget, int nArg) override
Definition: Groups.h:278
MHGenericInteger m_timerValue
Definition: Groups.h:204
MHGenericBoolean m_absFlag
Definition: Groups.h:205
MHSetTimer()
Definition: Groups.h:191
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: Groups.cpp:852
MHGenericInteger m_timerId
Definition: Groups.h:196
void Perform(MHEngine *engine) override
Definition: Groups.cpp:892
@ ST_NoNewTimer
Definition: Groups.h:200
@ ST_TimerRelative
Definition: Groups.h:202
@ ST_TimerAbsolute
Definition: Groups.h:201
enum MHSetTimer::@9 ST_NoNewTimer
void PrintArgs(FILE *fd, int nTabs) const override
Definition: Groups.cpp:874
MHSpawn()
Definition: Groups.h:211
void Perform(MHEngine *engine) override
Definition: Groups.cpp:1015
Definition: Groups.h:40
QTime m_Time
Definition: Groups.h:43
int m_nTimerId
Definition: Groups.h:42
void Perform(MHEngine *engine) override
Definition: Groups.cpp:998
int m_nConnectionTag
Definition: Groups.h:241
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: Groups.cpp:958
bool m_fIsTagged
Definition: Groups.h:240
void PrintArgs(FILE *fd, int nTabs) const override
Definition: Groups.cpp:980
int m_nTransitionEffect
Definition: Groups.h:242
MHUnlockScreen()
Definition: Groups.h:256
void Perform(MHEngine *engine) override
Definition: Groups.cpp:1025
int FILE
Definition: mythburn.py:138