1 | #ifndef __XIOS_FILTER_EXPR_NODE_HPP__ |
---|
2 | #define __XIOS_FILTER_EXPR_NODE_HPP__ |
---|
3 | |
---|
4 | #include <string> |
---|
5 | #include <boost/shared_ptr.hpp> |
---|
6 | #include <boost/smart_ptr/scoped_ptr.hpp> |
---|
7 | #include "scalar_expr_node.hpp" |
---|
8 | |
---|
9 | namespace xios |
---|
10 | { |
---|
11 | class COutputPin; |
---|
12 | class CGarbageCollector; |
---|
13 | class CField; |
---|
14 | |
---|
15 | /*! |
---|
16 | * Interface implemented by all the nodes of a tree representing an expression |
---|
17 | * which can be transformed into a filter graph representation. |
---|
18 | */ |
---|
19 | struct IFilterExprNode |
---|
20 | { |
---|
21 | /*! |
---|
22 | * Builds a filter graph corresponding to the expression tree. |
---|
23 | * |
---|
24 | * \param gc the garbage collector to associated with the filter graph |
---|
25 | * \param thisField the field to which the expression is attached |
---|
26 | * \return the output pin of the filter producing the result of the expression |
---|
27 | */ |
---|
28 | virtual boost::shared_ptr<COutputPin> reduce(CGarbageCollector& gc, CField& thisField) const = 0; |
---|
29 | }; |
---|
30 | |
---|
31 | /*! |
---|
32 | * Expression node corresponding to a field. |
---|
33 | */ |
---|
34 | class CFilterFieldExprNode : public IFilterExprNode |
---|
35 | { |
---|
36 | public: |
---|
37 | /*! |
---|
38 | * Constructs an expression node corresponding |
---|
39 | * to the field whose id is provided. |
---|
40 | * |
---|
41 | * \param fieldId the identifier of the field |
---|
42 | */ |
---|
43 | CFilterFieldExprNode(const std::string& fieldId); |
---|
44 | |
---|
45 | virtual boost::shared_ptr<COutputPin> reduce(CGarbageCollector& gc, CField& thisField) const; |
---|
46 | |
---|
47 | private: |
---|
48 | std::string fieldId; //!< The identifier of the field |
---|
49 | }; |
---|
50 | |
---|
51 | /*! |
---|
52 | * Expression node corresponding to a field for which the result of |
---|
53 | * the temporal operation is requested instead of the instant value. |
---|
54 | */ |
---|
55 | class CFilterTemporalFieldExprNode : public IFilterExprNode |
---|
56 | { |
---|
57 | public: |
---|
58 | /*! |
---|
59 | * Constructs an expression node corresponding |
---|
60 | * to the field whose id is provided. |
---|
61 | * |
---|
62 | * \param fieldId the identifier of the field |
---|
63 | */ |
---|
64 | CFilterTemporalFieldExprNode(const std::string& fieldId); |
---|
65 | |
---|
66 | virtual boost::shared_ptr<COutputPin> reduce(CGarbageCollector& gc, CField& thisField) const; |
---|
67 | |
---|
68 | private: |
---|
69 | std::string fieldId; //!< The identifier of the field |
---|
70 | }; |
---|
71 | |
---|
72 | /*! |
---|
73 | * Expression node corresponding to a unary operation on a field. |
---|
74 | */ |
---|
75 | class CFilterUnaryOpExprNode : public IFilterExprNode |
---|
76 | { |
---|
77 | public: |
---|
78 | /*! |
---|
79 | * Constructs an expression node corresponding to the specified unary operation |
---|
80 | * applied to the provided child node. |
---|
81 | * Note that the child node will be destroyed automatically when the parent node |
---|
82 | * is destroyed. |
---|
83 | * |
---|
84 | * \param opId the identifier of the operator |
---|
85 | * \param child the child node to which the operator is applied |
---|
86 | */ |
---|
87 | CFilterUnaryOpExprNode(const std::string& opId, IFilterExprNode* child); |
---|
88 | |
---|
89 | virtual boost::shared_ptr<COutputPin> reduce(CGarbageCollector& gc, CField& thisField) const; |
---|
90 | |
---|
91 | private: |
---|
92 | std::string opId; //!< The identifier of the field |
---|
93 | boost::scoped_ptr<IFilterExprNode> child; //!< The child node to which the operator is applied |
---|
94 | }; |
---|
95 | |
---|
96 | /*! |
---|
97 | * Expression node corresponding to a binary operation on a scalar and a field. |
---|
98 | */ |
---|
99 | class CFilterScalarFieldOpExprNode : public IFilterExprNode |
---|
100 | { |
---|
101 | public: |
---|
102 | /*! |
---|
103 | * Constructs an expression node corresponding to the specified binary operation |
---|
104 | * applied to the provided scalar and field child nodes. |
---|
105 | * Note that the child nodes will be destroyed automatically when the parent node |
---|
106 | * is destroyed. |
---|
107 | * |
---|
108 | * \param child1 the scalar child node to which the operator is applied |
---|
109 | * \param opId the identifier of the operator |
---|
110 | * \param child2 the field child node to which the operator is applied |
---|
111 | */ |
---|
112 | CFilterScalarFieldOpExprNode(IScalarExprNode* child1, const std::string& opId, IFilterExprNode* child2); |
---|
113 | |
---|
114 | virtual boost::shared_ptr<COutputPin> reduce(CGarbageCollector& gc, CField& thisField) const; |
---|
115 | |
---|
116 | private: |
---|
117 | std::string opId; //!< The identifier of the field |
---|
118 | boost::scoped_ptr<IScalarExprNode> child1; //!< The scalar child node to which the operator is applied |
---|
119 | boost::scoped_ptr<IFilterExprNode> child2; //!< The field child node to which the operator is applied |
---|
120 | }; |
---|
121 | |
---|
122 | /*! |
---|
123 | * Expression node corresponding to a binary operation on a field and a scalar. |
---|
124 | */ |
---|
125 | class CFilterFieldScalarOpExprNode : public IFilterExprNode |
---|
126 | { |
---|
127 | public: |
---|
128 | /*! |
---|
129 | * Constructs an expression node corresponding to the specified binary operation |
---|
130 | * applied to the provided field and scalar child nodes. |
---|
131 | * Note that the child nodes will be destroyed automatically when the parent node |
---|
132 | * is destroyed. |
---|
133 | * |
---|
134 | * \param child1 the field child node to which the operator is applied |
---|
135 | * \param opId the identifier of the operator |
---|
136 | * \param child2 the scalar child node to which the operator is applied |
---|
137 | */ |
---|
138 | CFilterFieldScalarOpExprNode(IFilterExprNode* child1, const std::string& opId, IScalarExprNode* child2); |
---|
139 | |
---|
140 | virtual boost::shared_ptr<COutputPin> reduce(CGarbageCollector& gc, CField& thisField) const; |
---|
141 | |
---|
142 | private: |
---|
143 | std::string opId; //!< The identifier of the field |
---|
144 | boost::scoped_ptr<IFilterExprNode> child1; //!< The field child node to which the operator is applied |
---|
145 | boost::scoped_ptr<IScalarExprNode> child2; //!< The scalar child node to which the operator is applied |
---|
146 | }; |
---|
147 | |
---|
148 | /*! |
---|
149 | * Expression node corresponding to a binary operation on two fields. |
---|
150 | */ |
---|
151 | class CFilterFieldFieldOpExprNode : public IFilterExprNode |
---|
152 | { |
---|
153 | public: |
---|
154 | /*! |
---|
155 | * Constructs an expression node corresponding to the specified binary operation |
---|
156 | * applied to the provided field child nodes. |
---|
157 | * Note that the child nodes will be destroyed automatically when the parent node |
---|
158 | * is destroyed. |
---|
159 | * |
---|
160 | * \param opId the identifier of the operator |
---|
161 | * \param child1, child2 the field child nodes to which the operator is applied |
---|
162 | */ |
---|
163 | CFilterFieldFieldOpExprNode(IFilterExprNode* child1, const std::string& opId, IFilterExprNode* child2); |
---|
164 | |
---|
165 | virtual boost::shared_ptr<COutputPin> reduce(CGarbageCollector& gc, CField& thisField) const; |
---|
166 | |
---|
167 | private: |
---|
168 | std::string opId; //!< The identifier of the field |
---|
169 | boost::scoped_ptr<IFilterExprNode> child1, child2; //!< The field child nodes to which the operator is applied |
---|
170 | }; |
---|
171 | } |
---|
172 | |
---|
173 | #endif // __XIOS_FILTER_EXPR_NODE_HPP__ |
---|