source: XIOS/dev/dev_olga/src/filter/ternary_arithmetic_filter.cpp @ 1162

Last change on this file since 1162 was 1162, checked in by oabramkina, 4 years ago

Two server levels: adding files missing in r1158.

File size: 5.5 KB
Line 
1#include "ternary_arithmetic_filter.hpp"
2
3namespace xios
4{
5  CScalarScalarFieldArithmeticFilter::CScalarScalarFieldArithmeticFilter(CGarbageCollector& gc, const std::string& op, double value1, double value2)
6    : CFilter(gc, 1, this)
7    , op(operatorExpr.getOpScalarScalarField(op))
8    , value1(value1)
9    , value2(value2)
10  { /* Nothing to do */ };
11
12  CDataPacketPtr CScalarScalarFieldArithmeticFilter::apply(std::vector<CDataPacketPtr> data)
13  {
14    CDataPacketPtr packet(new CDataPacket);
15    packet->date = data[0]->date;
16    packet->timestamp = data[0]->timestamp;
17    packet->status = data[0]->status;
18
19    if (packet->status == CDataPacket::NO_ERROR)
20      packet->data.reference(op(value1,value2, data[0]->data));
21
22    return packet;
23  }
24
25  CScalarFieldScalarArithmeticFilter::CScalarFieldScalarArithmeticFilter(CGarbageCollector& gc, const std::string& op, double value1, double value2)
26    : CFilter(gc, 1, this)
27    , op(operatorExpr.getOpScalarFieldScalar(op))
28    , value1(value1)
29    , value2(value2)
30  { /* Nothing to do */ };
31
32  CDataPacketPtr CScalarFieldScalarArithmeticFilter::apply(std::vector<CDataPacketPtr> data)
33  {
34    CDataPacketPtr packet(new CDataPacket);
35    packet->date = data[0]->date;
36    packet->timestamp = data[0]->timestamp;
37    packet->status = data[0]->status;
38
39    if (packet->status == CDataPacket::NO_ERROR)
40      packet->data.reference(op(value1, data[0]->data,value2));
41
42    return packet;
43  }
44
45  CScalarFieldFieldArithmeticFilter::CScalarFieldFieldArithmeticFilter(CGarbageCollector& gc, const std::string& op, double value)
46    : CFilter(gc, 2, this)
47    , op(operatorExpr.getOpScalarFieldField(op))
48    , value(value)
49  { /* Nothing to do */ };
50
51  CDataPacketPtr CScalarFieldFieldArithmeticFilter::apply(std::vector<CDataPacketPtr> data)
52  {
53    CDataPacketPtr packet(new CDataPacket);
54    packet->date = data[0]->date;
55    packet->timestamp = data[0]->timestamp;
56    packet->status = data[0]->status;
57
58    if (data[0]->status != CDataPacket::NO_ERROR)
59      packet->status = data[0]->status;
60    else if (data[1]->status != CDataPacket::NO_ERROR)
61      packet->status = data[1]->status;
62    else
63    { 
64      packet->status = CDataPacket::NO_ERROR;
65      packet->data.reference(op(value, data[0]->data, data[1]->data));
66    }
67    return packet;
68
69  }
70
71
72  CFieldScalarScalarArithmeticFilter::CFieldScalarScalarArithmeticFilter(CGarbageCollector& gc, const std::string& op, double value1, double value2)
73    : CFilter(gc, 1, this)
74    , op(operatorExpr.getOpFieldScalarScalar(op))
75    , value1(value1)
76    , value2(value2)
77  { /* Nothing to do */ };
78
79  CDataPacketPtr CFieldScalarScalarArithmeticFilter::apply(std::vector<CDataPacketPtr> data)
80  {
81    CDataPacketPtr packet(new CDataPacket);
82    packet->date = data[0]->date;
83    packet->timestamp = data[0]->timestamp;
84    packet->status = data[0]->status;
85
86    if (packet->status == CDataPacket::NO_ERROR)
87      packet->data.reference(op(data[0]->data, value1, value2));
88
89    return packet;
90  }
91
92
93  CFieldScalarFieldArithmeticFilter::CFieldScalarFieldArithmeticFilter(CGarbageCollector& gc, const std::string& op, double value)
94    : CFilter(gc, 2, this)
95    , op(operatorExpr.getOpFieldScalarField(op))
96    , value(value)
97  { /* Nothing to do */ };
98
99  CDataPacketPtr CFieldScalarFieldArithmeticFilter::apply(std::vector<CDataPacketPtr> data)
100  {
101    CDataPacketPtr packet(new CDataPacket);
102    packet->date = data[0]->date;
103    packet->timestamp = data[0]->timestamp;
104    packet->status = data[0]->status;
105
106    if (data[0]->status != CDataPacket::NO_ERROR)
107      packet->status = data[0]->status;
108    else if (data[1]->status != CDataPacket::NO_ERROR)
109      packet->status = data[1]->status;
110    else
111    { 
112      packet->status = CDataPacket::NO_ERROR;
113      packet->data.reference(op(data[0]->data, value, data[1]->data));
114    }
115    return packet;
116  }
117 
118   CFieldFieldScalarArithmeticFilter::CFieldFieldScalarArithmeticFilter(CGarbageCollector& gc, const std::string& op, double value)
119    : CFilter(gc, 2, this)
120    , op(operatorExpr.getOpFieldFieldScalar(op))
121    , value(value)
122  { /* Nothing to do */ };
123
124  CDataPacketPtr CFieldFieldScalarArithmeticFilter::apply(std::vector<CDataPacketPtr> data)
125  {
126    CDataPacketPtr packet(new CDataPacket);
127    packet->date = data[0]->date;
128    packet->timestamp = data[0]->timestamp;
129    packet->status = data[0]->status;
130
131    if (data[0]->status != CDataPacket::NO_ERROR)
132      packet->status = data[0]->status;
133    else if (data[1]->status != CDataPacket::NO_ERROR)
134      packet->status = data[1]->status;
135    else
136    { 
137      packet->status = CDataPacket::NO_ERROR;
138      packet->data.reference(op(data[0]->data, data[1]->data, value));
139    }
140    return packet;
141  } 
142 
143 
144  CFieldFieldFieldArithmeticFilter::CFieldFieldFieldArithmeticFilter(CGarbageCollector& gc, const std::string& op)
145    : CFilter(gc, 3, this)
146    , op(operatorExpr.getOpFieldFieldField(op))
147  { /* Nothing to do */ };
148
149  CDataPacketPtr CFieldFieldFieldArithmeticFilter::apply(std::vector<CDataPacketPtr> data)
150  {
151    CDataPacketPtr packet(new CDataPacket);
152    packet->date = data[0]->date;
153    packet->timestamp = data[0]->timestamp;
154    packet->status = data[0]->status;
155
156    if (data[0]->status != CDataPacket::NO_ERROR)
157      packet->status = data[0]->status;
158    else if (data[1]->status != CDataPacket::NO_ERROR)
159      packet->status = data[1]->status;
160    else if (data[2]->status != CDataPacket::NO_ERROR)
161      packet->status = data[2]->status;
162    else
163    { 
164      packet->status = CDataPacket::NO_ERROR;
165      packet->data.reference(op(data[0]->data, data[1]->data, data[2]->data));
166    }
167    return packet;
168  } 
169 
170} // namespace xios
171
Note: See TracBrowser for help on using the repository browser.