MythTV  master
Root.h
Go to the documentation of this file.
1 /* Root.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(ROOTCLASS_H)
24 #define ROOTCLASS_H
25 
26 #include "BaseClasses.h"
27 #include "BaseActions.h"
28 class MHParseNode;
29 class MHLink;
30 class MHIngredient;
31 class MHEngine;
32 
40  // The next two events are added in UK MHEG.
42 
43 class MHRoot
44 {
45  public:
46  MHRoot() {}
47  MHRoot(const MHRoot &/*ref*/) {}
48  virtual ~MHRoot() {}
49  // Initialise - set up the item from the parse tree.
50  virtual void Initialise(MHParseNode *p, MHEngine *engine); // Set this up from the parse tree.
51  // Print this item.
52  virtual void PrintMe(FILE *fd, int nTabs) const;
53  // Test for shared status.
54  virtual bool IsShared() { return false; }
55 
56  // MHEG Actions.
57  // Preparation - sets up the run-time representation. Sets m_fAvailable and generates IsAvailable event.
58  virtual void Preparation(MHEngine *engine);
59  // Activation - starts running the object. Sets m_fRunning and generates IsRunning event.
60  virtual void Activation(MHEngine *engine);
61  // Deactivation - stops running the object. Clears m_fRunning
62  virtual void Deactivation(MHEngine *engine);
63  // Destruction - deletes the run-time representation. Clears m_fAvailable.
64  virtual void Destruction(MHEngine *engine);
65  // Prepare the content - This action is added in the corrigendum to the standard.
66  virtual void ContentPreparation(MHEngine *) {}
67 
68  // Return an object with a given object number. In the root class this returns this object
69  // if it matches. Group and Stream classes also search their components.
70  virtual MHRoot *FindByObjectNo(int n);
71 
72  // Actions. The default behaviour if a sub-class doesn't override them is to fail.
73 
74  // Actions on Root class
75  virtual bool GetAvailabilityStatus() { return m_fAvailable; }
76  virtual bool GetRunningStatus() { return m_fRunning; }
77 
78  // Actions on Groups
79  virtual void SetTimer(int/*nTimerId*/, bool/*fAbsolute*/, int /*nMilliSecs*/, MHEngine *) { InvalidAction("SetTimer"); }
80  // This isn't an MHEG action as such but is used as part of the implementation of "Clone"
81  virtual void MakeClone(MHRoot* /*pTarget*/, MHRoot* /*pRef*/, MHEngine *) { InvalidAction("MakeClone"); }
82  virtual void SetInputRegister(int /*nReg*/, MHEngine *) { InvalidAction("SetInputRegister"); }
83 
84  // Actions on Ingredients.
85  virtual void SetData(const MHOctetString &/*included*/, MHEngine *) { InvalidAction("SetData"); }
86  virtual void SetData(const MHContentRef &/*referenced*/, bool /*fSizeGiven*/, int /*size*/, bool /*fCCGiven*/, int /*cc*/, MHEngine *)
87  { InvalidAction("SetData"); }
88  virtual void Preload(MHEngine *) { InvalidAction("Preload"); }
89  virtual void Unload(MHEngine *) { InvalidAction("Unload"); }
90  // The UK MHEG profile only requires cloning for Text, Bitmap and Rectangle.
91  virtual MHIngredient *Clone(MHEngine *) { InvalidAction("Clone"); return nullptr; }
92 
93  // Actions on Presentables. The Run/Stop actions on presentables and the Activate/Deactivate actions
94  // on Links have identical effects. They could be merged.
95  virtual void Run(MHEngine *) { InvalidAction("Run"); }
96  virtual void Stop(MHEngine *) { InvalidAction("Stop"); }
97 
98  // Actions on variables.
99  virtual void TestVariable(int /*nOp*/, const MHUnion &/*parm*/, MHEngine *) { InvalidAction("TestVariable"); }
100  virtual void GetVariableValue(MHUnion &, MHEngine *) { InvalidAction("GetVariableValue"); }
101  virtual void SetVariableValue(const MHUnion &) { InvalidAction("SetVariableValue"); }
102 
103  // Actions on Text objects
104  virtual void GetTextData(MHRoot * /*pDestination*/, MHEngine *) { InvalidAction("GetTextData"); }
105  virtual void SetBackgroundColour(const MHColour &/*colour*/, MHEngine *) { InvalidAction("SetBackgroundColour"); }
106  virtual void SetTextColour(const MHColour &/*colour*/, MHEngine *) { InvalidAction("SetTextColour"); }
107  virtual void SetFontAttributes(const MHOctetString &/*fontAttrs*/, MHEngine *) { InvalidAction("SetFontAttributes"); }
108 
109  // Actions on Links
110  virtual void Activate(bool /*f*/, MHEngine *) { InvalidAction("Activate/Deactivate"); } // Activate/Deactivate
111 
112  // Actions on Programs.
113  virtual void CallProgram(bool /*fIsFork*/, const MHObjectRef &/*success*/,
114  const MHSequence<MHParameter *> &/*args*/, MHEngine *) { InvalidAction("CallProgram"); }
115 
116  // Actions on TokenGroups
117  virtual void CallActionSlot(int, MHEngine *) { InvalidAction("CallActionSlot"); }
118  virtual void Move(int, MHEngine *) { InvalidAction("Move"); }
119  virtual void MoveTo(int, MHEngine *) { InvalidAction("MoveTo"); }
120  virtual void GetTokenPosition(MHRoot * /*pResult*/, MHEngine *) { InvalidAction("GetTokenPosition"); }
121 
122  // Actions on ListGroups
123  virtual void AddItem(int /*nIndex*/, MHRoot * /*pItem*/, MHEngine *) { InvalidAction("GetCellItem"); }
124  virtual void DelItem(MHRoot * /*pItem*/, MHEngine *) { InvalidAction("GetCellItem"); }
125  virtual void GetCellItem(int /*nCell*/, const MHObjectRef &/*itemDest*/, MHEngine *) { InvalidAction("GetCellItem"); }
126  virtual void GetListItem(int /*nCell*/, const MHObjectRef &/*itemDest*/, MHEngine *) { InvalidAction("GetCellItem"); }
127  virtual void GetItemStatus(int /*nCell*/, const MHObjectRef &/*itemDest*/, MHEngine *) { InvalidAction("GetItemStatus"); }
128  virtual void SelectItem(int /*nCell*/, MHEngine *) { InvalidAction("SelectItem"); }
129  virtual void DeselectItem(int /*nCell*/, MHEngine *) { InvalidAction("DeselectItem"); }
130  virtual void ToggleItem(int /*nCell*/, MHEngine *) { InvalidAction("ToggleItem"); }
131  virtual void ScrollItems(int /*nCell*/, MHEngine *) { InvalidAction("ScrollItems"); }
132  virtual void SetFirstItem(int /*nCell*/, MHEngine *) { InvalidAction("SetFirstItem"); }
133  virtual void GetFirstItem(MHRoot * /*pResult*/, MHEngine *) { InvalidAction("GetFirstItem"); }
134  virtual void GetListSize(MHRoot * /*pResult*/, MHEngine *) { InvalidAction("GetListSize"); }
135 
136  // Actions on Visibles.
137  virtual void SetPosition(int /*nXPosition*/, int /*nYPosition*/, MHEngine *) { InvalidAction("SetPosition"); }
138  virtual void GetPosition(MHRoot * /*pXPosN*/, MHRoot * /*pYPosN*/) { InvalidAction("GetPosition"); }
139  virtual void SetBoxSize(int /*nWidth*/, int /*nHeight*/, MHEngine *) { InvalidAction("SetBoxSize"); }
140  virtual void GetBoxSize(MHRoot * /*pWidthDest*/, MHRoot * /*HeightDest*/) { InvalidAction("GetBoxSize"); }
141  virtual void SetPaletteRef(const MHObjectRef /*newPalette*/, MHEngine *) { InvalidAction("SetPaletteRef"); }
142  virtual void BringToFront(MHEngine *) { InvalidAction("BringToFront"); }
143  virtual void SendToBack(MHEngine *) { InvalidAction("SendToBack"); }
144  virtual void PutBefore(const MHRoot * /*pRef*/, MHEngine *) { InvalidAction("PutBefore"); }
145  virtual void PutBehind(const MHRoot * /*pRef*/, MHEngine *) { InvalidAction("PutBehind"); }
146  virtual void ResetPosition() { InvalidAction("ResetPosition"); } // Used internally by ListGroup
147 
148  // Actions on LineArt
149  virtual void SetFillColour(const MHColour &/*colour*/, MHEngine *) { InvalidAction("SetFillColour"); }
150  virtual void SetLineColour(const MHColour &/*colour*/, MHEngine *) { InvalidAction("SetLineColour"); }
151  virtual void SetLineWidth(int /*nWidth*/, MHEngine *) { InvalidAction("SetLineWidth"); }
152  virtual void SetLineStyle(int /*nStyle*/, MHEngine *) { InvalidAction("SetLineStyle"); }
153 
154  // Actions on Bitmaps
155  virtual void SetTransparency(int /*nTransPerCent*/, MHEngine *) { InvalidAction("SetTransparency"); }
156  virtual void ScaleBitmap(int /*xScale*/, int /*yScale*/, MHEngine *) { InvalidAction("ScaleBitmap"); }
157  virtual void SetBitmapDecodeOffset(int /*newXOffset*/, int /*newYOffset*/, MHEngine *) { InvalidAction("SetBitmapDecodeOffset"); }
158  virtual void GetBitmapDecodeOffset(MHRoot * /*pXOffset*/, MHRoot * /*pYOffset*/) { InvalidAction("GetBitmapDecodeOffset"); }
159 
160  // Actions on Dynamic Line Art
161  virtual void Clear() { InvalidAction(""); }
162  virtual void GetLineWidth(MHRoot * /*pResult*/) { InvalidAction("GetLineWidth"); }
163  virtual void GetLineStyle(MHRoot * /*pResult*/) { InvalidAction("GetLineStyle"); }
164  virtual void GetLineColour(MHRoot * /*pResult*/) { InvalidAction("GetLineColour"); }
165  virtual void GetFillColour(MHRoot * /*pResult*/) { InvalidAction("GetFillColour"); }
166  virtual void DrawArcSector(bool /*fIsSector*/, int /*x*/, int /*y*/, int /*width*/, int /*height*/, int /*start*/,
167  int /*arc*/, MHEngine *) { InvalidAction("DrawArc/Sector"); }
168  virtual void DrawLine(int /*x1*/, int /*y1*/, int /*x2*/, int /*y2*/, MHEngine *) { InvalidAction("DrawLine"); }
169  virtual void DrawOval(int /*x1*/, int /*y1*/, int /*width*/, int /*height*/, MHEngine *) { InvalidAction("DrawOval"); }
170  virtual void DrawRectangle(int /*x1*/, int /*y1*/, int /*x2*/, int /*y2*/, MHEngine *) { InvalidAction("DrawRectangle"); }
171  virtual void DrawPoly(bool /*fIsPolygon*/, int /*nPoints*/, const int * /*xArray*/, const int * /*yArray*/, MHEngine *)
172  { InvalidAction("DrawPoly(gon/line)"); }
173 
174  // Actions on Video streams.
175  virtual void ScaleVideo(int /*xScale*/, int /*yScale*/, MHEngine *) { InvalidAction("ScaleVideo"); }
176  virtual void SetVideoDecodeOffset(int /*newXOffset*/, int /*newYOffset*/, MHEngine *) { InvalidAction("SetVideoDecodeOffset"); }
177  virtual void GetVideoDecodeOffset(MHRoot * /*pXOffset*/, MHRoot * /*pYOffset*/, MHEngine *) { InvalidAction("GetVideoDecodeOffset"); }
178  virtual void GetCounterPosition(MHRoot * /*pPos*/, MHEngine *) { InvalidAction("GetCounterPosition"); }
179  virtual void GetCounterMaxPosition(MHRoot * /*pPos*/, MHEngine *) { InvalidAction("GetCounterMaxPosition"); }
180  virtual void SetCounterPosition(int /*pos*/, MHEngine *) { InvalidAction("SetCounterPosition"); }
181  virtual void SetSpeed(int /*speed 0=stop*/, MHEngine *) { InvalidAction("SetSpeed"); }
182 
183  // Actions on Interactibles.
184  virtual void SetInteractionStatus(bool /*newStatus*/, MHEngine *) { InvalidAction("SetInteractionStatus"); }
185  virtual bool GetInteractionStatus(void) { InvalidAction("GetInteractionStatus"); return false; }
186  virtual void SetHighlightStatus(bool /*newStatus*/, MHEngine */*engine*/) { InvalidAction("SetHighlightStatus"); }
187  virtual bool GetHighlightStatus(void) { InvalidAction("GetHighlightStatus"); return false; }
188 
189  // Actions on Sliders.
190  virtual void Step(int /*nbSteps*/, MHEngine * /*engine*/) { InvalidAction("Step"); }
191  virtual void SetSliderValue(int /*nbSteps*/, MHEngine * /*engine*/) { InvalidAction("SetSliderValue"); }
192  virtual int GetSliderValue(void) { InvalidAction("GetSliderValue"); return 0; }
193  virtual void SetPortion(int /*newPortion*/, MHEngine * /*engine*/) { InvalidAction("SetPortion"); }
194  virtual int GetPortion(void) { InvalidAction("GetPortion"); return 0; }
195  // Additional action defined in UK MHEG.
196  virtual void SetSliderParameters(int /*newMin*/, int /*newMax*/, int /*newStep*/, MHEngine * /*engine*/)
197  { InvalidAction("SetSliderParameters"); }
198 
199  protected:
200 
201  void InvalidAction(const char *actionName);
202  public:
203  MHObjectRef m_ObjectReference; // Identifier of this object.
204 
205  virtual const char *ClassName() = 0; // For debugging messages.
206  protected:
207  bool m_fAvailable {false}; // Set once Preparation has completed.
208  bool m_fRunning {false}; // Set once Activation has completed.
209 
210  friend class MHEngine;
211 };
212 
213 // Get Availability Status - Does the object exist and is it available?.
215 {
216  public:
217  MHGetAvailabilityStatus(): MHElemAction(":GetAvailabilityStatus") {}
218  void Initialise(MHParseNode *p, MHEngine *engine) override; // MHElemAction
219  void Perform(MHEngine *engine) override; // MHElemAction
220  protected:
221  void PrintArgs(FILE *fd, int /*nTabs*/) const override // MHElemAction
222  { m_ResultVar.PrintMe(fd, 0); }
224 };
225 
226 // Get Running Status - Is the object running?.
228 {
229  public:
230  MHGetRunningStatus(): MHActionObjectRef(":GetRunningStatus") {}
231  void CallAction(MHEngine *, MHRoot *pTarget, MHRoot *pResult) override // MHActionObjectRef
232  { pResult->SetVariableValue(pTarget->GetRunningStatus());}
233 };
234 
235 #endif
virtual void GetListSize(MHRoot *, MHEngine *)
Definition: Root.h:134
virtual void SetFontAttributes(const MHOctetString &, MHEngine *)
Definition: Root.h:107
virtual void Destruction(MHEngine *engine)
Definition: Root.cpp:97
virtual void ScaleBitmap(int, int, MHEngine *)
Definition: Root.h:156
virtual void DeselectItem(int, MHEngine *)
Definition: Root.h:129
virtual void GetTextData(MHRoot *, MHEngine *)
Definition: Root.h:104
void PrintMe(FILE *fd, int nTabs) const
virtual void SetTextColour(const MHColour &, MHEngine *)
Definition: Root.h:106
void Perform(MHEngine *engine) override
Definition: Root.cpp:130
virtual void GetBoxSize(MHRoot *, MHRoot *)
Definition: Root.h:140
virtual bool IsShared()
Definition: Root.h:54
virtual void SetVariableValue(const MHUnion &)
Definition: Root.h:101
virtual MHRoot * FindByObjectNo(int n)
Definition: Root.cpp:115
virtual void Clear()
Definition: Root.h:161
virtual void PrintMe(FILE *fd, int nTabs) const
Definition: Root.cpp:38
virtual int GetSliderValue(void)
Definition: Root.h:192
virtual void SetSliderParameters(int, int, int, MHEngine *)
Definition: Root.h:196
virtual void ScaleVideo(int, int, MHEngine *)
Definition: Root.h:175
virtual void GetLineWidth(MHRoot *)
Definition: Root.h:162
virtual void GetCounterPosition(MHRoot *, MHEngine *)
Definition: Root.h:178
void InvalidAction(const char *actionName)
Definition: Root.cpp:45
virtual void SetFirstItem(int, MHEngine *)
Definition: Root.h:132
virtual void GetVariableValue(MHUnion &, MHEngine *)
Definition: Root.h:100
virtual void SetSliderValue(int, MHEngine *)
Definition: Root.h:191
virtual ~MHRoot()
Definition: Root.h:48
virtual void SendToBack(MHEngine *)
Definition: Root.h:143
virtual void Activation(MHEngine *engine)
Definition: Root.cpp:69
virtual bool GetRunningStatus()
Definition: Root.h:76
bool m_fAvailable
Definition: Root.h:207
virtual void DrawPoly(bool, int, const int *, const int *, MHEngine *)
Definition: Root.h:171
virtual void Deactivation(MHEngine *engine)
Definition: Root.cpp:85
virtual void SetBitmapDecodeOffset(int, int, MHEngine *)
Definition: Root.h:157
virtual void SetPosition(int, int, MHEngine *)
Definition: Root.h:137
virtual void SetInputRegister(int, MHEngine *)
Definition: Root.h:82
virtual void DrawRectangle(int, int, int, int, MHEngine *)
Definition: Root.h:170
void PrintArgs(FILE *fd, int) const override
Definition: Root.h:221
virtual int GetPortion(void)
Definition: Root.h:194
virtual bool GetInteractionStatus(void)
Definition: Root.h:185
virtual void GetItemStatus(int, const MHObjectRef &, MHEngine *)
Definition: Root.h:127
virtual void GetLineStyle(MHRoot *)
Definition: Root.h:163
virtual void GetListItem(int, const MHObjectRef &, MHEngine *)
Definition: Root.h:126
virtual const char * ClassName()=0
virtual void DrawArcSector(bool, int, int, int, int, int, int, MHEngine *)
Definition: Root.h:166
void CallAction(MHEngine *, MHRoot *pTarget, MHRoot *pResult) override
Definition: Root.h:231
virtual void GetTokenPosition(MHRoot *, MHEngine *)
Definition: Root.h:120
virtual void GetLineColour(MHRoot *)
Definition: Root.h:164
virtual void SetTransparency(int, MHEngine *)
Definition: Root.h:155
virtual void Activate(bool, MHEngine *)
Definition: Root.h:110
virtual void AddItem(int, MHRoot *, MHEngine *)
Definition: Root.h:123
virtual MHIngredient * Clone(MHEngine *)
Definition: Root.h:91
virtual void Move(int, MHEngine *)
Definition: Root.h:118
virtual void DrawLine(int, int, int, int, MHEngine *)
Definition: Root.h:168
MHObjectRef m_ResultVar
Definition: Root.h:223
virtual void SetBoxSize(int, int, MHEngine *)
Definition: Root.h:139
virtual void SetLineWidth(int, MHEngine *)
Definition: Root.h:151
virtual void SetLineStyle(int, MHEngine *)
Definition: Root.h:152
virtual void SelectItem(int, MHEngine *)
Definition: Root.h:128
virtual void GetBitmapDecodeOffset(MHRoot *, MHRoot *)
Definition: Root.h:158
virtual void SetData(const MHContentRef &, bool, int, bool, int, MHEngine *)
Definition: Root.h:86
virtual bool GetAvailabilityStatus()
Definition: Root.h:75
virtual void ToggleItem(int, MHEngine *)
Definition: Root.h:130
virtual void ContentPreparation(MHEngine *)
Definition: Root.h:66
virtual void ScrollItems(int, MHEngine *)
Definition: Root.h:131
virtual void CallActionSlot(int, MHEngine *)
Definition: Root.h:117
virtual void Run(MHEngine *)
Definition: Root.h:95
virtual void DrawOval(int, int, int, int, MHEngine *)
Definition: Root.h:169
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: Root.cpp:124
MHRoot(const MHRoot &)
Definition: Root.h:47
virtual void GetFillColour(MHRoot *)
Definition: Root.h:165
virtual void DelItem(MHRoot *, MHEngine *)
Definition: Root.h:124
Definition: Root.h:43
bool m_fRunning
Definition: Root.h:208
MHObjectRef m_ObjectReference
Definition: Root.h:203
virtual void PutBefore(const MHRoot *, MHEngine *)
Definition: Root.h:144
int FILE
Definition: mythburn.py:110
virtual void SetPaletteRef(const MHObjectRef, MHEngine *)
Definition: Root.h:141
virtual bool GetHighlightStatus(void)
Definition: Root.h:187
virtual void SetTimer(int, bool, int, MHEngine *)
Definition: Root.h:79
virtual void GetCellItem(int, const MHObjectRef &, MHEngine *)
Definition: Root.h:125
virtual void MoveTo(int, MHEngine *)
Definition: Root.h:119
virtual void Preload(MHEngine *)
Definition: Root.h:88
virtual void Unload(MHEngine *)
Definition: Root.h:89
MHGetRunningStatus()
Definition: Root.h:230
virtual void CallProgram(bool, const MHObjectRef &, const MHSequence< MHParameter * > &, MHEngine *)
Definition: Root.h:113
virtual void MakeClone(MHRoot *, MHRoot *, MHEngine *)
Definition: Root.h:81
virtual void Initialise(MHParseNode *p, MHEngine *engine)
Definition: Root.cpp:30
virtual void PutBehind(const MHRoot *, MHEngine *)
Definition: Root.h:145
virtual void SetFillColour(const MHColour &, MHEngine *)
Definition: Root.h:149
virtual void SetCounterPosition(int, MHEngine *)
Definition: Root.h:180
virtual void ResetPosition()
Definition: Root.h:146
virtual void Stop(MHEngine *)
Definition: Root.h:96
virtual void GetCounterMaxPosition(MHRoot *, MHEngine *)
Definition: Root.h:179
virtual void SetVideoDecodeOffset(int, int, MHEngine *)
Definition: Root.h:176
virtual void SetLineColour(const MHColour &, MHEngine *)
Definition: Root.h:150
virtual void SetSpeed(int, MHEngine *)
Definition: Root.h:181
virtual void SetPortion(int, MHEngine *)
Definition: Root.h:193
virtual void BringToFront(MHEngine *)
Definition: Root.h:142
virtual void Step(int, MHEngine *)
Definition: Root.h:190
virtual void GetVideoDecodeOffset(MHRoot *, MHRoot *, MHEngine *)
Definition: Root.h:177
EventType
Definition: Root.h:33
virtual void SetBackgroundColour(const MHColour &, MHEngine *)
Definition: Root.h:105
virtual void TestVariable(int, const MHUnion &, MHEngine *)
Definition: Root.h:99
virtual void SetData(const MHOctetString &, MHEngine *)
Definition: Root.h:85
virtual void Preparation(MHEngine *engine)
Definition: Root.cpp:52
virtual void SetInteractionStatus(bool, MHEngine *)
Definition: Root.h:184
virtual void GetFirstItem(MHRoot *, MHEngine *)
Definition: Root.h:133
virtual void SetHighlightStatus(bool, MHEngine *)
Definition: Root.h:186
virtual void GetPosition(MHRoot *, MHRoot *)
Definition: Root.h:138
MHRoot()
Definition: Root.h:46