[642] | 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 unary operation on a field. |
---|
| 53 | */ |
---|
| 54 | class CFilterUnaryOpExprNode : public IFilterExprNode |
---|
| 55 | { |
---|
| 56 | public: |
---|
| 57 | /*! |
---|
| 58 | * Constructs an expression node corresponding to the specified unary operation |
---|
| 59 | * applied to the provided child node. |
---|
| 60 | * Note that the child node will be destroyed automatically when the parent node |
---|
| 61 | * is destroyed. |
---|
| 62 | * |
---|
| 63 | * \param opId the identifier of the operator |
---|
| 64 | * \param child the child node to which the operator is applied |
---|
| 65 | */ |
---|
| 66 | CFilterUnaryOpExprNode(const std::string& opId, IFilterExprNode* child); |
---|
| 67 | |
---|
| 68 | virtual boost::shared_ptr<COutputPin> reduce(CGarbageCollector& gc, CField& thisField) const; |
---|
| 69 | |
---|
| 70 | private: |
---|
| 71 | std::string opId; //!< The identifier of the field |
---|
| 72 | boost::scoped_ptr<IFilterExprNode> child; //!< The child node to which the operator is applied |
---|
| 73 | }; |
---|
| 74 | |
---|
| 75 | /*! |
---|
| 76 | * Expression node corresponding to a binary operation on a scalar and a field. |
---|
| 77 | */ |
---|
| 78 | class CFilterScalarFieldOpExprNode : public IFilterExprNode |
---|
| 79 | { |
---|
| 80 | public: |
---|
| 81 | /*! |
---|
| 82 | * Constructs an expression node corresponding to the specified binary operation |
---|
| 83 | * applied to the provided scalar and field child nodes. |
---|
| 84 | * Note that the child nodes will be destroyed automatically when the parent node |
---|
| 85 | * is destroyed. |
---|
| 86 | * |
---|
| 87 | * \param child1 the scalar child node to which the operator is applied |
---|
| 88 | * \param opId the identifier of the operator |
---|
| 89 | * \param child2 the field child node to which the operator is applied |
---|
| 90 | */ |
---|
| 91 | CFilterScalarFieldOpExprNode(IScalarExprNode* child1, const std::string& opId, IFilterExprNode* child2); |
---|
| 92 | |
---|
| 93 | virtual boost::shared_ptr<COutputPin> reduce(CGarbageCollector& gc, CField& thisField) const; |
---|
| 94 | |
---|
| 95 | private: |
---|
| 96 | std::string opId; //!< The identifier of the field |
---|
| 97 | boost::scoped_ptr<IScalarExprNode> child1; //!< The scalar child node to which the operator is applied |
---|
| 98 | boost::scoped_ptr<IFilterExprNode> child2; //!< The field child node to which the operator is applied |
---|
| 99 | }; |
---|
| 100 | |
---|
| 101 | /*! |
---|
| 102 | * Expression node corresponding to a binary operation on a field and a scalar. |
---|
| 103 | */ |
---|
| 104 | class CFilterFieldScalarOpExprNode : public IFilterExprNode |
---|
| 105 | { |
---|
| 106 | public: |
---|
| 107 | /*! |
---|
| 108 | * Constructs an expression node corresponding to the specified binary operation |
---|
| 109 | * applied to the provided field and scalar child nodes. |
---|
| 110 | * Note that the child nodes will be destroyed automatically when the parent node |
---|
| 111 | * is destroyed. |
---|
| 112 | * |
---|
| 113 | * \param child1 the field child node to which the operator is applied |
---|
| 114 | * \param opId the identifier of the operator |
---|
| 115 | * \param child2 the scalar child node to which the operator is applied |
---|
| 116 | */ |
---|
| 117 | CFilterFieldScalarOpExprNode(IFilterExprNode* child1, const std::string& opId, IScalarExprNode* child2); |
---|
| 118 | |
---|
| 119 | virtual boost::shared_ptr<COutputPin> reduce(CGarbageCollector& gc, CField& thisField) const; |
---|
| 120 | |
---|
| 121 | private: |
---|
| 122 | std::string opId; //!< The identifier of the field |
---|
| 123 | boost::scoped_ptr<IFilterExprNode> child1; //!< The field child node to which the operator is applied |
---|
| 124 | boost::scoped_ptr<IScalarExprNode> child2; //!< The scalar child node to which the operator is applied |
---|
| 125 | }; |
---|
| 126 | |
---|
| 127 | /*! |
---|
| 128 | * Expression node corresponding to a binary operation on two fields. |
---|
| 129 | */ |
---|
| 130 | class CFilterFieldFieldOpExprNode : public IFilterExprNode |
---|
| 131 | { |
---|
| 132 | public: |
---|
| 133 | /*! |
---|
| 134 | * Constructs an expression node corresponding to the specified binary operation |
---|
| 135 | * applied to the provided field child nodes. |
---|
| 136 | * Note that the child nodes will be destroyed automatically when the parent node |
---|
| 137 | * is destroyed. |
---|
| 138 | * |
---|
| 139 | * \param opId the identifier of the operator |
---|
| 140 | * \param child1, child2 the field child nodes to which the operator is applied |
---|
| 141 | */ |
---|
| 142 | CFilterFieldFieldOpExprNode(IFilterExprNode* child1, const std::string& opId, IFilterExprNode* child2); |
---|
| 143 | |
---|
| 144 | virtual boost::shared_ptr<COutputPin> reduce(CGarbageCollector& gc, CField& thisField) const; |
---|
| 145 | |
---|
| 146 | private: |
---|
| 147 | std::string opId; //!< The identifier of the field |
---|
| 148 | boost::scoped_ptr<IFilterExprNode> child1, child2; //!< The field child nodes to which the operator is applied |
---|
| 149 | }; |
---|
| 150 | } |
---|
| 151 | |
---|
| 152 | #endif // __XIOS_FILTER_EXPR_NODE_HPP__ |
---|