MythTV  master
BaseActions.h
Go to the documentation of this file.
1 /* BaseActions.h
2 
3  Copyright (C) David C. J. Matthews 2004, 2008 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(BASEACTIONS_H)
23 #define BASEACTIONS_H
24 
25 #include "BaseClasses.h"
26 
27 class MHParseNode;
28 class MHRoot;
29 
30 // Abstract base class for MHEG elementary actions.
31 // The first argument of most (all?) actions is an object reference which is
32 // the target of the action so we can handle some of the parsing and printing
33 // within this class rather than the derived classes.
35 {
36  public:
37  explicit MHElemAction(const char *name): m_actionName(name) {}
38  virtual ~MHElemAction() = default;
39  virtual void Initialise(MHParseNode *p, MHEngine *engine);
40  virtual void PrintMe(FILE *fd, int nTabs) const;
41  virtual void Perform(MHEngine *engine) = 0; // Perform the action.
42  protected:
43  virtual void PrintArgs(FILE */*file*/, int /*nTabs*/) const {}
44  MHRoot *Target(MHEngine *engine); // Look up the target
45  const char *m_actionName {nullptr};
47 };
48 
49 
50 // Base class for actions with a single integer argument.
52 {
53  public:
54  explicit MHActionInt(const char *name): MHElemAction(name) {}
55  void Initialise(MHParseNode *p, MHEngine *engine) override; // MHElemAction
56  void PrintArgs(FILE *fd, int /*nTabs*/) const override // MHElemAction
57  { m_argument.PrintMe(fd, 0); }
58  void Perform(MHEngine *engine) override; // MHElemAction
59  virtual void CallAction(MHEngine *engine, MHRoot *pTarget, int nArg) = 0;
60  protected:
62 };
63 
64 // Base class for actions with a pair of integer arguments.
66 {
67  public:
68  explicit MHActionIntInt(const char *name): MHElemAction(name) {}
69  void Initialise(MHParseNode *p, MHEngine *engine) override; // MHElemAction
70  void PrintArgs(FILE *fd, int/* nTabs*/) const override // MHElemAction
71  { m_argument1.PrintMe(fd, 0); m_argument2.PrintMe(fd, 0); }
72  void Perform(MHEngine *engine) override; // MHElemAction
73  virtual void CallAction(MHEngine *engine, MHRoot *pTarget, int nArg1, int nArg2) = 0;
74  protected:
76 };
77 
78 // Base class for actions with three integers. Used for SetSliderParameters
80 {
81  public:
82  explicit MHActionInt3(const char *name): MHElemAction(name) {}
83  void Initialise(MHParseNode *p, MHEngine *engine) override; // MHElemAction
84  void PrintArgs(FILE *fd, int nTabs) const override; // MHElemAction
85  void Perform(MHEngine *engine) override; // MHElemAction
86  virtual void CallAction(MHEngine *engine, MHRoot *pTarget, int nArg1, int nArg2, int nArg3) = 0;
87  protected:
89 };
90 
91 // Base class for actions with four integers. Used in the DynamicLineArt class
93 {
94  public:
95  explicit MHActionInt4(const char *name): MHElemAction(name) {}
96  void Initialise(MHParseNode *p, MHEngine *engine) override; // MHElemAction
97  void PrintArgs(FILE *fd, int nTabs) const override; // MHElemAction
98  void Perform(MHEngine *engine) override; // MHElemAction
99  virtual void CallAction(MHEngine *engine, MHRoot *pTarget, int nArg1, int nArg2, int nArg3, int nArg4) = 0;
100  protected:
102 };
103 
104 // Base class for actions with six integers. Used in the DynamicLineArt class
106 {
107  public:
108  explicit MHActionInt6(const char *name): MHElemAction(name) {}
109  void Initialise(MHParseNode *p, MHEngine *engine) override; // MHElemAction
110  void PrintArgs(FILE *fd, int nTabs) const override; // MHElemAction
111  void Perform(MHEngine *engine) override; // MHElemAction
112  virtual void CallAction(MHEngine *engine, MHRoot *pTarget, int nArg1, int nArg2, int nArg3, int nArg4, int nArg5, int nArg6) = 0;
113  protected:
115 };
116 
117 
118 // An action with an object reference as an argument.
120 {
121  public:
122  explicit MHActionObjectRef(const char *name): MHElemAction(name) {}
123  void Initialise(MHParseNode *p, MHEngine *engine) override; // MHElemAction
124  void Perform(MHEngine *engine) override; // MHElemAction
125  virtual void CallAction(MHEngine *engine, MHRoot *pTarget, MHRoot *pArg) = 0;
126  private:
127  void PrintArgs(FILE *fd, int/* nTabs*/) const override // MHElemAction
128  { m_resultVar.PrintMe(fd, 0); }
130 };
131 
132 // An action with two object references as an argument.
134 {
135  public:
136  explicit MHActionObjectRef2(const char *name): MHElemAction(name) {}
137  void Initialise(MHParseNode *p, MHEngine *engine) override; // MHElemAction
138  void Perform(MHEngine *engine) override; // MHElemAction
139  virtual void CallAction(MHEngine *engine, MHRoot *pTarget, MHRoot *pArg1, MHRoot *pArg2) = 0;
140  private:
141  void PrintArgs(FILE *fd, int/* nTabs*/) const override // MHElemAction
142  { m_resultVar1.PrintMe(fd, 0); m_resultVar2.PrintMe(fd, 0);}
144 };
145 
147 {
148  public:
149  explicit MHActionGenericObjectRef(const char *name): MHElemAction(name) {}
150  void Initialise(MHParseNode *p, MHEngine *engine) override; // MHElemAction
151  void Perform(MHEngine *engine) override; // MHElemAction
152  virtual void CallAction(MHEngine *engine, MHRoot *pTarget, MHRoot *pObj) = 0;
153  protected:
154  void PrintArgs(FILE *fd, int/* nTabs*/) const override // MHElemAction
155  { m_refObject.PrintMe(fd, 0); }
157 };
158 
159 
160 // Base class for actions with a single boolean argument.
162 {
163  public:
164  explicit MHActionBool(const char *name): MHElemAction(name) {}
165  void Initialise(MHParseNode *p, MHEngine *engine) override; // MHElemAction
166  void PrintArgs(FILE *fd, int /*nTabs*/) const override // MHElemAction
167  { m_argument.PrintMe(fd, 0); }
168  void Perform(MHEngine *engine) override; // MHElemAction
169  virtual void CallAction(MHEngine *engine, MHRoot *pTarget, bool fArg) = 0;
170  protected:
172 };
173 
174 #endif
MHActionInt::Initialise
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: BaseActions.cpp:53
MHActionObjectRef2::CallAction
virtual void CallAction(MHEngine *engine, MHRoot *pTarget, MHRoot *pArg1, MHRoot *pArg2)=0
MHObjectRef
Definition: BaseClasses.h:153
MHActionInt6::m_argument1
MHGenericInteger m_argument1
Definition: BaseActions.h:114
MHActionObjectRef::MHActionObjectRef
MHActionObjectRef(const char *name)
Definition: BaseActions.h:122
MHActionObjectRef
Definition: BaseActions.h:120
MHActionGenericObjectRef
Definition: BaseActions.h:147
MHActionBool
Definition: BaseActions.h:162
MHActionIntInt::Perform
void Perform(MHEngine *engine) override
Definition: BaseActions.cpp:72
MHActionObjectRef::Perform
void Perform(MHEngine *engine) override
Definition: BaseActions.cpp:173
MHActionObjectRef2::MHActionObjectRef2
MHActionObjectRef2(const char *name)
Definition: BaseActions.h:136
MHActionObjectRef2::Initialise
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: BaseActions.cpp:83
MHActionInt4::Initialise
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: BaseActions.cpp:110
MHActionInt4::m_argument1
MHGenericInteger m_argument1
Definition: BaseActions.h:101
MHGenericBoolean
Definition: BaseClasses.h:202
MHEngine
Definition: Engine.h:72
MHActionBool::m_argument
MHGenericBoolean m_argument
Definition: BaseActions.h:171
MHActionInt6::Perform
void Perform(MHEngine *engine) override
Definition: BaseActions.cpp:153
MHActionInt::PrintArgs
void PrintArgs(FILE *fd, int) const override
Definition: BaseActions.h:56
MHActionInt6::m_argument3
MHGenericInteger m_argument3
Definition: BaseActions.h:114
MHActionObjectRef::m_resultVar
MHObjectRef m_resultVar
Definition: BaseActions.h:129
MHGenericInteger
Definition: BaseClasses.h:213
MHActionInt4
Definition: BaseActions.h:93
MHActionInt3::m_argument2
MHGenericInteger m_argument2
Definition: BaseActions.h:88
MHActionBool::PrintArgs
void PrintArgs(FILE *fd, int) const override
Definition: BaseActions.h:166
MHActionObjectRef2::PrintArgs
void PrintArgs(FILE *fd, int) const override
Definition: BaseActions.h:141
MHActionInt4::m_argument4
MHGenericInteger m_argument4
Definition: BaseActions.h:101
MHActionInt3::Initialise
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: BaseActions.cpp:90
MHActionInt::Perform
void Perform(MHEngine *engine) override
Definition: BaseActions.cpp:60
MHActionInt4::MHActionInt4
MHActionInt4(const char *name)
Definition: BaseActions.h:95
MHActionInt6::m_argument2
MHGenericInteger m_argument2
Definition: BaseActions.h:114
MHActionBool::Initialise
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: BaseActions.cpp:184
MHElemAction::Initialise
virtual void Initialise(MHParseNode *p, MHEngine *engine)
Definition: BaseActions.cpp:31
MHActionInt4::PrintArgs
void PrintArgs(FILE *fd, int nTabs) const override
Definition: BaseActions.cpp:119
MHActionInt3::MHActionInt3
MHActionInt3(const char *name)
Definition: BaseActions.h:82
MHActionInt4::m_argument2
MHGenericInteger m_argument2
Definition: BaseActions.h:101
mythburn.FILE
int FILE
Definition: mythburn.py:139
MHActionInt4::Perform
void Perform(MHEngine *engine) override
Definition: BaseActions.cpp:127
MHActionInt6::PrintArgs
void PrintArgs(FILE *fd, int nTabs) const override
Definition: BaseActions.cpp:143
MHActionIntInt::PrintArgs
void PrintArgs(FILE *fd, int) const override
Definition: BaseActions.h:70
MHActionGenericObjectRef::Initialise
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: BaseActions.cpp:160
MHActionInt6::CallAction
virtual void CallAction(MHEngine *engine, MHRoot *pTarget, int nArg1, int nArg2, int nArg3, int nArg4, int nArg5, int nArg6)=0
MHActionInt::CallAction
virtual void CallAction(MHEngine *engine, MHRoot *pTarget, int nArg)=0
MHActionObjectRef2::m_resultVar2
MHObjectRef m_resultVar2
Definition: BaseActions.h:143
MHActionIntInt::Initialise
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: BaseActions.cpp:65
MHActionObjectRef2::m_resultVar1
MHObjectRef m_resultVar1
Definition: BaseActions.h:143
MHActionInt3
Definition: BaseActions.h:80
hardwareprofile.config.p
p
Definition: config.py:33
MHActionIntInt::MHActionIntInt
MHActionIntInt(const char *name)
Definition: BaseActions.h:68
MHActionInt4::m_argument3
MHGenericInteger m_argument3
Definition: BaseActions.h:101
MHGenericObjectRef
Definition: BaseClasses.h:235
MHActionInt6::Initialise
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: BaseActions.cpp:132
MHActionBool::CallAction
virtual void CallAction(MHEngine *engine, MHRoot *pTarget, bool fArg)=0
MHActionBool::MHActionBool
MHActionBool(const char *name)
Definition: BaseActions.h:164
MHActionGenericObjectRef::MHActionGenericObjectRef
MHActionGenericObjectRef(const char *name)
Definition: BaseActions.h:149
MHElemAction::m_actionName
const char * m_actionName
Definition: BaseActions.h:45
MHActionIntInt::m_argument1
MHGenericInteger m_argument1
Definition: BaseActions.h:75
MHActionIntInt
Definition: BaseActions.h:66
MHActionObjectRef::PrintArgs
void PrintArgs(FILE *fd, int) const override
Definition: BaseActions.h:127
MHGenericBoolean::PrintMe
void PrintMe(FILE *fd, int nTabs) const
Definition: BaseClasses.cpp:358
MHActionObjectRef::CallAction
virtual void CallAction(MHEngine *engine, MHRoot *pTarget, MHRoot *pArg)=0
MHElemAction::~MHElemAction
virtual ~MHElemAction()=default
MHActionInt::m_argument
MHGenericInteger m_argument
Definition: BaseActions.h:61
MHActionInt
Definition: BaseActions.h:52
MHActionObjectRef2
Definition: BaseActions.h:134
MHActionGenericObjectRef::PrintArgs
void PrintArgs(FILE *fd, int) const override
Definition: BaseActions.h:154
MHElemAction::Target
MHRoot * Target(MHEngine *engine)
Definition: BaseActions.cpp:46
MHActionInt6
Definition: BaseActions.h:106
MHActionInt3::m_argument3
MHGenericInteger m_argument3
Definition: BaseActions.h:88
MHActionObjectRef::Initialise
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: BaseActions.cpp:77
MHActionBool::Perform
void Perform(MHEngine *engine) override
Definition: BaseActions.cpp:191
MHActionObjectRef2::Perform
void Perform(MHEngine *engine) override
Definition: BaseActions.cpp:179
MHActionInt3::Perform
void Perform(MHEngine *engine) override
Definition: BaseActions.cpp:105
MHActionInt3::CallAction
virtual void CallAction(MHEngine *engine, MHRoot *pTarget, int nArg1, int nArg2, int nArg3)=0
MHElemAction::PrintArgs
virtual void PrintArgs(FILE *, int) const
Definition: BaseActions.h:43
BaseClasses.h
MHActionInt3::m_argument1
MHGenericInteger m_argument1
Definition: BaseActions.h:88
MHActionInt6::MHActionInt6
MHActionInt6(const char *name)
Definition: BaseActions.h:108
MHParseNode
Definition: ParseNode.h:39
MHActionInt::MHActionInt
MHActionInt(const char *name)
Definition: BaseActions.h:54
MHActionInt3::PrintArgs
void PrintArgs(FILE *fd, int nTabs) const override
Definition: BaseActions.cpp:98
MHElemAction::m_target
MHGenericObjectRef m_target
Definition: BaseActions.h:46
MHActionGenericObjectRef::m_refObject
MHGenericObjectRef m_refObject
Definition: BaseActions.h:156
MHGenericInteger::PrintMe
void PrintMe(FILE *fd, int nTabs) const
Definition: BaseClasses.cpp:412
MHActionInt6::m_argument6
MHGenericInteger m_argument6
Definition: BaseActions.h:114
MHElemAction::Perform
virtual void Perform(MHEngine *engine)=0
MHElemAction
Definition: BaseActions.h:35
MHActionInt6::m_argument4
MHGenericInteger m_argument4
Definition: BaseActions.h:114
MHActionInt4::CallAction
virtual void CallAction(MHEngine *engine, MHRoot *pTarget, int nArg1, int nArg2, int nArg3, int nArg4)=0
MHGenericObjectRef::PrintMe
void PrintMe(FILE *fd, int nTabs) const
Definition: BaseClasses.cpp:554
MHActionIntInt::CallAction
virtual void CallAction(MHEngine *engine, MHRoot *pTarget, int nArg1, int nArg2)=0
MHObjectRef::PrintMe
void PrintMe(FILE *fd, int nTabs) const
Definition: BaseClasses.cpp:299
MHActionGenericObjectRef::CallAction
virtual void CallAction(MHEngine *engine, MHRoot *pTarget, MHRoot *pObj)=0
MHElemAction::PrintMe
virtual void PrintMe(FILE *fd, int nTabs) const
Definition: BaseActions.cpp:37
MHActionGenericObjectRef::Perform
void Perform(MHEngine *engine) override
Definition: BaseActions.cpp:166
MHElemAction::MHElemAction
MHElemAction(const char *name)
Definition: BaseActions.h:37
MHActionInt6::m_argument5
MHGenericInteger m_argument5
Definition: BaseActions.h:114
MHRoot
Definition: Root.h:44
MHActionIntInt::m_argument2
MHGenericInteger m_argument2
Definition: BaseActions.h:75