1 | #ifndef __XIOS_FILTER_EXPR_NODE_HPP__ |
---|
2 | #define __XIOS_FILTER_EXPR_NODE_HPP__ |
---|
3 | |
---|
4 | #include <string> |
---|
5 | #include <boost/smart_ptr/scoped_ptr.hpp> |
---|
6 | #include "scalar_expr_node.hpp" |
---|
7 | |
---|
8 | #include "duration.hpp" |
---|
9 | |
---|
10 | namespace xios |
---|
11 | { |
---|
12 | class COutputPin; |
---|
13 | class CGarbageCollector; |
---|
14 | class CField; |
---|
15 | |
---|
16 | /*! |
---|
17 | * Interface implemented by all the nodes of a tree representing an expression |
---|
18 | * which can be transformed into a filter graph representation. |
---|
19 | */ |
---|
20 | struct IFilterExprNode |
---|
21 | { |
---|
22 | /*! |
---|
23 | * Builds a filter graph corresponding to the expression tree. |
---|
24 | * |
---|
25 | * \param gc the garbage collector to associated with the filter graph |
---|
26 | * \param thisField the field to which the expression is attached |
---|
27 | * \return the output pin of the filter producing the result of the expression |
---|
28 | */ |
---|
29 | virtual std::shared_ptr<COutputPin> reduce(CGarbageCollector& gc, CField& thisField, Time start_graph=-1, Time end_graph=-1) const = 0; |
---|
30 | }; |
---|
31 | |
---|
32 | /*! |
---|
33 | * Expression node corresponding to a field. |
---|
34 | */ |
---|
35 | class CFilterFieldExprNode : public IFilterExprNode |
---|
36 | { |
---|
37 | public: |
---|
38 | /*! |
---|
39 | * Constructs an expression node corresponding |
---|
40 | * to the field whose id is provided. |
---|
41 | * |
---|
42 | * \param fieldId the identifier of the field |
---|
43 | */ |
---|
44 | CFilterFieldExprNode(const std::string& fieldId); |
---|
45 | |
---|
46 | virtual std::shared_ptr<COutputPin> reduce(CGarbageCollector& gc, CField& thisField, Time start_graph=-1, Time end_graph=-1) const; |
---|
47 | |
---|
48 | private: |
---|
49 | std::string fieldId; //!< The identifier of the field |
---|
50 | }; |
---|
51 | |
---|
52 | /*! |
---|
53 | * Expression node corresponding to a field for which the result of |
---|
54 | * the temporal operation is requested instead of the instant value. |
---|
55 | */ |
---|
56 | class CFilterTemporalFieldExprNode : public IFilterExprNode |
---|
57 | { |
---|
58 | public: |
---|
59 | /*! |
---|
60 | * Constructs an expression node corresponding |
---|
61 | * to the field whose id is provided. |
---|
62 | * |
---|
63 | * \param fieldId the identifier of the field |
---|
64 | */ |
---|
65 | CFilterTemporalFieldExprNode(const std::string& fieldId); |
---|
66 | |
---|
67 | virtual std::shared_ptr<COutputPin> reduce(CGarbageCollector& gc, CField& thisField, Time start_graph=-1, Time end_graph=-1) const; |
---|
68 | |
---|
69 | private: |
---|
70 | std::string fieldId; //!< The identifier of the field |
---|
71 | }; |
---|
72 | |
---|
73 | /*! |
---|
74 | * Expression node corresponding to a unary operation on a field. |
---|
75 | */ |
---|
76 | class CFilterUnaryOpExprNode : public IFilterExprNode |
---|
77 | { |
---|
78 | public: |
---|
79 | /*! |
---|
80 | * Constructs an expression node corresponding to the specified unary operation |
---|
81 | * applied to the provided child node. |
---|
82 | * Note that the child node will be destroyed automatically when the parent node |
---|
83 | * is destroyed. |
---|
84 | * |
---|
85 | * \param opId the identifier of the operator |
---|
86 | * \param child the child node to which the operator is applied |
---|
87 | */ |
---|
88 | CFilterUnaryOpExprNode(const std::string& opId, IFilterExprNode* child); |
---|
89 | |
---|
90 | virtual std::shared_ptr<COutputPin> reduce(CGarbageCollector& gc, CField& thisField, Time start_graph=-1, Time end_graph=-1) const; |
---|
91 | |
---|
92 | private: |
---|
93 | std::string opId; //!< The identifier of the field |
---|
94 | boost::scoped_ptr<IFilterExprNode> child; //!< The child node to which the operator is applied |
---|
95 | }; |
---|
96 | |
---|
97 | /*! |
---|
98 | * Expression node corresponding to a binary operation on a scalar and a field. |
---|
99 | */ |
---|
100 | class CFilterScalarFieldOpExprNode : public IFilterExprNode |
---|
101 | { |
---|
102 | public: |
---|
103 | /*! |
---|
104 | * Constructs an expression node corresponding to the specified binary operation |
---|
105 | * applied to the provided scalar and field child nodes. |
---|
106 | * Note that the child nodes will be destroyed automatically when the parent node |
---|
107 | * is destroyed. |
---|
108 | * |
---|
109 | * \param child1 the scalar child node to which the operator is applied |
---|
110 | * \param opId the identifier of the operator |
---|
111 | * \param child2 the field child node to which the operator is applied |
---|
112 | */ |
---|
113 | CFilterScalarFieldOpExprNode(IScalarExprNode* child1, const std::string& opId, IFilterExprNode* child2); |
---|
114 | |
---|
115 | virtual std::shared_ptr<COutputPin> reduce(CGarbageCollector& gc, CField& thisField, Time start_graph=-1, Time end_graph=-1) const; |
---|
116 | |
---|
117 | private: |
---|
118 | std::string opId; //!< The identifier of the field |
---|
119 | boost::scoped_ptr<IScalarExprNode> child1; //!< The scalar child node to which the operator is applied |
---|
120 | boost::scoped_ptr<IFilterExprNode> child2; //!< The field child node to which the operator is applied |
---|
121 | }; |
---|
122 | |
---|
123 | /*! |
---|
124 | * Expression node corresponding to a binary operation on a field and a scalar. |
---|
125 | */ |
---|
126 | class CFilterFieldScalarOpExprNode : public IFilterExprNode |
---|
127 | { |
---|
128 | public: |
---|
129 | /*! |
---|
130 | * Constructs an expression node corresponding to the specified binary operation |
---|
131 | * applied to the provided field and scalar child nodes. |
---|
132 | * Note that the child nodes will be destroyed automatically when the parent node |
---|
133 | * is destroyed. |
---|
134 | * |
---|
135 | * \param child1 the field child node to which the operator is applied |
---|
136 | * \param opId the identifier of the operator |
---|
137 | * \param child2 the scalar child node to which the operator is applied |
---|
138 | */ |
---|
139 | CFilterFieldScalarOpExprNode(IFilterExprNode* child1, const std::string& opId, IScalarExprNode* child2); |
---|
140 | |
---|
141 | virtual std::shared_ptr<COutputPin> reduce(CGarbageCollector& gc, CField& thisField, Time start_graph=-1, Time end_graph=-1) const; |
---|
142 | |
---|
143 | private: |
---|
144 | std::string opId; //!< The identifier of the field |
---|
145 | boost::scoped_ptr<IFilterExprNode> child1; //!< The field child node to which the operator is applied |
---|
146 | boost::scoped_ptr<IScalarExprNode> child2; //!< The scalar child node to which the operator is applied |
---|
147 | }; |
---|
148 | |
---|
149 | /*! |
---|
150 | * Expression node corresponding to a binary operation on two fields. |
---|
151 | */ |
---|
152 | class CFilterFieldFieldOpExprNode : public IFilterExprNode |
---|
153 | { |
---|
154 | public: |
---|
155 | /*! |
---|
156 | * Constructs an expression node corresponding to the specified binary operation |
---|
157 | * applied to the provided field child nodes. |
---|
158 | * Note that the child nodes will be destroyed automatically when the parent node |
---|
159 | * is destroyed. |
---|
160 | * |
---|
161 | * \param opId the identifier of the operator |
---|
162 | * \param child1, child2 the field child nodes to which the operator is applied |
---|
163 | */ |
---|
164 | CFilterFieldFieldOpExprNode(IFilterExprNode* child1, const std::string& opId, IFilterExprNode* child2); |
---|
165 | |
---|
166 | virtual std::shared_ptr<COutputPin> reduce(CGarbageCollector& gc, CField& thisField, Time start_graph=-1, Time end_graph=-1) const; |
---|
167 | |
---|
168 | private: |
---|
169 | std::string opId; //!< The identifier of the field |
---|
170 | boost::scoped_ptr<IFilterExprNode> child1, child2; //!< The field child nodes to which the operator is applied |
---|
171 | }; |
---|
172 | |
---|
173 | |
---|
174 | |
---|
175 | /*! |
---|
176 | * Expression node corresponding to a ternary operation on a scalar-scalar-field. |
---|
177 | */ |
---|
178 | class CFilterScalarScalarFieldOpExprNode : public IFilterExprNode |
---|
179 | { |
---|
180 | public: |
---|
181 | /*! |
---|
182 | * Constructs an expression node corresponding to the specified ternary operation |
---|
183 | * applied to the provided fields and scalars child nodes. |
---|
184 | * Note that the child nodes will be destroyed automatically when the parent node |
---|
185 | * is destroyed. |
---|
186 | * |
---|
187 | * \param child1 the scalar child node to which the operator is applied |
---|
188 | * \param opId the identifier of the operator |
---|
189 | * \param child2 the scalar child node to which the operator is applied |
---|
190 | * \param child3 the field child node to which the operator is applied |
---|
191 | */ |
---|
192 | CFilterScalarScalarFieldOpExprNode(IScalarExprNode* child1, const std::string& opId, IScalarExprNode* child2, IFilterExprNode* child3); |
---|
193 | |
---|
194 | virtual std::shared_ptr<COutputPin> reduce(CGarbageCollector& gc, CField& thisField, Time start_graph=-1, Time end_graph=-1) const; |
---|
195 | |
---|
196 | private: |
---|
197 | std::string opId; //!< The identifier of the field |
---|
198 | boost::scoped_ptr<IScalarExprNode> child1; //!< The scalar child node to which the operator is applied |
---|
199 | boost::scoped_ptr<IScalarExprNode> child2; //!< The scalar child node to which the operator is applied |
---|
200 | boost::scoped_ptr<IFilterExprNode> child3; //!< The field child node to which the operator is applied |
---|
201 | }; |
---|
202 | |
---|
203 | |
---|
204 | /*! |
---|
205 | * Expression node corresponding to a ternary operation on a scalar-field-scalar. |
---|
206 | */ |
---|
207 | class CFilterScalarFieldScalarOpExprNode : public IFilterExprNode |
---|
208 | { |
---|
209 | public: |
---|
210 | /*! |
---|
211 | * Constructs an expression node corresponding to the specified ternary operation |
---|
212 | * applied to the provided fields and scalars child nodes. |
---|
213 | * Note that the child nodes will be destroyed automatically when the parent node |
---|
214 | * is destroyed. |
---|
215 | * |
---|
216 | * \param child1 the scalar child node to which the operator is applied |
---|
217 | * \param opId the identifier of the operator |
---|
218 | * \param child2 the field child node to which the operator is applied |
---|
219 | * \param child3 the scalar child node to which the operator is applied |
---|
220 | */ |
---|
221 | CFilterScalarFieldScalarOpExprNode(IScalarExprNode* child1, const std::string& opId, IFilterExprNode* child2, IScalarExprNode* child3); |
---|
222 | |
---|
223 | virtual std::shared_ptr<COutputPin> reduce(CGarbageCollector& gc, CField& thisField, Time start_graph=-1, Time end_graph=-1) const; |
---|
224 | |
---|
225 | private: |
---|
226 | std::string opId; //!< The identifier of the field |
---|
227 | boost::scoped_ptr<IScalarExprNode> child1; //!< The scalar child node to which the operator is applied |
---|
228 | boost::scoped_ptr<IFilterExprNode> child2; //!< The field child node to which the operator is applied |
---|
229 | boost::scoped_ptr<IScalarExprNode> child3; //!< The scalar child node to which the operator is applied |
---|
230 | }; |
---|
231 | |
---|
232 | |
---|
233 | /*! |
---|
234 | * Expression node corresponding to a ternary operation on a scalar-field-field. |
---|
235 | */ |
---|
236 | class CFilterScalarFieldFieldOpExprNode : public IFilterExprNode |
---|
237 | { |
---|
238 | public: |
---|
239 | /*! |
---|
240 | * Constructs an expression node corresponding to the specified ternary operation |
---|
241 | * applied to the provided fields and scalars child nodes. |
---|
242 | * Note that the child nodes will be destroyed automatically when the parent node |
---|
243 | * is destroyed. |
---|
244 | * |
---|
245 | * \param child1 the scalar child node to which the operator is applied |
---|
246 | * \param opId the identifier of the operator |
---|
247 | * \param child2 the field child node to which the operator is applied |
---|
248 | * \param child3 the field child node to which the operator is applied |
---|
249 | */ |
---|
250 | CFilterScalarFieldFieldOpExprNode(IScalarExprNode* child1, const std::string& opId, IFilterExprNode* child2, IFilterExprNode* child3); |
---|
251 | |
---|
252 | virtual std::shared_ptr<COutputPin> reduce(CGarbageCollector& gc, CField& thisField, Time start_graph=-1, Time end_graph=-1) const; |
---|
253 | |
---|
254 | private: |
---|
255 | std::string opId; //!< The identifier of the field |
---|
256 | boost::scoped_ptr<IScalarExprNode> child1; //!< The scalar child node to which the operator is applied |
---|
257 | boost::scoped_ptr<IFilterExprNode> child2; //!< The field child node to which the operator is applied |
---|
258 | boost::scoped_ptr<IFilterExprNode> child3; //!< The field child node to which the operator is applied |
---|
259 | }; |
---|
260 | |
---|
261 | |
---|
262 | |
---|
263 | /*! |
---|
264 | * Expression node corresponding to a ternary operation on a field-scalar-scalar. |
---|
265 | */ |
---|
266 | class CFilterFieldScalarScalarOpExprNode : public IFilterExprNode |
---|
267 | { |
---|
268 | public: |
---|
269 | /*! |
---|
270 | * Constructs an expression node corresponding to the specified ternary operation |
---|
271 | * applied to the provided fields and scalars child nodes. |
---|
272 | * Note that the child nodes will be destroyed automatically when the parent node |
---|
273 | * is destroyed. |
---|
274 | * |
---|
275 | * \param child1 the field child node to which the operator is applied |
---|
276 | * \param opId the identifier of the operator |
---|
277 | * \param child2 the scalar child node to which the operator is applied |
---|
278 | * \param child3 the scalar child node to which the operator is applied |
---|
279 | */ |
---|
280 | CFilterFieldScalarScalarOpExprNode(IFilterExprNode* child1, const std::string& opId, IScalarExprNode* child2, IScalarExprNode* child3); |
---|
281 | |
---|
282 | virtual std::shared_ptr<COutputPin> reduce(CGarbageCollector& gc, CField& thisField, Time start_graph=-1, Time end_graph=-1) const; |
---|
283 | |
---|
284 | private: |
---|
285 | std::string opId; //!< The identifier of the field |
---|
286 | boost::scoped_ptr<IFilterExprNode> child1; //!< The field child node to which the operator is applied |
---|
287 | boost::scoped_ptr<IScalarExprNode> child2; //!< The scalar child node to which the operator is applied |
---|
288 | boost::scoped_ptr<IScalarExprNode> child3; //!< The scalar child node to which the operator is applied |
---|
289 | }; |
---|
290 | |
---|
291 | |
---|
292 | /*! |
---|
293 | * Expression node corresponding to a ternary operation on a field-scalar-field. |
---|
294 | */ |
---|
295 | class CFilterFieldScalarFieldOpExprNode : public IFilterExprNode |
---|
296 | { |
---|
297 | public: |
---|
298 | /*! |
---|
299 | * Constructs an expression node corresponding to the specified ternary operation |
---|
300 | * applied to the provided fields and scalars child nodes. |
---|
301 | * Note that the child nodes will be destroyed automatically when the parent node |
---|
302 | * is destroyed. |
---|
303 | * |
---|
304 | * \param child1 the field child node to which the operator is applied |
---|
305 | * \param opId the identifier of the operator |
---|
306 | * \param child2 the scalar child node to which the operator is applied |
---|
307 | * \param child3 the field child node to which the operator is applied |
---|
308 | */ |
---|
309 | CFilterFieldScalarFieldOpExprNode(IFilterExprNode* child1, const std::string& opId, IScalarExprNode* child2, IFilterExprNode* child3); |
---|
310 | |
---|
311 | virtual std::shared_ptr<COutputPin> reduce(CGarbageCollector& gc, CField& thisField, Time start_graph=-1, Time end_graph=-1) const; |
---|
312 | |
---|
313 | private: |
---|
314 | std::string opId; //!< The identifier of the field |
---|
315 | boost::scoped_ptr<IFilterExprNode> child1; //!< The field child node to which the operator is applied |
---|
316 | boost::scoped_ptr<IScalarExprNode> child2; //!< The scalar child node to which the operator is applied |
---|
317 | boost::scoped_ptr<IFilterExprNode> child3; //!< The field child node to which the operator is applied |
---|
318 | }; |
---|
319 | |
---|
320 | /*! |
---|
321 | * Expression node corresponding to a ternary operation on a field-field-scalar. |
---|
322 | */ |
---|
323 | class CFilterFieldFieldScalarOpExprNode : public IFilterExprNode |
---|
324 | { |
---|
325 | public: |
---|
326 | /*! |
---|
327 | * Constructs an expression node corresponding to the specified ternary operation |
---|
328 | * applied to the provided fields and scalars child nodes. |
---|
329 | * Note that the child nodes will be destroyed automatically when the parent node |
---|
330 | * is destroyed. |
---|
331 | * |
---|
332 | * \param child1 the field child node to which the operator is applied |
---|
333 | * \param opId the identifier of the operator |
---|
334 | * \param child2 the field child node to which the operator is applied |
---|
335 | * \param child3 the scalar child node to which the operator is applied |
---|
336 | */ |
---|
337 | CFilterFieldFieldScalarOpExprNode(IFilterExprNode* child1, const std::string& opId, IFilterExprNode* child2, IScalarExprNode* child3); |
---|
338 | |
---|
339 | virtual std::shared_ptr<COutputPin> reduce(CGarbageCollector& gc, CField& thisField, Time start_graph=-1, Time end_graph=-1) const; |
---|
340 | |
---|
341 | private: |
---|
342 | std::string opId; //!< The identifier of the field |
---|
343 | boost::scoped_ptr<IFilterExprNode> child1; //!< The field child node to which the operator is applied |
---|
344 | boost::scoped_ptr<IFilterExprNode> child2; //!< The field child node to which the operator is applied |
---|
345 | boost::scoped_ptr<IScalarExprNode> child3; //!< The scalar child node to which the operator is applied |
---|
346 | }; |
---|
347 | |
---|
348 | |
---|
349 | /*! |
---|
350 | * Expression node corresponding to a ternary operation on a field-field-field. |
---|
351 | */ |
---|
352 | class CFilterFieldFieldFieldOpExprNode : public IFilterExprNode |
---|
353 | { |
---|
354 | public: |
---|
355 | /*! |
---|
356 | * Constructs an expression node corresponding to the specified ternary operation |
---|
357 | * applied to the provided fields and scalars child nodes. |
---|
358 | * Note that the child nodes will be destroyed automatically when the parent node |
---|
359 | * is destroyed. |
---|
360 | * |
---|
361 | * \param child1 the field child node to which the operator is applied |
---|
362 | * \param opId the identifier of the operator |
---|
363 | * \param child2 the field child node to which the operator is applied |
---|
364 | * \param child3 the field child node to which the operator is applied |
---|
365 | */ |
---|
366 | CFilterFieldFieldFieldOpExprNode(IFilterExprNode* child1, const std::string& opId, IFilterExprNode* child2, IFilterExprNode* child3); |
---|
367 | |
---|
368 | virtual std::shared_ptr<COutputPin> reduce(CGarbageCollector& gc, CField& thisField, Time start_graph=-1, Time end_graph=-1) const; |
---|
369 | |
---|
370 | private: |
---|
371 | std::string opId; //!< The identifier of the field |
---|
372 | boost::scoped_ptr<IFilterExprNode> child1; //!< The field child node to which the operator is applied |
---|
373 | boost::scoped_ptr<IFilterExprNode> child2; //!< The field child node to which the operator is applied |
---|
374 | boost::scoped_ptr<IFilterExprNode> child3; //!< The field child node to which the operator is applied |
---|
375 | }; |
---|
376 | |
---|
377 | |
---|
378 | |
---|
379 | } |
---|
380 | |
---|
381 | #endif // __XIOS_FILTER_EXPR_NODE_HPP__ |
---|