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  virtual ~MHIngredient() = 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 *, int, MHEngine *) { }
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  virtual ~MHFont() = 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  virtual ~MHCursorShape() = 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  virtual ~MHPalette() = 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
void Preparation(MHEngine *engine) override
Definition: cc.h:13
int m_nOrigContentSize
Definition: Ingredients.h:74
void PrintMe(FILE *fd, int nTabs) const override
void Unload(MHEngine *engine) override
Definition: Ingredients.h:58
const char * ClassName() override
Definition: Ingredients.h:90
void PrintMe(FILE *fd, int nTabs) const override
virtual ~MHPalette()=default
MHCursorShape()=default
virtual ~MHIngredient()=default
void Preload(MHEngine *engine) override
Definition: Ingredients.h:56
virtual bool InitiallyAvailable()
Definition: Ingredients.h:43
MHRoot * Target(MHEngine *engine)
Definition: BaseActions.cpp:46
virtual bool InitiallyActive()
Definition: Ingredients.h:42
virtual ~MHFont()=default
void PrintMe(FILE *fd, int nTabs) const override
enum MHIngredient::@10 IN_NoContent
MHOctetString m_OrigIncludedContent
Definition: Ingredients.h:72
bool m_fInitiallyActive
Definition: Ingredients.h:65
int m_nContentHook
Definition: Ingredients.h:66
MHGenericInteger m_CCPriority
Definition: Ingredients.h:143
virtual void ContentArrived(const unsigned char *, int, MHEngine *)
Definition: Ingredients.h:62
void Initialise(MHParseNode *p, MHEngine *engine) override
void ContentPreparation(MHEngine *engine) override
void PrintArgs(FILE *fd, int nTabs) const override
void PrintMe(FILE *fd, int nTabs) const override
MHGenericOctetString m_Included
Definition: Ingredients.h:140
void Perform(MHEngine *engine) override
bool IsShared() override
Definition: Ingredients.h:44
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: Ingredients.cpp:49
bool m_fShared
Definition: Ingredients.h:68
void CallAction(MHEngine *engine, MHRoot *pTarget, MHRoot *pRef) override
MHGenericContentRef m_Referenced
Definition: Ingredients.h:141
int m_nOrigCCPrio
Definition: Ingredients.h:75
MHPalette()=default
MHIngredient()=default
int m_nContentSize
Definition: Ingredients.h:79
bool m_fCCPriorityPresent
Definition: Ingredients.h:139
bool m_fIsIncluded
Definition: Ingredients.h:137
MHFont()=default
Definition: Root.h:43
void Initialise(MHParseNode *p, MHEngine *engine) override
int FILE
Definition: mythburn.py:110
void SetData(const MHOctetString &included, MHEngine *engine) override
const char * ClassName() override
Definition: Ingredients.h:118
void Destruction(MHEngine *engine) override
virtual ~MHCursorShape()=default
virtual void Preload(MHEngine *)
Definition: Root.h:88
MHOctetString m_IncludedContent
Definition: Ingredients.h:77
virtual void Unload(MHEngine *)
Definition: Root.h:89
MHGenericInteger m_ContentSize
Definition: Ingredients.h:142
MHContentRef m_OrigContentRef
Definition: Ingredients.h:73
void Perform(MHEngine *engine) override
Definition: Ingredients.h:151
void Perform(MHEngine *engine) override
Definition: Ingredients.h:159
void Initialise(MHParseNode *p, MHEngine *engine) override
void Initialise(MHParseNode *p, MHEngine *engine) override
const char * ClassName() override
Definition: Ingredients.h:104
bool m_fSizePresent
Definition: Ingredients.h:138
MHContentRef m_ContentRef
Definition: Ingredients.h:78