1 | #include "filter_expr_node.hpp" |
---|
2 | #include "unary_arithmetic_filter.hpp" |
---|
3 | #include "binary_arithmetic_filter.hpp" |
---|
4 | #include "ternary_arithmetic_filter.hpp" |
---|
5 | #include "field.hpp" |
---|
6 | |
---|
7 | namespace xios |
---|
8 | { |
---|
9 | CFilterFieldExprNode::CFilterFieldExprNode(const std::string& fieldId) |
---|
10 | : fieldId(fieldId) |
---|
11 | { /* Nothing to do */ } |
---|
12 | |
---|
13 | boost::shared_ptr<COutputPin> CFilterFieldExprNode::reduce(CGarbageCollector& gc, CField& thisField) const |
---|
14 | { |
---|
15 | boost::shared_ptr<COutputPin> outputPin; |
---|
16 | |
---|
17 | if (fieldId == "this") |
---|
18 | outputPin = thisField.getSelfReference(gc); |
---|
19 | else if (CField::has(fieldId)) |
---|
20 | { |
---|
21 | CField* field = CField::get(fieldId); |
---|
22 | if (field == &thisField) |
---|
23 | ERROR("boost::shared_ptr<COutputPin> CFilterFieldExprNode::reduce(CGarbageCollector& gc, CField& thisField) const", |
---|
24 | << "The field " << fieldId << " has an invalid reference to itself. " |
---|
25 | << "Use the keyword \"this\" if you want to reference the input data sent to this field."); |
---|
26 | |
---|
27 | field->buildFilterGraph(gc, false); |
---|
28 | outputPin = field->getInstantDataFilter(); |
---|
29 | } |
---|
30 | else |
---|
31 | ERROR("boost::shared_ptr<COutputPin> CFilterFieldExprNode::reduce(CGarbageCollector& gc, CField& thisField) const", |
---|
32 | << "The field " << fieldId << " does not exist."); |
---|
33 | |
---|
34 | return outputPin; |
---|
35 | } |
---|
36 | |
---|
37 | CFilterTemporalFieldExprNode::CFilterTemporalFieldExprNode(const std::string& fieldId) |
---|
38 | : fieldId(fieldId) |
---|
39 | { /* Nothing to do */ } |
---|
40 | |
---|
41 | boost::shared_ptr<COutputPin> CFilterTemporalFieldExprNode::reduce(CGarbageCollector& gc, CField& thisField) const |
---|
42 | { |
---|
43 | boost::shared_ptr<COutputPin> outputPin; |
---|
44 | |
---|
45 | if (fieldId == "this") |
---|
46 | outputPin = thisField.getSelfTemporalDataFilter(gc, thisField.freq_op.isEmpty() ? TimeStep : thisField.freq_op); |
---|
47 | else if (CField::has(fieldId)) |
---|
48 | { |
---|
49 | CField* field = CField::get(fieldId); |
---|
50 | if (field == &thisField) |
---|
51 | ERROR("boost::shared_ptr<COutputPin> CFilterTemporalFieldExprNode::reduce(CGarbageCollector& gc, CField& thisField) const", |
---|
52 | << "The field " << fieldId << " has an invalid reference to itself. " |
---|
53 | << "Use the keyword \"this\" if you want to reference the input data sent to this field."); |
---|
54 | |
---|
55 | field->buildFilterGraph(gc, false); |
---|
56 | outputPin = field->getTemporalDataFilter(gc, thisField.freq_op.isEmpty() ? TimeStep : thisField.freq_op); |
---|
57 | } |
---|
58 | else |
---|
59 | ERROR("boost::shared_ptr<COutputPin> CFilterTemporalFieldExprNode::reduce(CGarbageCollector& gc, CField& thisField) const", |
---|
60 | << "The field " << fieldId << " does not exist."); |
---|
61 | |
---|
62 | return outputPin; |
---|
63 | } |
---|
64 | |
---|
65 | CFilterUnaryOpExprNode::CFilterUnaryOpExprNode(const std::string& opId, IFilterExprNode* child) |
---|
66 | : opId(opId) |
---|
67 | , child(child) |
---|
68 | { |
---|
69 | if (!child) |
---|
70 | ERROR("CFilterUnaryOpExprNode::CFilterUnaryOpExprNode(const std::string& opId, IFilterExprNode* child)", |
---|
71 | "Impossible to create the new expression node, an invalid child node was provided."); |
---|
72 | } |
---|
73 | |
---|
74 | boost::shared_ptr<COutputPin> CFilterUnaryOpExprNode::reduce(CGarbageCollector& gc, CField& thisField) const |
---|
75 | { |
---|
76 | boost::shared_ptr<CUnaryArithmeticFilter> filter(new CUnaryArithmeticFilter(gc, opId)); |
---|
77 | child->reduce(gc, thisField)->connectOutput(filter, 0); |
---|
78 | return filter; |
---|
79 | } |
---|
80 | |
---|
81 | CFilterScalarFieldOpExprNode::CFilterScalarFieldOpExprNode(IScalarExprNode* child1, const std::string& opId, IFilterExprNode* child2) |
---|
82 | : child1(child1) |
---|
83 | , opId(opId) |
---|
84 | , child2(child2) |
---|
85 | { |
---|
86 | if (!child1 || !child2) |
---|
87 | ERROR("CFilterScalarFieldOpExprNode::CFilterScalarFieldOpExprNode(IScalarExprNode* child1, const std::string& opId, IFilterExprNode* child2)", |
---|
88 | "Impossible to create the new expression node, an invalid child node was provided."); |
---|
89 | } |
---|
90 | |
---|
91 | boost::shared_ptr<COutputPin> CFilterScalarFieldOpExprNode::reduce(CGarbageCollector& gc, CField& thisField) const |
---|
92 | { |
---|
93 | boost::shared_ptr<CScalarFieldArithmeticFilter> filter(new CScalarFieldArithmeticFilter(gc, opId, child1->reduce())); |
---|
94 | child2->reduce(gc, thisField)->connectOutput(filter, 0); |
---|
95 | return filter; |
---|
96 | } |
---|
97 | |
---|
98 | CFilterFieldScalarOpExprNode::CFilterFieldScalarOpExprNode(IFilterExprNode* child1, const std::string& opId, IScalarExprNode* child2) |
---|
99 | : child1(child1) |
---|
100 | , opId(opId) |
---|
101 | , child2(child2) |
---|
102 | { |
---|
103 | if (!child1 || !child2) |
---|
104 | ERROR("CFilterFieldScalarOpExprNode::CFilterFieldScalarOpExprNode(IFilterExprNode* child1, const std::string& opId, IScalarExprNode* child2)", |
---|
105 | "Impossible to create the new expression node, an invalid child node was provided."); |
---|
106 | } |
---|
107 | |
---|
108 | boost::shared_ptr<COutputPin> CFilterFieldScalarOpExprNode::reduce(CGarbageCollector& gc, CField& thisField) const |
---|
109 | { |
---|
110 | boost::shared_ptr<CFieldScalarArithmeticFilter> filter(new CFieldScalarArithmeticFilter(gc, opId, child2->reduce())); |
---|
111 | child1->reduce(gc, thisField)->connectOutput(filter, 0); |
---|
112 | return filter; |
---|
113 | } |
---|
114 | |
---|
115 | CFilterFieldFieldOpExprNode::CFilterFieldFieldOpExprNode(IFilterExprNode* child1, const std::string& opId, IFilterExprNode* child2) |
---|
116 | : child1(child1) |
---|
117 | , opId(opId) |
---|
118 | , child2(child2) |
---|
119 | { |
---|
120 | if (!child1 || !child2) |
---|
121 | ERROR("CFilterFieldFieldOpExprNode::CFilterFieldFieldOpExprNode(IFilterExprNode* child1, const std::string& opId, IFilterExprNode* child2)", |
---|
122 | "Impossible to create the new expression node, an invalid child node was provided."); |
---|
123 | } |
---|
124 | |
---|
125 | boost::shared_ptr<COutputPin> CFilterFieldFieldOpExprNode::reduce(CGarbageCollector& gc, CField& thisField) const |
---|
126 | { |
---|
127 | boost::shared_ptr<CFieldFieldArithmeticFilter> filter(new CFieldFieldArithmeticFilter(gc, opId)); |
---|
128 | child1->reduce(gc, thisField)->connectOutput(filter, 0); |
---|
129 | child2->reduce(gc, thisField)->connectOutput(filter, 1); |
---|
130 | return filter; |
---|
131 | } |
---|
132 | |
---|
133 | |
---|
134 | |
---|
135 | |
---|
136 | CFilterScalarScalarFieldOpExprNode::CFilterScalarScalarFieldOpExprNode(IScalarExprNode* child1, const std::string& opId, IScalarExprNode* child2, IFilterExprNode* child3) |
---|
137 | : child1(child1) |
---|
138 | , opId(opId) |
---|
139 | , child2(child2) |
---|
140 | , child3(child3) |
---|
141 | { |
---|
142 | if (!child1 || !child2 || !child3) |
---|
143 | ERROR(" CFilterScalarScalarFieldOpExprNode::CFilterScalarScalarFieldOpExprNode(IScalarExprNode* child1, const std::string& opId, IScalarExprNode* child2, IFilterExprNode* child3)", |
---|
144 | "Impossible to create the new expression node, an invalid child node was provided."); |
---|
145 | } |
---|
146 | |
---|
147 | boost::shared_ptr<COutputPin> CFilterScalarScalarFieldOpExprNode::reduce(CGarbageCollector& gc, CField& thisField) const |
---|
148 | { |
---|
149 | boost::shared_ptr<CScalarScalarFieldArithmeticFilter> filter(new CScalarScalarFieldArithmeticFilter(gc, opId, child1->reduce(),child2->reduce())); |
---|
150 | child3->reduce(gc, thisField)->connectOutput(filter, 0); |
---|
151 | return filter; |
---|
152 | } |
---|
153 | |
---|
154 | |
---|
155 | CFilterScalarFieldScalarOpExprNode::CFilterScalarFieldScalarOpExprNode(IScalarExprNode* child1, const std::string& opId, IFilterExprNode* child2, IScalarExprNode* child3) |
---|
156 | : child1(child1) |
---|
157 | , opId(opId) |
---|
158 | , child2(child2) |
---|
159 | , child3(child3) |
---|
160 | { |
---|
161 | if (!child1 || !child2 || !child3) |
---|
162 | ERROR(" CFilterScalarFieldScalarOpExprNode::CFilterScalarFieldScalarOpExprNode(IScalarExprNode* child1, const std::string& opId, IFilterExprNode* child2, IScalarExprNode* child3)", |
---|
163 | "Impossible to create the new expression node, an invalid child node was provided."); |
---|
164 | } |
---|
165 | |
---|
166 | boost::shared_ptr<COutputPin> CFilterScalarFieldScalarOpExprNode::reduce(CGarbageCollector& gc, CField& thisField) const |
---|
167 | { |
---|
168 | boost::shared_ptr<CScalarFieldScalarArithmeticFilter> filter(new CScalarFieldScalarArithmeticFilter(gc, opId, child1->reduce(),child3->reduce())); |
---|
169 | child2->reduce(gc, thisField)->connectOutput(filter, 0); |
---|
170 | return filter; |
---|
171 | } |
---|
172 | |
---|
173 | |
---|
174 | CFilterScalarFieldFieldOpExprNode::CFilterScalarFieldFieldOpExprNode(IScalarExprNode* child1, const std::string& opId, IFilterExprNode* child2, IFilterExprNode* child3) |
---|
175 | : child1(child1) |
---|
176 | , opId(opId) |
---|
177 | , child2(child2) |
---|
178 | , child3(child3) |
---|
179 | { |
---|
180 | if (!child1 || !child2 || !child3) |
---|
181 | ERROR(" CFilterScalarFieldFieldOpExprNode::CFilterScalarFieldFieldOpExprNode(IScalarExprNode* child1, const std::string& opId, IFilterExprNode* child2, IFilterExprNode* child3)", |
---|
182 | "Impossible to create the new expression node, an invalid child node was provided."); |
---|
183 | } |
---|
184 | |
---|
185 | boost::shared_ptr<COutputPin> CFilterScalarFieldFieldOpExprNode::reduce(CGarbageCollector& gc, CField& thisField) const |
---|
186 | { |
---|
187 | boost::shared_ptr<CScalarFieldFieldArithmeticFilter> filter(new CScalarFieldFieldArithmeticFilter(gc, opId, child1->reduce())); |
---|
188 | child2->reduce(gc, thisField)->connectOutput(filter, 0); |
---|
189 | child3->reduce(gc, thisField)->connectOutput(filter, 1); |
---|
190 | return filter; |
---|
191 | } |
---|
192 | |
---|
193 | |
---|
194 | |
---|
195 | CFilterFieldScalarScalarOpExprNode::CFilterFieldScalarScalarOpExprNode(IFilterExprNode* child1, const std::string& opId, IScalarExprNode* child2, IScalarExprNode* child3) |
---|
196 | : child1(child1) |
---|
197 | , opId(opId) |
---|
198 | , child2(child2) |
---|
199 | , child3(child3) |
---|
200 | { |
---|
201 | if (!child1 || !child2 || !child3) |
---|
202 | ERROR(" CFilterFieldScalarScalarOpExprNode::CFilterFieldScalarScalarOpExprNode(IFilterExprNode* child1, const std::string& opId, IScalarExprNode* child2, IScalarExprNode* child3)", |
---|
203 | "Impossible to create the new expression node, an invalid child node was provided."); |
---|
204 | } |
---|
205 | |
---|
206 | boost::shared_ptr<COutputPin> CFilterFieldScalarScalarOpExprNode::reduce(CGarbageCollector& gc, CField& thisField) const |
---|
207 | { |
---|
208 | boost::shared_ptr<CFieldScalarScalarArithmeticFilter> filter(new CFieldScalarScalarArithmeticFilter(gc, opId, child2->reduce(),child3->reduce())); |
---|
209 | child1->reduce(gc, thisField)->connectOutput(filter, 0); |
---|
210 | return filter; |
---|
211 | } |
---|
212 | |
---|
213 | |
---|
214 | |
---|
215 | CFilterFieldScalarFieldOpExprNode::CFilterFieldScalarFieldOpExprNode(IFilterExprNode* child1, const std::string& opId, IScalarExprNode* child2, IFilterExprNode* child3) |
---|
216 | : child1(child1) |
---|
217 | , opId(opId) |
---|
218 | , child2(child2) |
---|
219 | , child3(child3) |
---|
220 | { |
---|
221 | if (!child1 || !child2 || !child3) |
---|
222 | ERROR(" CFilterFieldScalarFieldOpExprNode::CFilterFieldScalarFieldOpExprNode(IFilterExprNode* child1, const std::string& opId, IScalarExprNode* child2, IFilterExprNode* child3)", |
---|
223 | "Impossible to create the new expression node, an invalid child node was provided."); |
---|
224 | } |
---|
225 | |
---|
226 | boost::shared_ptr<COutputPin> CFilterFieldScalarFieldOpExprNode::reduce(CGarbageCollector& gc, CField& thisField) const |
---|
227 | { |
---|
228 | boost::shared_ptr<CFieldScalarFieldArithmeticFilter> filter(new CFieldScalarFieldArithmeticFilter(gc, opId, child2->reduce())); |
---|
229 | child1->reduce(gc, thisField)->connectOutput(filter, 0); |
---|
230 | child3->reduce(gc, thisField)->connectOutput(filter, 1); |
---|
231 | return filter; |
---|
232 | } |
---|
233 | |
---|
234 | |
---|
235 | |
---|
236 | CFilterFieldFieldScalarOpExprNode::CFilterFieldFieldScalarOpExprNode(IFilterExprNode* child1, const std::string& opId, IFilterExprNode* child2, IScalarExprNode* child3) |
---|
237 | : child1(child1) |
---|
238 | , opId(opId) |
---|
239 | , child2(child2) |
---|
240 | , child3(child3) |
---|
241 | { |
---|
242 | if (!child1 || !child2 || !child3) |
---|
243 | ERROR(" CFilterFieldFieldScalarOpExprNode::CFilterFieldFieldScalarOpExprNode(IFilterExprNode* child1, const std::string& opId, IFilterExprNode* child2, IScalarExprNode* child3)", |
---|
244 | "Impossible to create the new expression node, an invalid child node was provided."); |
---|
245 | } |
---|
246 | |
---|
247 | boost::shared_ptr<COutputPin> CFilterFieldFieldScalarOpExprNode::reduce(CGarbageCollector& gc, CField& thisField) const |
---|
248 | { |
---|
249 | boost::shared_ptr<CFieldFieldScalarArithmeticFilter> filter(new CFieldFieldScalarArithmeticFilter(gc, opId, child3->reduce())); |
---|
250 | child1->reduce(gc, thisField)->connectOutput(filter, 0); |
---|
251 | child2->reduce(gc, thisField)->connectOutput(filter, 1); |
---|
252 | return filter; |
---|
253 | } |
---|
254 | |
---|
255 | |
---|
256 | CFilterFieldFieldFieldOpExprNode::CFilterFieldFieldFieldOpExprNode(IFilterExprNode* child1, const std::string& opId, IFilterExprNode* child2, IFilterExprNode* child3) |
---|
257 | : child1(child1) |
---|
258 | , opId(opId) |
---|
259 | , child2(child2) |
---|
260 | , child3(child3) |
---|
261 | { |
---|
262 | if (!child1 || !child2 || !child3) |
---|
263 | ERROR(" CFilterFieldFieldFieldOpExprNode::CFilterFieldFieldFieldOpExprNode(IFilterExprNode* child1, const std::string& opId, IFilterExprNode* child2, IFilterExprNode* child3)", |
---|
264 | "Impossible to create the new expression node, an invalid child node was provided."); |
---|
265 | } |
---|
266 | |
---|
267 | boost::shared_ptr<COutputPin> CFilterFieldFieldFieldOpExprNode::reduce(CGarbageCollector& gc, CField& thisField) const |
---|
268 | { |
---|
269 | boost::shared_ptr<CFieldFieldFieldArithmeticFilter> filter(new CFieldFieldFieldArithmeticFilter(gc, opId)); |
---|
270 | child1->reduce(gc, thisField)->connectOutput(filter, 0); |
---|
271 | child2->reduce(gc, thisField)->connectOutput(filter, 1); |
---|
272 | child3->reduce(gc, thisField)->connectOutput(filter, 2); |
---|
273 | return filter; |
---|
274 | } |
---|
275 | |
---|
276 | } |
---|