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  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 *, int) 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  MHActionInt(const char *name): MHElemAction(name) {}
55  void Initialise(MHParseNode *p, MHEngine *engine) override; // MHElemAction
56  void PrintArgs(FILE *fd, int) 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:
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  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  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  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:
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:
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:
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  MHActionBool(const char *name): MHElemAction(name) {}
165  void Initialise(MHParseNode *p, MHEngine *engine) override; // MHElemAction
166  void PrintArgs(FILE *fd, int) 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
void PrintArgs(FILE *fd, int nTabs) const override
Definition: BaseActions.cpp:98
MHGenericInteger m_Argument1
Definition: BaseActions.h:88
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: BaseActions.cpp:53
void Perform(MHEngine *engine) override
void PrintMe(FILE *fd, int nTabs) const
MHGenericInteger m_Argument2
Definition: BaseActions.h:88
virtual void CallAction(MHEngine *engine, MHRoot *pTarget, MHRoot *pObj)=0
void Perform(MHEngine *engine) override
Definition: BaseActions.cpp:60
MHGenericInteger m_Argument3
Definition: BaseActions.h:114
void Perform(MHEngine *engine) override
virtual void CallAction(MHEngine *engine, MHRoot *pTarget, int nArg1, int nArg2, int nArg3)=0
MHObjectRef m_ResultVar1
Definition: BaseActions.h:143
MHGenericObjectRef m_Target
Definition: BaseActions.h:46
void PrintArgs(FILE *fd, int nTabs) const override
MHRoot * Target(MHEngine *engine)
Definition: BaseActions.cpp:46
MHGenericInteger m_Argument4
Definition: BaseActions.h:114
void Initialise(MHParseNode *p, MHEngine *engine) override
void PrintArgs(FILE *fd, int) const override
Definition: BaseActions.h:56
MHGenericInteger m_Argument
Definition: BaseActions.h:61
virtual void PrintArgs(FILE *, int) const
Definition: BaseActions.h:43
void Perform(MHEngine *engine) override
Definition: BaseActions.cpp:72
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: BaseActions.cpp:83
MHActionGenericObjectRef(const char *name)
Definition: BaseActions.h:149
void PrintArgs(FILE *fd, int) const override
Definition: BaseActions.h:166
void PrintArgs(FILE *fd, int) const override
Definition: BaseActions.h:154
MHGenericInteger m_Argument1
Definition: BaseActions.h:75
MHActionInt4(const char *name)
Definition: BaseActions.h:95
void Perform(MHEngine *engine) override
MHActionObjectRef2(const char *name)
Definition: BaseActions.h:136
MHGenericObjectRef m_RefObject
Definition: BaseActions.h:156
void Perform(MHEngine *engine) override
MHActionIntInt(const char *name)
Definition: BaseActions.h:68
void PrintArgs(FILE *fd, int nTabs) const override
MHGenericInteger m_Argument2
Definition: BaseActions.h:75
virtual void PrintMe(FILE *fd, int nTabs) const
Definition: BaseActions.cpp:37
MHElemAction(const char *name)
Definition: BaseActions.h:37
void PrintArgs(FILE *fd, int) const override
Definition: BaseActions.h:127
void Initialise(MHParseNode *p, MHEngine *engine) override
MHActionBool(const char *name)
Definition: BaseActions.h:164
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: BaseActions.cpp:65
MHGenericInteger m_Argument3
Definition: BaseActions.h:101
MHGenericInteger m_Argument6
Definition: BaseActions.h:114
virtual void CallAction(MHEngine *engine, MHRoot *pTarget, int nArg)=0
MHActionInt6(const char *name)
Definition: BaseActions.h:108
const char * name
Definition: ParseText.cpp:328
Definition: Root.h:43
int FILE
Definition: mythburn.py:110
MHObjectRef m_ResultVar
Definition: BaseActions.h:129
virtual void CallAction(MHEngine *engine, MHRoot *pTarget, int nArg1, int nArg2, int nArg3, int nArg4, int nArg5, int nArg6)=0
MHObjectRef m_ResultVar2
Definition: BaseActions.h:143
virtual ~MHElemAction()=default
MHGenericInteger m_Argument1
Definition: BaseActions.h:114
MHGenericInteger m_Argument2
Definition: BaseActions.h:101
MHGenericInteger m_Argument3
Definition: BaseActions.h:88
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: BaseActions.cpp:77
void PrintMe(FILE *fd, int nTabs) const
void Initialise(MHParseNode *p, MHEngine *engine) override
virtual void CallAction(MHEngine *engine, MHRoot *pTarget, bool fArg)=0
virtual void Initialise(MHParseNode *p, MHEngine *engine)
Definition: BaseActions.cpp:31
virtual void CallAction(MHEngine *engine, MHRoot *pTarget, MHRoot *pArg1, MHRoot *pArg2)=0
virtual void CallAction(MHEngine *engine, MHRoot *pTarget, int nArg1, int nArg2)=0
MHActionInt3(const char *name)
Definition: BaseActions.h:82
virtual void CallAction(MHEngine *engine, MHRoot *pTarget, MHRoot *pArg)=0
const char * m_ActionName
Definition: BaseActions.h:45
void Perform(MHEngine *engine) override
MHGenericInteger m_Argument4
Definition: BaseActions.h:101
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: BaseActions.cpp:90
void Initialise(MHParseNode *p, MHEngine *engine) override
MHGenericBoolean m_Argument
Definition: BaseActions.h:171
virtual void CallAction(MHEngine *engine, MHRoot *pTarget, int nArg1, int nArg2, int nArg3, int nArg4)=0
MHActionObjectRef(const char *name)
Definition: BaseActions.h:122
void PrintArgs(FILE *fd, int) const override
Definition: BaseActions.h:141
void Perform(MHEngine *engine) override
MHGenericInteger m_Argument1
Definition: BaseActions.h:101
void PrintArgs(FILE *fd, int) const override
Definition: BaseActions.h:70
void PrintMe(FILE *fd, int nTabs) const
void PrintMe(FILE *fd, int nTabs) const
MHGenericInteger m_Argument5
Definition: BaseActions.h:114
MHActionInt(const char *name)
Definition: BaseActions.h:54
void Perform(MHEngine *engine) override
MHGenericInteger m_Argument2
Definition: BaseActions.h:114
virtual void Perform(MHEngine *engine)=0