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:157
MHActionInt6::m_argument1
MHGenericInteger m_argument1
Definition: BaseActions.h:114
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_argument1
MHGenericInteger m_argument1
Definition: BaseActions.h:101
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
MHActionInt6::m_argument3
MHGenericInteger m_argument3
Definition: BaseActions.h:114
MHGenericInteger::Initialise
void Initialise(MHParseNode *p, MHEngine *engine)
Definition: BaseClasses.cpp:397
MHActionObjectRef::m_resultVar
MHObjectRef m_resultVar
Definition: BaseActions.h:129
MHActionInt3::m_argument2
MHGenericInteger m_argument2
Definition: BaseActions.h:88
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
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
MHGenericBoolean::Initialise
void Initialise(MHParseNode *p, MHEngine *engine)
Definition: BaseClasses.cpp:343
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
MHGenericObjectRef::Initialise
void Initialise(MHParseNode *p, MHEngine *engine)
Definition: BaseClasses.cpp:533
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
MHActionInt4::m_argument3
MHGenericInteger m_argument3
Definition: BaseActions.h:101
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:573
MHActionBool::CallAction
virtual void CallAction(MHEngine *engine, MHRoot *pTarget, bool fArg)=0
MHElemAction::m_actionName
const char * m_actionName
Definition: BaseActions.h:45
MHActionIntInt::m_argument1
MHGenericInteger m_argument1
Definition: BaseActions.h:75
Engine.h
Ingredients.h
MHActionObjectRef::CallAction
virtual void CallAction(MHEngine *engine, MHRoot *pTarget, MHRoot *pArg)=0
MHActionInt::m_argument
MHGenericInteger m_argument
Definition: BaseActions.h:61
MHElemAction::Target
MHRoot * Target(MHEngine *engine)
Definition: BaseActions.cpp:46
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
MHParseNode
Definition: ParseNode.h:39
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
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
MHGenericObjectRef::GetValue
void GetValue(MHObjectRef &ref, MHEngine *engine) const
Definition: BaseClasses.cpp:562
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:548
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
MHActionGenericObjectRef::Perform
void Perform(MHEngine *engine) override
Definition: BaseActions.cpp:166
MHActionInt6::m_argument5
MHGenericInteger m_argument5
Definition: BaseActions.h:114
MHRoot
Definition: Root.h:44
MHGenericBoolean::GetValue
bool GetValue(MHEngine *engine) const
Definition: BaseClasses.cpp:372
MHActionIntInt::m_argument2
MHGenericInteger m_argument2
Definition: BaseActions.h:75