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 
35 class MHVisible;
36 
37 // Group Class and the two derived classes.
38 
39 //
40 class MHTimer {
41  public:
42  int m_nTimerId {0};
43  QTime m_Time;
44 };
45 
46 class 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.
69  int m_nOrigGCPriority {127};
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 
88 class 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};
103  int m_nSceneCoordX {0};
104  int m_nSceneCoordY {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 
117 class MHApplication : public MHGroup
118 {
119  public:
120  MHApplication() { m_fIsApp = true; }
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};
135  int m_nTextCHook {0};
136  int m_nIPCHook {0};
137  int m_nStrCHook {0};
138  int m_nBitmapCHook {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 
159 class MHLaunch: public MHElemAction
160 {
161  public:
162  MHLaunch(): MHElemAction(":Launch") {}
163  void Perform(MHEngine *engine) override; // MHElemAction
164 };
165 
166 // Quit the application.
167 class 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 
208 class MHSpawn: public MHElemAction
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
224  bool m_fIsLoad;
228 };
229 
230 
231 // TransitionTo - move to a new scene.
233 {
234  public:
235  MHTransitionTo();
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 };
241  int m_nConnectionTag { 0 };
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
MHTransitionTo::MHTransitionTo
MHTransitionTo()
Definition: Groups.cpp:954
MHObjectRef
Definition: BaseClasses.h:153
MHGroup
Definition: Groups.h:46
MHGetEngineSupport::m_answer
MHObjectRef m_answer
Definition: Groups.h:270
MHGenericOctetString
Definition: BaseClasses.h:224
MHApplication::m_nIPCHook
int m_nIPCHook
Definition: Groups.h:136
MHScene::SetInputRegister
void SetInputRegister(int nReg, MHEngine *engine) override
Definition: Groups.cpp:798
MHTransitionTo
Definition: Groups.h:232
MHSendEvent::MHSendEvent
MHSendEvent()
Definition: Groups.h:178
MHSetTimer::MHSetTimer
MHSetTimer()
Definition: Groups.h:191
MHParameter
Definition: BaseClasses.h:258
MHGroup::MHEGEngine
friend class MHEGEngine
Definition: Groups.h:85
MHTransitionTo::m_nConnectionTag
int m_nConnectionTag
Definition: Groups.h:241
MHGetEngineSupport::m_feature
MHGenericOctetString m_feature
Definition: Groups.h:269
MHGenericBoolean
Definition: BaseClasses.h:202
MHGetEngineSupport::PrintArgs
void PrintArgs(FILE *fd, int) const override
Definition: Groups.h:267
MHSendEvent::Initialise
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: Groups.cpp:805
MHApplication::m_fRestarting
bool m_fRestarting
Definition: Groups.h:152
MHScene::m_nEventReg
int m_nEventReg
Definition: Groups.h:102
MHSetTimer::Perform
void Perform(MHEngine *engine) override
Definition: Groups.cpp:892
MHEngine
Definition: Engine.h:72
MHApplication
Definition: Groups.h:117
MHGroup::~MHGroup
~MHGroup() override
Definition: Groups.cpp:43
MHApplication::Activation
void Activation(MHEngine *engine) override
Definition: Groups.cpp:689
MHApplication::FindOnStack
int FindOnStack(const MHRoot *pVis)
Definition: Groups.cpp:707
MHSpawn::Perform
void Perform(MHEngine *engine) override
Definition: Groups.cpp:1015
MHTimer::m_nTimerId
int m_nTimerId
Definition: Groups.h:42
MHSetTimer::ST_TimerRelative
@ ST_TimerRelative
Definition: Groups.h:202
MHGroup::Activation
void Activation(MHEngine *engine) override
Definition: Groups.cpp:275
MHTransitionTo::Perform
void Perform(MHEngine *engine) override
Definition: Groups.cpp:998
MHSendEvent
Definition: Groups.h:175
MHSetTimer
Definition: Groups.h:188
MHApplication::m_onRestart
MHActionSequence m_onRestart
Definition: Groups.h:131
MHGroup::Preparation
void Preparation(MHEngine *engine) override
Definition: Groups.cpp:258
MHUnlockScreen::Perform
void Perform(MHEngine *engine) override
Definition: Groups.cpp:1025
MHGenericInteger
Definition: BaseClasses.h:213
MHApplication::m_onSpawnCloseDown
MHActionSequence m_onSpawnCloseDown
Definition: Groups.h:131
MHPersistent::PrintArgs
void PrintArgs(FILE *fd, int nTabs) const override
Definition: Groups.cpp:930
MHPersistent::m_succeeded
MHObjectRef m_succeeded
Definition: Groups.h:225
MHScene::PrintMe
void PrintMe(FILE *fd, int nTabs) const override
Definition: Groups.cpp:761
MHLaunch::MHLaunch
MHLaunch()
Definition: Groups.h:162
MHSetTimer::m_timerValue
MHGenericInteger m_timerValue
Definition: Groups.h:204
MHApplication::m_pCurrentScene
MHScene * m_pCurrentScene
Definition: Groups.h:151
MHApplication::m_buttonRefColour
MHColour m_buttonRefColour
Definition: Groups.h:134
MHSequence< MHVisible * >
MHSetTimer::ST_TimerAbsolute
@ ST_TimerAbsolute
Definition: Groups.h:201
MHOctetString
Definition: BaseClasses.h:107
MHTimer
Definition: Groups.h:40
mythburn.FILE
int FILE
Definition: mythburn.py:139
MHSetTimer::m_timerId
MHGenericInteger m_timerId
Definition: Groups.h:196
MHGroup::Destruction
void Destruction(MHEngine *engine) override
Definition: Groups.cpp:319
MHApplication::m_bgColour
MHColour m_bgColour
Definition: Groups.h:134
MHGroup::Deactivation
void Deactivation(MHEngine *engine) override
Definition: Groups.cpp:305
MHSetInputRegister::CallAction
void CallAction(MHEngine *engine, MHRoot *pTarget, int nArg) override
Definition: Groups.h:278
MHApplication::m_sliderRefColour
MHColour m_sliderRefColour
Definition: Groups.h:134
MHTransitionTo::m_nTransitionEffect
int m_nTransitionEffect
Definition: Groups.h:242
MHSendEvent::m_eventSource
MHGenericObjectRef m_eventSource
Definition: Groups.h:183
MHSendEvent::Perform
void Perform(MHEngine *engine) override
Definition: Groups.cpp:831
MHSetTimer::m_absFlag
MHGenericBoolean m_absFlag
Definition: Groups.h:205
MHUnlockScreen
Definition: Groups.h:253
MHGroup::m_items
MHOwnPtrSequence< MHIngredient > m_items
Definition: Groups.h:71
MHApplication::m_nBitmapCHook
int m_nBitmapCHook
Definition: Groups.h:138
MHApplication::PrintMe
void PrintMe(FILE *fd, int nTabs) const override
Definition: Groups.cpp:569
MHScene::m_nSceneCoordY
int m_nSceneCoordY
Definition: Groups.h:104
MHApplication::m_nLineArtCHook
int m_nLineArtCHook
Definition: Groups.h:139
MHPersistent::Perform
void Perform(MHEngine *engine) override
Definition: Groups.cpp:944
MHApplication::m_fontAttrs
MHOctetString m_fontAttrs
Definition: Groups.h:141
MHTransitionTo::Initialise
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: Groups.cpp:958
EventType
EventType
Definition: Root.h:33
MHScene::m_fMovingCursor
bool m_fMovingCursor
Definition: Groups.h:110
hardwareprofile.config.p
p
Definition: config.py:33
MHApplication::Initialise
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: Groups.cpp:438
MHScene::Initialise
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: Groups.cpp:720
MHSetInputRegister
Definition: Groups.h:274
MHGenericObjectRef
Definition: BaseClasses.h:235
MHSetInputRegister::MHSetInputRegister
MHSetInputRegister()
Definition: Groups.h:277
MHGroup::m_nLastId
int m_nLastId
Definition: Groups.h:83
MHColour
Definition: BaseClasses.h:139
MHScene
Definition: Groups.h:88
MHSetTimer::ST_NoNewTimer
enum MHSetTimer::@9 ST_NoNewTimer
MHQuit::Perform
void Perform(MHEngine *engine) override
Definition: Groups.cpp:1011
MHGroup::FindByObjectNo
MHRoot * FindByObjectNo(int n) override
Definition: Groups.cpp:330
MHApplication::m_displayStack
MHSequence< MHVisible * > m_displayStack
Definition: Groups.h:148
MHApplication::m_tuneInfo
int m_tuneInfo
Definition: Groups.h:142
MHScene::ClassName
const char * ClassName() override
Definition: Groups.h:94
MHPersistent::m_variables
MHOwnPtrSequence< MHObjectRef > m_variables
Definition: Groups.h:226
MHGroup::m_fIsApp
bool m_fIsApp
Definition: Groups.h:72
MHGenericOctetString::PrintMe
void PrintMe(FILE *fd, int nTabs) const
Definition: BaseClasses.cpp:476
MHTransitionTo::PrintArgs
void PrintArgs(FILE *fd, int nTabs) const override
Definition: Groups.cpp:980
MHScene::m_nSceneCoordX
int m_nSceneCoordX
Definition: Groups.h:103
MHGroup::m_closeDown
MHActionSequence m_closeDown
Definition: Groups.h:70
MHApplication::MHApplication
MHApplication()
Definition: Groups.h:120
MHLockScreen::Perform
void Perform(MHEngine *engine) override
Definition: Groups.cpp:1021
MHScene::m_nAspectRatioW
int m_nAspectRatioW
Definition: Groups.h:108
MHGroup::CheckTimers
std::chrono::milliseconds CheckTimers(MHEngine *engine)
Definition: Groups.cpp:387
MHApplication::m_nTextCHook
int m_nTextCHook
Definition: Groups.h:135
MHPersistent::m_fIsLoad
bool m_fIsLoad
Definition: Groups.h:224
MHGroup::PrintMe
void PrintMe(FILE *fd, int nTabs) const override
Definition: Groups.cpp:217
MHApplication::m_nLockCount
int m_nLockCount
Definition: Groups.h:145
Ingredients.h
MHActionInt
Definition: BaseActions.h:51
MHPersistent
Definition: Groups.h:216
MHGetEngineSupport::Initialise
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: Groups.cpp:1030
MHGroup::Initialise
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: Groups.cpp:51
MHScene::m_nAspectRatioH
int m_nAspectRatioH
Definition: Groups.h:109
MHFontBody
Definition: BaseClasses.h:309
Root.h
MHGroup::m_runTime
QElapsedTimer m_runTime
Definition: Groups.h:78
MHSendEvent::PrintArgs
void PrintArgs(FILE *fd, int nTabs) const override
Definition: Groups.cpp:818
MHSendEvent::m_eventData
MHParameter m_eventData
Definition: Groups.h:185
MHSetTimer::PrintArgs
void PrintArgs(FILE *fd, int nTabs) const override
Definition: Groups.cpp:874
MHQuit::MHQuit
MHQuit()
Definition: Groups.h:170
MHVisible
Definition: Visible.h:35
MHScene::MHScene
MHScene()=default
MHGetEngineSupport::MHGetEngineSupport
MHGetEngineSupport()
Definition: Groups.h:263
MHGetEngineSupport
Definition: Groups.h:260
MHUnlockScreen::MHUnlockScreen
MHUnlockScreen()
Definition: Groups.h:256
BaseClasses.h
MHTimer::m_Time
QTime m_Time
Definition: Groups.h:43
MHActionSequence
Definition: Actions.h:28
MHApplication::m_font
MHFontBody m_font
Definition: Groups.h:140
MHTransitionTo::m_fIsTagged
bool m_fIsTagged
Definition: Groups.h:240
MHApplication::IsShared
bool IsShared() override
Definition: Groups.h:127
MHSpawn::MHSpawn
MHSpawn()
Definition: Groups.h:211
MHPersistent::MHPersistent
MHPersistent(const char *name, bool fIsLoad)
Definition: Groups.h:219
MHLaunch::Perform
void Perform(MHEngine *engine) override
Definition: Groups.cpp:1005
MHParseNode
Definition: ParseNode.h:38
MHGroup::MakeClone
void MakeClone(MHRoot *pTarget, MHRoot *pRef, MHEngine *engine) override
Definition: Groups.cpp:422
MHSpawn
Definition: Groups.h:208
MHGroup::m_timers
QList< MHTimer * > m_timers
Definition: Groups.h:79
MHGroup::m_startUp
MHActionSequence m_startUp
Definition: Groups.h:70
MHApplication::~MHApplication
~MHApplication() override
Definition: Groups.cpp:433
MHSetTimer::ST_NoNewTimer
@ ST_NoNewTimer
Definition: Groups.h:200
MHQuit
Definition: Groups.h:167
MHApplication::m_nStrCHook
int m_nStrCHook
Definition: Groups.h:137
MHElemAction
Definition: BaseActions.h:34
MHScene::Activation
void Activation(MHEngine *engine) override
Definition: Groups.cpp:786
MHPersistent::Initialise
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: Groups.cpp:914
MHGroup::m_nOrigGCPriority
int m_nOrigGCPriority
Definition: Groups.h:69
MHPersistent::m_fileName
MHGenericOctetString m_fileName
Definition: Groups.h:227
MHGroup::MHGroup
MHGroup()=default
MHApplication::m_nCharSet
int m_nCharSet
Definition: Groups.h:133
MHObjectRef::PrintMe
void PrintMe(FILE *fd, int nTabs) const
Definition: BaseClasses.cpp:284
MHApplication::m_highlightRefColour
MHColour m_highlightRefColour
Definition: Groups.h:134
MHApplication::m_textColour
MHColour m_textColour
Definition: Groups.h:134
MHGetEngineSupport::Perform
void Perform(MHEngine *engine) override
Definition: Groups.cpp:1037
BaseActions.h
MHOwnPtrSequence< MHIngredient >
EventIsAvailable
@ EventIsAvailable
Definition: Root.h:34
MHApplication::ClassName
const char * ClassName() override
Definition: Groups.h:122
MHLaunch
Definition: Groups.h:159
MHSetTimer::Initialise
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: Groups.cpp:852
MHRoot
Definition: Root.h:44
MHLockScreen
Definition: Groups.h:246
MHApplication::m_path
QString m_path
Definition: Groups.h:153
MHLockScreen::MHLockScreen
MHLockScreen()
Definition: Groups.h:249
MHGroup::SetTimer
void SetTimer(int nTimerId, bool fAbsolute, int nMilliSecs, MHEngine *engine) override
Definition: Groups.cpp:351