MythTV  master
BaseActions.cpp
Go to the documentation of this file.
1 /* BaseActions.cpp
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 #include <cstdio>
23 
24 #include "BaseActions.h"
25 #include "BaseClasses.h"
26 #include "ParseNode.h"
27 #include "Ingredients.h"
28 #include "Engine.h"
29 
30 
32 {
33  m_Target.Initialise(p->GetArgN(0), engine);
34 }
35 
36 // Print the action name and the target.
37 void MHElemAction::PrintMe(FILE *fd, int nTabs) const
38 {
39  PrintTabs(fd, nTabs);
40  fprintf(fd, "%s (", m_ActionName);
41  m_Target.PrintMe(fd, nTabs + 1);
42  PrintArgs(fd, nTabs + 1); // Any other arguments must be handled by the subclass.
43  fprintf(fd, ")\n");
44 }
45 
47 {
48  MHObjectRef target;
49  m_Target.GetValue(target, engine);
50  return engine->FindObject(target);
51 }
52 
54 {
55  MHElemAction::Initialise(p, engine);
56  m_Argument.Initialise(p->GetArgN(1), engine);
57 }
58 
59 
61 {
62  CallAction(engine, Target(engine), m_Argument.GetValue(engine));
63 }
64 
66 {
67  MHElemAction::Initialise(p, engine);
68  m_Argument1.Initialise(p->GetArgN(1), engine);
69  m_Argument2.Initialise(p->GetArgN(2), engine);
70 }
71 
73 {
74  CallAction(engine, Target(engine), m_Argument1.GetValue(engine), m_Argument2.GetValue(engine));
75 }
76 
78 {
79  MHElemAction::Initialise(p, engine);
80  m_ResultVar.Initialise(p->GetArgN(1), engine);
81 }
82 
84 {
85  MHElemAction::Initialise(p, engine);
86  m_ResultVar1.Initialise(p->GetArgN(1), engine);
87  m_ResultVar2.Initialise(p->GetArgN(2), engine);
88 }
89 
91 {
92  MHElemAction::Initialise(p, engine);
93  m_Argument1.Initialise(p->GetArgN(1), engine);
94  m_Argument2.Initialise(p->GetArgN(2), engine);
95  m_Argument3.Initialise(p->GetArgN(3), engine);
96 }
97 
98 void MHActionInt3::PrintArgs(FILE *fd, int /*nTabs*/) const
99 {
100  m_Argument1.PrintMe(fd, 0);
101  m_Argument2.PrintMe(fd, 0);
102  m_Argument3.PrintMe(fd, 0);
103 }
104 
106 {
107  CallAction(engine, Target(engine), m_Argument1.GetValue(engine), m_Argument2.GetValue(engine), m_Argument3.GetValue(engine));
108 }
109 
111 {
112  MHElemAction::Initialise(p, engine);
113  m_Argument1.Initialise(p->GetArgN(1), engine);
114  m_Argument2.Initialise(p->GetArgN(2), engine);
115  m_Argument3.Initialise(p->GetArgN(3), engine);
116  m_Argument4.Initialise(p->GetArgN(4), engine);
117 }
118 
119 void MHActionInt4::PrintArgs(FILE *fd, int /*nTabs*/) const
120 {
121  m_Argument1.PrintMe(fd, 0);
122  m_Argument2.PrintMe(fd, 0);
123  m_Argument3.PrintMe(fd, 0);
124  m_Argument4.PrintMe(fd, 0);
125 }
126 
128 {
129  CallAction(engine, Target(engine), m_Argument1.GetValue(engine), m_Argument2.GetValue(engine), m_Argument3.GetValue(engine), m_Argument4.GetValue(engine));
130 }
131 
133 {
134  MHElemAction::Initialise(p, engine);
135  m_Argument1.Initialise(p->GetArgN(1), engine);
136  m_Argument2.Initialise(p->GetArgN(2), engine);
137  m_Argument3.Initialise(p->GetArgN(3), engine);
138  m_Argument4.Initialise(p->GetArgN(4), engine);
139  m_Argument5.Initialise(p->GetArgN(5), engine);
140  m_Argument6.Initialise(p->GetArgN(6), engine);
141 }
142 
143 void MHActionInt6::PrintArgs(FILE *fd, int /*nTabs*/) const
144 {
145  m_Argument1.PrintMe(fd, 0);
146  m_Argument2.PrintMe(fd, 0);
147  m_Argument3.PrintMe(fd, 0);
148  m_Argument4.PrintMe(fd, 0);
149  m_Argument5.PrintMe(fd, 0);
150  m_Argument6.PrintMe(fd, 0);
151 }
152 
154 {
155  CallAction(engine, Target(engine), m_Argument1.GetValue(engine), m_Argument2.GetValue(engine), m_Argument3.GetValue(engine),
156  m_Argument4.GetValue(engine), m_Argument5.GetValue(engine), m_Argument6.GetValue(engine));
157 }
158 
159 
161 {
162  MHElemAction::Initialise(p, engine); // Target
163  m_RefObject.Initialise(p->GetArgN(1), engine);
164 }
165 
167 {
168  MHObjectRef reference;
169  m_RefObject.GetValue(reference, engine);
170  CallAction(engine, Target(engine), engine->FindObject(reference));
171 }
172 
174 {
175  CallAction(engine, Target(engine), engine->FindObject(m_ResultVar));
176 }
177 
178 
180 {
181  CallAction(engine, Target(engine), engine->FindObject(m_ResultVar1), engine->FindObject(m_ResultVar2));
182 }
183 
185 {
186  MHElemAction::Initialise(p, engine);
187  m_Argument.Initialise(p->GetArgN(1), engine);
188 }
189 
190 
192 {
193  CallAction(engine, Target(engine), m_Argument.GetValue(engine));
194 }
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)
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: BaseActions.cpp:53
bool GetValue(MHEngine *engine) const
void Perform(MHEngine *engine) override
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
void Initialise(MHParseNode *p, MHEngine *engine)
MHGenericInteger m_Argument4
Definition: BaseActions.h:114
void Initialise(MHParseNode *p, MHEngine *engine) override
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
int GetValue(MHEngine *engine) const
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: BaseActions.cpp:83
void Initialise(MHParseNode *p, MHEngine *engine)
MHGenericInteger m_Argument1
Definition: BaseActions.h:75
void Perform(MHEngine *engine) override
MHGenericObjectRef m_RefObject
Definition: BaseActions.h:156
void Perform(MHEngine *engine) override
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
void GetValue(MHObjectRef &ref, MHEngine *engine) const
void PrintTabs(FILE *fd, int n)
Definition: ParseNode.cpp:34
void Initialise(MHParseNode *p, MHEngine *engine) override
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
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
MHGenericInteger m_Argument1
Definition: BaseActions.h:114
MHRoot * FindObject(const MHObjectRef &oRef, bool failOnNotFound=true)
Definition: Engine.cpp:574
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 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
virtual void CallAction(MHEngine *engine, MHRoot *pTarget, MHRoot *pArg)=0
const char * m_ActionName
Definition: BaseActions.h:45
void Initialise(MHParseNode *p, MHEngine *engine)
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
void Perform(MHEngine *engine) override
MHGenericInteger m_Argument1
Definition: BaseActions.h:101
void PrintMe(FILE *fd, int nTabs) const
void PrintMe(FILE *fd, int nTabs) const
MHGenericInteger m_Argument5
Definition: BaseActions.h:114
void Perform(MHEngine *engine) override
MHGenericInteger m_Argument2
Definition: BaseActions.h:114