MythTV  master
Ingredients.h
Go to the documentation of this file.
1 /* Ingredients.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 #if !defined(INGREDIENTS_H)
23 #define INGREDIENTS_H
24 
25 #include "Root.h"
26 #include "BaseClasses.h"
27 #include "Actions.h"
28 #include "BaseActions.h"
29 
30 class MHParseNode;
31 
32 // Abstract class for ingredients of a scene or application.
33 class MHIngredient : public MHRoot
34 {
35  public:
36  MHIngredient() = default;
37  MHIngredient(const MHIngredient &ref);
38  ~MHIngredient() override = default;
39  // Set this up from the parse tree.
40  void Initialise(MHParseNode *p, MHEngine *engine) override; // MHRoot
41  void PrintMe(FILE *fd, int nTabs) const override; // MHRoot
42  virtual bool InitiallyActive() { return m_fInitiallyActive; }
43  virtual bool InitiallyAvailable() { return false; } // Used for programs only.
44  bool IsShared() override // MHRoot
45  { return m_fShared; }
46 
47  // Internal behaviours.
48  void Preparation(MHEngine *engine) override; // MHRoot
49  void Destruction(MHEngine *engine) override; // MHRoot
50  void ContentPreparation(MHEngine *engine) override; // MHRoot
51 
52  // Actions.
53  void SetData(const MHOctetString &included, MHEngine *engine) override; // MHRoot
54  void SetData(const MHContentRef &referenced, bool fSizeGiven,
55  int size, bool fCCGiven, int cc, MHEngine *engine) override; // MHRoot
56  void Preload(MHEngine *engine) override // MHRoot
57  { Preparation(engine); }
58  void Unload(MHEngine *engine) override // MHRoot
59  { Destruction(engine); }
60 
61  // Called by the engine to deliver external content.
62  virtual void ContentArrived(const unsigned char */*data*/, int/*length*/, MHEngine */*engine*/) { }
63 
64  protected:
65  bool m_fInitiallyActive {true}; // Default is true
66  int m_nContentHook {0}; // Need to choose a value that
67  // isn't otherwise used
68  bool m_fShared {false};
69  // Original content. The original included content and the other fields are
70  // mutually exclusive.
75  int m_nOrigCCPrio {127}; // Default.
76  // Internal attributes
79  int m_nContentSize {0};
80  int m_nCCPrio {0};
81  friend class MHEngine;
82 };
83 
84 // Font - not needed for UK MHEG
85 class MHFont : public MHIngredient
86 {
87  public:
88  MHFont() = default;
89  ~MHFont() override = default;
90  const char *ClassName() override // MHRoot
91  { return "Font"; }
92  void Initialise(MHParseNode *p, MHEngine *engine) override; // MHIngredient
93  void PrintMe(FILE *fd, int nTabs) const override; // MHIngredient
94 
95  protected:
96 };
97 
98 // CursorShape - not needed for UK MHEG
99 class MHCursorShape : public MHIngredient
100 {
101  public:
102  MHCursorShape() = default;
103  ~MHCursorShape() override = default;
104  const char *ClassName() override // MHRoot
105  { return "CursorShape"; }
106  void Initialise(MHParseNode *p, MHEngine *engine) override; // MHIngredient
107  void PrintMe(FILE *fd, int nTabs) const override; // MHIngredient
108 
109  protected:
110 };
111 
112 // Paletter - not needed for UK MHEG
113 class MHPalette : public MHIngredient
114 {
115  public:
116  MHPalette() = default;
117  ~MHPalette() override = default;
118  const char *ClassName() override // MHRoot
119  { return "Palette"; }
120  void Initialise(MHParseNode *p, MHEngine *engine) override; // MHIngredient
121  void PrintMe(FILE *fd, int nTabs) const override; // MHIngredient
122 
123  protected:
124 };
125 
126 // Actions.
127 // SetData - provide new content for an ingredient.
128 class MHSetData: public MHElemAction
129 {
130  public:
131  MHSetData(): MHElemAction(":SetData") {}
132  void Initialise(MHParseNode *p, MHEngine *engine) override; // MHElemAction
133  void Perform(MHEngine *engine) override; // MHElemAction
134  void PrintArgs(FILE *fd, int nTabs) const override; // MHElemAction
135  protected:
136  // Either included content or referenced content.
137  bool m_fIsIncluded {false};
138  bool m_fSizePresent {false};
139  bool m_fCCPriorityPresent {false};
144 };
145 
146 // Preload and unload
147 class MHPreload: public MHElemAction
148 {
149  public:
150  MHPreload(): MHElemAction(":Preload") {}
151  void Perform(MHEngine *engine) override // MHElemAction
152  { Target(engine)->Preload(engine); }
153 };
154 
155 class MHUnload: public MHElemAction
156 {
157  public:
158  MHUnload(): MHElemAction(":Unload") {}
159  void Perform(MHEngine *engine) override // MHElemAction
160  { Target(engine)->Unload(engine); }
161 };
162 
163 // Clone - make a copy of an existing object.
165 {
166  public:
168  void CallAction(MHEngine *engine, MHRoot *pTarget, MHRoot *pRef) override; // MHActionGenericObjectRef
169 };
170 
171 #endif
MHFont::Initialise
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: Ingredients.cpp:239
MHActionGenericObjectRef
Definition: BaseActions.h:147
MHGenericOctetString
Definition: BaseClasses.h:224
MHGenericContentRef
Definition: BaseClasses.h:246
MHIngredient::MHIngredient
MHIngredient()=default
MHUnload::MHUnload
MHUnload()
Definition: Ingredients.h:158
MHPreload::Perform
void Perform(MHEngine *engine) override
Definition: Ingredients.h:151
MHSetData
Definition: Ingredients.h:129
MHCursorShape
Definition: Ingredients.h:100
MHRoot::Preload
virtual void Preload(MHEngine *)
Definition: Root.h:93
MHFont::~MHFont
~MHFont() override=default
MHIngredient::SetData
void SetData(const MHOctetString &included, MHEngine *engine) override
Definition: Ingredients.cpp:197
MHIngredient::Preparation
void Preparation(MHEngine *engine) override
Definition: Ingredients.cpp:159
MHSetData::m_fSizePresent
bool m_fSizePresent
Definition: Ingredients.h:138
MHEngine
Definition: Engine.h:72
MHFont
Definition: Ingredients.h:86
MHIngredient::IN_NoContent
enum MHIngredient::@10 IN_NoContent
MHIngredient::Initialise
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: Ingredients.cpp:49
MHIngredient::m_nCCPrio
int m_nCCPrio
Definition: Ingredients.h:80
cc
Definition: cc.h:10
MHGenericInteger
Definition: BaseClasses.h:213
MHIngredient::m_includedContent
MHOctetString m_includedContent
Definition: Ingredients.h:77
MHIngredient::m_origIncludedContent
MHOctetString m_origIncludedContent
Definition: Ingredients.h:72
MHFont::ClassName
const char * ClassName() override
Definition: Ingredients.h:90
MHSetData::m_fCCPriorityPresent
bool m_fCCPriorityPresent
Definition: Ingredients.h:139
MHIngredient::ContentPreparation
void ContentPreparation(MHEngine *engine) override
Definition: Ingredients.cpp:181
MHSetData::m_ccPriority
MHGenericInteger m_ccPriority
Definition: Ingredients.h:143
MHFont::MHFont
MHFont()=default
MHOctetString
Definition: BaseClasses.h:107
Actions.h
mythburn.FILE
int FILE
Definition: mythburn.py:139
MHIngredient::m_origContentRef
MHContentRef m_origContentRef
Definition: Ingredients.h:73
MHCursorShape::ClassName
const char * ClassName() override
Definition: Ingredients.h:104
MHCursorShape::Initialise
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: Ingredients.cpp:258
MHPalette
Definition: Ingredients.h:114
hardwareprofile.config.p
p
Definition: config.py:33
MHIngredient::~MHIngredient
~MHIngredient() override=default
MHRoot::Unload
virtual void Unload(MHEngine *)
Definition: Root.h:94
MHIngredient::InitiallyAvailable
virtual bool InitiallyAvailable()
Definition: Ingredients.h:43
MHIngredient::m_nContentSize
int m_nContentSize
Definition: Ingredients.h:79
MHSetData::PrintArgs
void PrintArgs(FILE *fd, int nTabs) const override
Definition: Ingredients.cpp:344
MHUnload
Definition: Ingredients.h:156
MHIngredient::m_nOrigCCPrio
int m_nOrigCCPrio
Definition: Ingredients.h:75
MHPalette::MHPalette
MHPalette()=default
MHSetData::m_contentSize
MHGenericInteger m_contentSize
Definition: Ingredients.h:142
MHCursorShape::PrintMe
void PrintMe(FILE *fd, int nTabs) const override
Definition: Ingredients.cpp:264
MHIngredient::PrintMe
void PrintMe(FILE *fd, int nTabs) const override
Definition: Ingredients.cpp:107
MHClone::MHClone
MHClone()
Definition: Ingredients.h:167
MHSetData::m_fIsIncluded
bool m_fIsIncluded
Definition: Ingredients.h:137
MHPalette::ClassName
const char * ClassName() override
Definition: Ingredients.h:118
MHPalette::Initialise
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: Ingredients.cpp:276
MHFont::PrintMe
void PrintMe(FILE *fd, int nTabs) const override
Definition: Ingredients.cpp:245
MHClone
Definition: Ingredients.h:165
MHUnload::Perform
void Perform(MHEngine *engine) override
Definition: Ingredients.h:159
MHPreload
Definition: Ingredients.h:148
MHIngredient::Preload
void Preload(MHEngine *engine) override
Definition: Ingredients.h:56
MHIngredient
Definition: Ingredients.h:34
MHIngredient::m_nOrigContentSize
int m_nOrigContentSize
Definition: Ingredients.h:74
MHElemAction::Target
MHRoot * Target(MHEngine *engine)
Definition: BaseActions.cpp:46
MHIngredient::m_fShared
bool m_fShared
Definition: Ingredients.h:68
MHIngredient::Unload
void Unload(MHEngine *engine) override
Definition: Ingredients.h:58
MHCursorShape::~MHCursorShape
~MHCursorShape() override=default
Root.h
MHContentRef
Definition: BaseClasses.h:174
MHPalette::~MHPalette
~MHPalette() override=default
MHIngredient::IN_ReferencedContent
@ IN_ReferencedContent
Definition: Ingredients.h:71
MHPalette::PrintMe
void PrintMe(FILE *fd, int nTabs) const override
Definition: Ingredients.cpp:282
MHSetData::Perform
void Perform(MHEngine *engine) override
Definition: Ingredients.cpp:368
MHIngredient::IsShared
bool IsShared() override
Definition: Ingredients.h:44
BaseClasses.h
MHIngredient::InitiallyActive
virtual bool InitiallyActive()
Definition: Ingredients.h:42
MHParseNode
Definition: ParseNode.h:39
MHIngredient::Destruction
void Destruction(MHEngine *engine) override
Definition: Ingredients.cpp:175
MHClone::CallAction
void CallAction(MHEngine *engine, MHRoot *pTarget, MHRoot *pRef) override
Definition: Ingredients.cpp:401
MHCursorShape::MHCursorShape
MHCursorShape()=default
MHSetData::m_referenced
MHGenericContentRef m_referenced
Definition: Ingredients.h:141
MHSetData::m_included
MHGenericOctetString m_included
Definition: Ingredients.h:140
MHIngredient::m_fInitiallyActive
bool m_fInitiallyActive
Definition: Ingredients.h:65
MHElemAction
Definition: BaseActions.h:35
MHSetData::Initialise
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: Ingredients.cpp:292
MHIngredient::ContentArrived
virtual void ContentArrived(const unsigned char *, int, MHEngine *)
Definition: Ingredients.h:62
MHIngredient::m_nContentHook
int m_nContentHook
Definition: Ingredients.h:66
MHPreload::MHPreload
MHPreload()
Definition: Ingredients.h:150
MHIngredient::m_contentRef
MHContentRef m_contentRef
Definition: Ingredients.h:78
BaseActions.h
MHIngredient::IN_IncludedContent
@ IN_IncludedContent
Definition: Ingredients.h:71
MHRoot
Definition: Root.h:44
MHSetData::MHSetData
MHSetData()
Definition: Ingredients.h:131