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