source: XIOS/dev/dev_ym/XIOS_COUPLING/src/filter/binary_arithmetic_filter.hpp @ 2230

Last change on this file since 2230 was 2193, checked in by yushan, 3 years ago

workflow graph : enable unary and binary arithmetic filters

File size: 3.8 KB
Line 
1#ifndef __XIOS_CBinaryArithmeticFilter__
2#define __XIOS_CBinaryArithmeticFilter__
3
4#include "filter.hpp"
5#include <string>
6#include "operator_expr.hpp"
7#include <unordered_map>
8
9namespace xios
10{
11  /*!
12   * A generic binary arithmetic filter wrapping any type of binary scalar-field operator.
13   */
14  class CScalarFieldArithmeticFilter : public CFilter, public IFilterEngine
15  {
16    public:
17      /*!
18       * Constructs an binary scalar-field arithmetic filter wrapping the specified operator.
19       *
20       * \param gc the associated garbage collector
21       * \param op the string identifing the binary scalar-field operator
22       * \param value the scalar value
23       */
24      CScalarFieldArithmeticFilter(CGarbageCollector& gc, const std::string& op, double value);
25
26    protected:
27      COperatorExpr::functionScalarField op; //!< The binary scalar-field operator attached to the binary arithmeric filter
28      double value; //!< The scalar value associated with the binary arithmeric filter
29
30      /*!
31       * Applies the binary scalar-field operator to the input data and returns the result.
32       *
33       * \param data a vector of packets corresponding to each slot (one in this case)
34       * \return the result of the binary operation
35       */
36      CDataPacketPtr virtual apply(std::vector<CDataPacketPtr> data);
37      std::pair<int, int> virtual buildGraph(std::vector<CDataPacketPtr> data);
38  }; // class CScalarFieldArithmeticFilter
39
40  /*!
41   * A generic binary arithmetic filter wrapping any type of binary scalar-field operator.
42   */
43  class CFieldScalarArithmeticFilter : public CFilter, public IFilterEngine
44  {
45    public:
46      /*!
47       * Constructs an binary field-scalar arithmetic filter wrapping the specified operator.
48       *
49       * \param gc the associated garbage collector
50       * \param op the string identifing the binary field-scalar operator
51       * \param value the scalar value
52       */
53      CFieldScalarArithmeticFilter(CGarbageCollector& gc, const std::string& op, double value);
54
55    protected:
56      COperatorExpr::functionFieldScalar op; //!< The binary field-scalar operator attached to the binary arithmeric filter
57      double value; //!< The scalar value associated with the binary arithmeric filter
58
59      /*!
60       * Applies the binary field-scalar operator to the input data and returns the result.
61       *
62       * \param data a vector of packets corresponding to each slot (one in this case)
63       * \return the result of the binary operation
64       */
65      CDataPacketPtr virtual apply(std::vector<CDataPacketPtr> data);
66      std::pair<int, int> virtual buildGraph(std::vector<CDataPacketPtr> data);
67  }; // class CFieldScalarArithmeticFilter
68
69  /*!
70   * A generic binary arithmetic filter wrapping any type of binary scalar-field operator.
71   */
72  class CFieldFieldArithmeticFilter : public CFilter, public IFilterEngine
73  {
74    public:
75      /*!
76       * Constructs an binary field-field arithmetic filter wrapping the specified operator.
77       *
78       * \param gc the associated garbage collector
79       * \param op the string identifing the binary field-field operator
80       */
81      CFieldFieldArithmeticFilter(CGarbageCollector& gc, const std::string& op);
82
83    protected:
84      COperatorExpr::functionFieldField op; //!< The binary field-field operator attached to the binary arithmeric filter
85
86      /*!
87       * Applies the binary field-field operator to the input data and returns the result.
88       *
89       * \param data a vector of packets corresponding to each slot (one in this case)
90       * \return the result of the binary operation
91       */
92      CDataPacketPtr virtual apply(std::vector<CDataPacketPtr> data);
93      std::pair<int, int> virtual buildGraph(std::vector<CDataPacketPtr> data);
94     
95  }; // class CFieldFieldArithmeticFilter
96} // namespace xios
97
98#endif //__XIOS_CBinaryArithmeticFilter__
Note: See TracBrowser for help on using the repository browser.