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 }
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:152
MHActionIntInt::Perform
void Perform(MHEngine *engine) override
Definition: BaseActions.cpp:72
MHObjectRef::Initialise
void Initialise(MHParseNode *p, MHEngine *engine)
Definition: BaseClasses.cpp:278
MHActionObjectRef::Perform
void Perform(MHEngine *engine) override
Definition: BaseActions.cpp:173
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_Argument3
MHGenericInteger m_Argument3
Definition: BaseActions.h:101
MHActionInt3::m_Argument3
MHGenericInteger m_Argument3
Definition: BaseActions.h:88
MHEngine
Definition: Engine.h:72
MHActionInt6::m_Argument2
MHGenericInteger m_Argument2
Definition: BaseActions.h:114
MHActionInt6::Perform
void Perform(MHEngine *engine) override
Definition: BaseActions.cpp:153
MHActionInt::m_Argument
MHGenericInteger m_Argument
Definition: BaseActions.h:61
MHGenericInteger::Initialise
void Initialise(MHParseNode *p, MHEngine *engine)
Definition: BaseClasses.cpp:397
MHActionObjectRef::m_resultVar
MHObjectRef m_resultVar
Definition: BaseActions.h:129
MHActionInt6::m_Argument6
MHGenericInteger m_Argument6
Definition: BaseActions.h:114
MHActionInt4::m_Argument2
MHGenericInteger m_Argument2
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
MHActionBool::Initialise
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: BaseActions.cpp:184
MHActionIntInt::m_Argument2
MHGenericInteger m_Argument2
Definition: BaseActions.h:75
MHElemAction::Initialise
virtual void Initialise(MHParseNode *p, MHEngine *engine)
Definition: BaseActions.cpp:31
MHActionInt4::m_Argument4
MHGenericInteger m_Argument4
Definition: BaseActions.h:101
MHActionInt4::PrintArgs
void PrintArgs(FILE *fd, int nTabs) const override
Definition: BaseActions.cpp:119
MHGenericBoolean::Initialise
void Initialise(MHParseNode *p, MHEngine *engine)
Definition: BaseClasses.cpp:343
MHElemAction::m_ActionName
const char * m_ActionName
Definition: BaseActions.h:45
mythburn.FILE
int FILE
Definition: mythburn.py:139
MHActionInt4::Perform
void Perform(MHEngine *engine) override
Definition: BaseActions.cpp:127
MHGenericObjectRef::Initialise
void Initialise(MHParseNode *p, MHEngine *engine)
Definition: BaseClasses.cpp:539
MHActionInt3::m_Argument2
MHGenericInteger m_Argument2
Definition: BaseActions.h:88
MHActionInt6::PrintArgs
void PrintArgs(FILE *fd, int nTabs) const override
Definition: BaseActions.cpp:143
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
hardwareprofile.config.p
p
Definition: config.py:33
ParseNode.h
PrintTabs
void PrintTabs(FILE *fd, int n)
Definition: ParseNode.cpp:34
MHActionInt6::Initialise
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: BaseActions.cpp:132
MHEngine::FindObject
MHRoot * FindObject(const MHObjectRef &oRef, bool failOnNotFound=true)
Definition: Engine.cpp:574
MHActionInt6::m_Argument4
MHGenericInteger m_Argument4
Definition: BaseActions.h:114
MHActionBool::CallAction
virtual void CallAction(MHEngine *engine, MHRoot *pTarget, bool fArg)=0
Engine.h
MHElemAction::m_Target
MHGenericObjectRef m_Target
Definition: BaseActions.h:46
Ingredients.h
MHActionObjectRef::CallAction
virtual void CallAction(MHEngine *engine, MHRoot *pTarget, MHRoot *pArg)=0
MHElemAction::Target
MHRoot * Target(MHEngine *engine)
Definition: BaseActions.cpp:46
MHActionInt6::m_Argument5
MHGenericInteger m_Argument5
Definition: BaseActions.h:114
MHActionBool::m_Argument
MHGenericBoolean m_Argument
Definition: BaseActions.h:171
MHActionObjectRef::Initialise
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: BaseActions.cpp:77
MHActionInt3::m_Argument1
MHGenericInteger m_Argument1
Definition: BaseActions.h:88
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
MHActionInt6::m_Argument3
MHGenericInteger m_Argument3
Definition: BaseActions.h:114
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
MHParseNode
Definition: ParseNode.h:38
MHActionInt4::m_Argument1
MHGenericInteger m_Argument1
Definition: BaseActions.h:101
MHGenericInteger::GetValue
int GetValue(MHEngine *engine) const
Definition: BaseClasses.cpp:426
MHActionInt3::PrintArgs
void PrintArgs(FILE *fd, int nTabs) const override
Definition: BaseActions.cpp:98
MHGenericInteger::PrintMe
void PrintMe(FILE *fd, int nTabs) const
Definition: BaseClasses.cpp:412
MHGenericObjectRef::GetValue
void GetValue(MHObjectRef &ref, MHEngine *engine) const
Definition: BaseClasses.cpp:568
MHActionGenericObjectRef::m_RefObject
MHGenericObjectRef m_RefObject
Definition: BaseActions.h:156
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
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
BaseActions.h
MHActionInt6::m_Argument1
MHGenericInteger m_Argument1
Definition: BaseActions.h:114
MHActionIntInt::m_Argument1
MHGenericInteger m_Argument1
Definition: BaseActions.h:75
MHActionGenericObjectRef::Perform
void Perform(MHEngine *engine) override
Definition: BaseActions.cpp:166
MHRoot
Definition: Root.h:43
MHGenericBoolean::GetValue
bool GetValue(MHEngine *engine) const
Definition: BaseClasses.cpp:372