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  int CheckTimers(MHEngine *engine); // Checks the timers and fires any relevant events. Returns the millisecs to the
81  // next event or zero if there aren't any.
82  int m_nLastId {0}; // Highest numbered ingredient. Used to make new ids for clones.
83 
84  friend class MHEGEngine;
85 };
86 
87 class MHScene : public MHGroup
88 {
89  public:
90  MHScene() = default;
91  // Set this up from the parse tree.
92  void Initialise(MHParseNode *p, MHEngine *engine) override; // MHGroup
93  const char *ClassName() override // MHRoot
94  { return "Scene"; }
95  void PrintMe(FILE *fd, int nTabs) const override; // MHGroup
96  void Activation(MHEngine *engine) override; // MHGroup
97 
98  // Actions.
99  void SetInputRegister(int nReg, MHEngine *engine) override; // MHRoot
100  protected:
101  int m_nEventReg {0};
102  int m_nSceneCoordX {0};
103  int m_nSceneCoordY {0};
104 
105  // TODO: In UK MHEG 1.06 the aspect ratio is optional and if not specified "the
106  // scene has no aspect ratio".
109  bool m_fMovingCursor {false};
110  // We don't use the Next-Scenes info at the moment.
111 // MHSceneSeq m_NextScenes; // Preload info for next scenes.
112  friend class MHEngine;
113 };
114 
115 
116 class MHApplication : public MHGroup
117 {
118  public:
119  MHApplication() { m_fIsApp = true; }
120  ~MHApplication() override;
121  const char *ClassName() override // MHRoot
122  { return "Application"; }
123  // Set this up from the parse tree.
124  void Initialise(MHParseNode *p, MHEngine *engine) override; // MHGroup
125  void PrintMe(FILE *fd, int nTabs) const override; // MHGroup
126  bool IsShared() override // MHRoot
127  { return true; } // The application is "shared".
128  void Activation(MHEngine *engine) override; // MHGroup
129  protected:
131  // Default attributes.
132  int m_nCharSet {0};
134  int m_nTextCHook {0};
135  int m_nIPCHook {0};
136  int m_nStrCHook {0};
137  int m_nBitmapCHook {0};
141  int m_tuneinfo {0};
142 
143  // Internal attributes and additional state
144  int m_nLockCount {0}; // Count for locking the screen
145  // Display stack. Visible items with the lowest item in the stack first.
146  // Later items may obscure earlier.
148  int FindOnStack(const MHRoot *pVis); // Returns the index on the stack or -1 if it's not there.
149 
151  bool m_fRestarting {false};
152  QString m_Path; // Path from the root directory to this application. Either the null string or
153  // a string of the form /a/b/c .
154 
155  friend class MHEngine;
156 };
157 
158 class MHLaunch: public MHElemAction
159 {
160  public:
161  MHLaunch(): MHElemAction(":Launch") {}
162  void Perform(MHEngine *engine) override; // MHElemAction
163 };
164 
165 // Quit the application.
166 class MHQuit: public MHElemAction
167 {
168  public:
169  MHQuit(): MHElemAction(":Quit") {}
170  void Perform(MHEngine *engine) override; // MHElemAction
171 };
172 
173 // SendEvent - generate an event
175 {
176  public:
177  MHSendEvent(): MHElemAction(":SendEvent") {}
178  void Initialise(MHParseNode *p, MHEngine *engine) override; // MHElemAction
179  void Perform(MHEngine *engine) override; // MHElemAction
180  void PrintArgs(FILE *fd, int nTabs) const override; // MHElemAction
181  protected:
183  enum EventType m_EventType { EventIsAvailable }; // Event type
184  MHParameter m_EventData; // Optional - Null means not specified. Can only be bool, int or string.
185 };
186 
188 {
189  public:
190  MHSetTimer(): MHElemAction(":SetTimer") {}
191  void Initialise(MHParseNode *p, MHEngine *engine) override; // MHElemAction
192  void Perform(MHEngine *engine) override; // MHElemAction
193  protected:
194  void PrintArgs(FILE *fd, int nTabs) const override; // MHElemAction
196  // A new timer may not be specified in which case this cancels the timer.
197  // If the timer is specified the "absolute" flag is optional.
198  enum {
202  } m_TimerType { ST_NoNewTimer };
205 };
206 
207 class MHSpawn: public MHElemAction
208 {
209  public:
210  MHSpawn(): MHElemAction(":Spawn") {}
211  void Perform(MHEngine *engine) override; // MHElemAction
212 };
213 
214 // Read and Store persistent - read and save data to persistent store.
216 {
217  public:
218  MHPersistent(const char *name, bool fIsLoad): MHElemAction(name), m_fIsLoad(fIsLoad) {}
219  void Initialise(MHParseNode *p, MHEngine *engine) override; // MHElemAction
220  void Perform(MHEngine *engine) override; // MHElemAction
221  protected:
222  void PrintArgs(FILE *fd, int nTabs) const override; // MHElemAction
223  bool m_fIsLoad;
227 };
228 
229 
230 // TransitionTo - move to a new scene.
232 {
233  public:
234  MHTransitionTo();
235  void Initialise(MHParseNode *p, MHEngine *engine) override; // MHElemAction
236  void Perform(MHEngine *engine) override; // MHElemAction
237  protected:
238  void PrintArgs(FILE *fd, int nTabs) const override; // MHElemAction
242 };
243 
244 // Lock and unlock functions.
246 {
247  public:
248  MHLockScreen(): MHElemAction(":LockScreen") {}
249  void Perform(MHEngine *engine) override; // MHElemAction
250 };
251 
253 {
254  public:
255  MHUnlockScreen(): MHElemAction(":UnlockScreen") {}
256  void Perform(MHEngine *engine) override; // MHElemAction
257 };
258 
260 {
261  public:
262  MHGetEngineSupport(): MHElemAction(":GetEngineSupport") {}
263  void Initialise(MHParseNode *p, MHEngine *engine) override; // MHElemAction
264  void Perform(MHEngine *engine) override; // MHElemAction
265  protected:
266  void PrintArgs(FILE *fd, int /*nTabs*/) const override // MHElemAction
267  { m_Feature.PrintMe(fd, 0); m_Answer.PrintMe(fd, 0); }
270 };
271 
272 // Actions added in UK MHEG profile.
274 {
275  public:
276  MHSetInputRegister(): MHActionInt(":SetInputRegister") {}
277  void CallAction(MHEngine *engine, MHRoot *pTarget, int nArg) override // MHActionInt
278  { pTarget->SetInputRegister(nArg, engine); };
279 };
280 
281 
282 #endif
int m_nTransitionEffect
Definition: Groups.h:241
const char * ClassName() override
Definition: Groups.h:121
void Activation(MHEngine *engine) override
Definition: Groups.cpp:786
Definition: Groups.h:40
QTime m_Time
Definition: Groups.h:43
void Deactivation(MHEngine *engine) override
Definition: Groups.cpp:305
QList< MHTimer * > m_Timers
Definition: Groups.h:79
const char * ClassName() override
Definition: Groups.h:93
MHObjectRef m_Answer
Definition: Groups.h:269
QElapsedTimer m_RunTime
Definition: Groups.h:78
void CallAction(MHEngine *engine, MHRoot *pTarget, int nArg) override
Definition: Groups.h:277
void PrintMe(FILE *fd, int nTabs) const
MHParameter m_EventData
Definition: Groups.h:184
MHOwnPtrSequence< MHObjectRef > m_Variables
Definition: Groups.h:225
int m_tuneinfo
Definition: Groups.h:141
void Perform(MHEngine *engine) override
Definition: Groups.cpp:1040
friend class MHEGEngine
Definition: Groups.h:84
void Perform(MHEngine *engine) override
Definition: Groups.cpp:1001
void Perform(MHEngine *engine) override
Definition: Groups.cpp:1028
void PrintMe(FILE *fd, int nTabs) const
MHColour m_BGColour
Definition: Groups.h:133
MHSpawn()
Definition: Groups.h:210
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: Groups.cpp:720
MHLaunch()
Definition: Groups.h:161
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: Groups.cpp:961
MHQuit()
Definition: Groups.h:169
void Perform(MHEngine *engine) override
Definition: Groups.cpp:831
int m_nBitmapCHook
Definition: Groups.h:137
MHColour m_TextColour
Definition: Groups.h:133
MHScene * m_pCurrentScene
Definition: Groups.h:150
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: Groups.cpp:438
MHGenericObjectRef m_EventSource
Definition: Groups.h:182
MHOctetString m_FontAttrs
Definition: Groups.h:140
int CheckTimers(MHEngine *engine)
Definition: Groups.cpp:387
MHOwnPtrSequence< MHIngredient > m_Items
Definition: Groups.h:71
void MakeClone(MHRoot *pTarget, MHRoot *pRef, MHEngine *engine) override
Definition: Groups.cpp:422
void PrintArgs(FILE *fd, int) const override
Definition: Groups.h:266
void Perform(MHEngine *engine) override
Definition: Groups.cpp:944
void PrintMe(FILE *fd, int nTabs) const override
Definition: Groups.cpp:761
int m_nCharSet
Definition: Groups.h:132
MHGroup()=default
void SetTimer(int nTimerId, bool fAbsolute, int nMilliSecs, MHEngine *engine) override
Definition: Groups.cpp:351
MHGenericInteger m_TimerValue
Definition: Groups.h:203
MHPersistent(const char *name, bool fIsLoad)
Definition: Groups.h:218
MHSendEvent()
Definition: Groups.h:177
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: Groups.cpp:852
void Perform(MHEngine *engine) override
Definition: Groups.cpp:1024
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: Groups.cpp:48
int FindOnStack(const MHRoot *pVis)
Definition: Groups.cpp:707
int m_nLockCount
Definition: Groups.h:144
MHUnlockScreen()
Definition: Groups.h:255
MHFontBody m_Font
Definition: Groups.h:139
MHRoot * FindByObjectNo(int n) override
Definition: Groups.cpp:330
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: Groups.cpp:1033
int m_nLastId
Definition: Groups.h:82
void PrintMe(FILE *fd, int nTabs) const override
Definition: Groups.cpp:569
MHSetTimer()
Definition: Groups.h:190
bool IsShared() override
Definition: Groups.h:126
int m_nIPCHook
Definition: Groups.h:135
void PrintArgs(FILE *fd, int nTabs) const override
Definition: Groups.cpp:874
Definition: Groups.h:166
void PrintArgs(FILE *fd, int nTabs) const override
Definition: Groups.cpp:983
MHGenericInteger m_TimerId
Definition: Groups.h:195
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: Groups.cpp:914
void Perform(MHEngine *engine) override
Definition: Groups.cpp:892
void Preparation(MHEngine *engine) override
Definition: Groups.cpp:258
bool m_fIsApp
Definition: Groups.h:72
bool m_fMovingCursor
Definition: Groups.h:109
int m_nStrCHook
Definition: Groups.h:136
void PrintArgs(FILE *fd, int nTabs) const override
Definition: Groups.cpp:818
MHGenericOctetString m_Feature
Definition: Groups.h:268
int m_nTextCHook
Definition: Groups.h:134
Definition: Root.h:43
MHObjectRef m_Succeeded
Definition: Groups.h:224
Definition: Groups.h:87
int FILE
Definition: mythburn.py:139
MHActionSequence m_OnRestart
Definition: Groups.h:130
int m_nTimerId
Definition: Groups.h:42
void Perform(MHEngine *engine) override
Definition: Groups.cpp:1008
int m_nEventReg
Definition: Groups.h:101
void Perform(MHEngine *engine) override
Definition: Groups.cpp:1018
bool m_fIsLoad
Definition: Groups.h:223
MHActionSequence m_StartUp
Definition: Groups.h:70
MHColour m_ButtonRefColour
Definition: Groups.h:133
MHActionSequence m_OnSpawnCloseDown
Definition: Groups.h:130
void PrintArgs(FILE *fd, int nTabs) const override
Definition: Groups.cpp:930
int m_nSceneCoordX
Definition: Groups.h:102
MHLockScreen()
Definition: Groups.h:248
void Destruction(MHEngine *engine) override
Definition: Groups.cpp:319
bool m_fIsTagged
Definition: Groups.h:239
void SetInputRegister(int nReg, MHEngine *engine) override
Definition: Groups.cpp:798
Definition: Groups.h:46
void Perform(MHEngine *engine) override
Definition: Groups.cpp:1014
~MHGroup() override
Definition: Groups.cpp:40
MHActionSequence m_CloseDown
Definition: Groups.h:70
MHApplication()
Definition: Groups.h:119
void Activation(MHEngine *engine) override
Definition: Groups.cpp:689
MHSequence< MHVisible * > m_DisplayStack
Definition: Groups.h:147
MHGenericBoolean m_AbsFlag
Definition: Groups.h:204
MHColour m_HighlightRefColour
Definition: Groups.h:133
MHScene()=default
void PrintMe(FILE *fd, int nTabs) const override
Definition: Groups.cpp:217
EventType
Definition: Root.h:33
int m_nAspectRatioW
Definition: Groups.h:107
int m_nLineArtCHook
Definition: Groups.h:138
bool m_fRestarting
Definition: Groups.h:151
MHGenericOctetString m_FileName
Definition: Groups.h:226
int m_nSceneCoordY
Definition: Groups.h:103
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: Groups.cpp:805
int m_nConnectionTag
Definition: Groups.h:240
QString m_Path
Definition: Groups.h:152
int m_nOrigGCPriority
Definition: Groups.h:69
void Activation(MHEngine *engine) override
Definition: Groups.cpp:275
enum MHSetTimer::@9 ST_NoNewTimer
int m_nAspectRatioH
Definition: Groups.h:108
MHColour m_SliderRefColour
Definition: Groups.h:133
~MHApplication() override
Definition: Groups.cpp:433