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#ifndef INGREDIENTS_H
23#define INGREDIENTS_H
24
25#include "Root.h"
26#include "BaseClasses.h"
27#include "Actions.h"
28#include "BaseActions.h"
29
30class MHParseNode;
31
32// Abstract class for ingredients of a scene or application.
33class 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.
71 enum : std::uint8_t { IN_NoContent, IN_IncludedContent, IN_ReferencedContent } m_contentType {IN_NoContent};
75 int m_nOrigCCPrio {127}; // Default.
76 // Internal attributes
80 int m_nCCPrio {0};
81 friend class MHEngine;
82};
83
84// Font - not needed for UK MHEG
85class 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
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
113class 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.
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};
144};
145
146// Preload and unload
148{
149 public:
150 MHPreload(): MHElemAction(":Preload") {}
151 void Perform(MHEngine *engine) override // MHElemAction
152 { Target(engine)->Preload(engine); }
153};
154
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 CallAction(MHEngine *engine, MHRoot *pTarget, MHRoot *pRef) override
MHCursorShape()=default
void PrintMe(FILE *fd, int nTabs) const override
const char * ClassName() override
Definition: Ingredients.h:104
void Initialise(MHParseNode *p, MHEngine *engine) override
~MHCursorShape() override=default
MHRoot * Target(MHEngine *engine)
Definition: BaseActions.cpp:46
~MHFont() override=default
MHFont()=default
void Initialise(MHParseNode *p, MHEngine *engine) override
const char * ClassName() override
Definition: Ingredients.h:90
void PrintMe(FILE *fd, int nTabs) const override
void Preload(MHEngine *engine) override
Definition: Ingredients.h:56
void ContentPreparation(MHEngine *engine) override
enum MHIngredient::@4 IN_NoContent
void Destruction(MHEngine *engine) override
MHContentRef m_contentRef
Definition: Ingredients.h:78
void Preparation(MHEngine *engine) override
MHOctetString m_includedContent
Definition: Ingredients.h:77
int m_nOrigContentSize
Definition: Ingredients.h:74
bool m_fShared
Definition: Ingredients.h:68
bool m_fInitiallyActive
Definition: Ingredients.h:65
virtual void ContentArrived(const unsigned char *, int, MHEngine *)
Definition: Ingredients.h:62
int m_nContentSize
Definition: Ingredients.h:79
MHIngredient()=default
bool IsShared() override
Definition: Ingredients.h:44
~MHIngredient() override=default
MHOctetString m_origIncludedContent
Definition: Ingredients.h:72
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: Ingredients.cpp:50
int m_nOrigCCPrio
Definition: Ingredients.h:75
virtual bool InitiallyAvailable()
Definition: Ingredients.h:43
int m_nContentHook
Definition: Ingredients.h:66
void PrintMe(FILE *fd, int nTabs) const override
@ IN_ReferencedContent
Definition: Ingredients.h:71
@ IN_IncludedContent
Definition: Ingredients.h:71
void SetData(const MHOctetString &included, MHEngine *engine) override
void Unload(MHEngine *engine) override
Definition: Ingredients.h:58
MHContentRef m_origContentRef
Definition: Ingredients.h:73
virtual bool InitiallyActive()
Definition: Ingredients.h:42
~MHPalette() override=default
void Initialise(MHParseNode *p, MHEngine *engine) override
void PrintMe(FILE *fd, int nTabs) const override
MHPalette()=default
const char * ClassName() override
Definition: Ingredients.h:118
void Perform(MHEngine *engine) override
Definition: Ingredients.h:151
Definition: Root.h:45
virtual void Unload(MHEngine *)
Definition: Root.h:95
virtual void Preload(MHEngine *)
Definition: Root.h:94
bool m_fSizePresent
Definition: Ingredients.h:138
bool m_fIsIncluded
Definition: Ingredients.h:137
MHGenericInteger m_contentSize
Definition: Ingredients.h:142
void Initialise(MHParseNode *p, MHEngine *engine) override
void Perform(MHEngine *engine) override
bool m_fCCPriorityPresent
Definition: Ingredients.h:139
MHGenericInteger m_ccPriority
Definition: Ingredients.h:143
MHGenericContentRef m_referenced
Definition: Ingredients.h:141
void PrintArgs(FILE *fd, int nTabs) const override
MHGenericOctetString m_included
Definition: Ingredients.h:140
void Perform(MHEngine *engine) override
Definition: Ingredients.h:159
int FILE
Definition: mythburn.py:138