[642] | 1 | #include "filter_expr_node.hpp" |
---|
| 2 | #include "unary_arithmetic_filter.hpp" |
---|
| 3 | #include "binary_arithmetic_filter.hpp" |
---|
[1158] | 4 | #include "ternary_arithmetic_filter.hpp" |
---|
[642] | 5 | #include "field.hpp" |
---|
| 6 | |
---|
| 7 | namespace xios |
---|
| 8 | { |
---|
| 9 | CFilterFieldExprNode::CFilterFieldExprNode(const std::string& fieldId) |
---|
| 10 | : fieldId(fieldId) |
---|
| 11 | { /* Nothing to do */ } |
---|
| 12 | |
---|
[1542] | 13 | std::shared_ptr<COutputPin> CFilterFieldExprNode::reduce(CGarbageCollector& gc, CField& thisField) const |
---|
[642] | 14 | { |
---|
[1542] | 15 | std::shared_ptr<COutputPin> outputPin; |
---|
[642] | 16 | |
---|
| 17 | if (fieldId == "this") |
---|
| 18 | outputPin = thisField.getSelfReference(gc); |
---|
| 19 | else if (CField::has(fieldId)) |
---|
| 20 | { |
---|
| 21 | CField* field = CField::get(fieldId); |
---|
| 22 | if (field == &thisField) |
---|
[1542] | 23 | ERROR("std::shared_ptr<COutputPin> CFilterFieldExprNode::reduce(CGarbageCollector& gc, CField& thisField) const", |
---|
[642] | 24 | << "The field " << fieldId << " has an invalid reference to itself. " |
---|
| 25 | << "Use the keyword \"this\" if you want to reference the input data sent to this field."); |
---|
| 26 | |
---|
| 27 | field->buildFilterGraph(gc, false); |
---|
| 28 | outputPin = field->getInstantDataFilter(); |
---|
| 29 | } |
---|
| 30 | else |
---|
[1542] | 31 | ERROR("std::shared_ptr<COutputPin> CFilterFieldExprNode::reduce(CGarbageCollector& gc, CField& thisField) const", |
---|
[642] | 32 | << "The field " << fieldId << " does not exist."); |
---|
| 33 | |
---|
| 34 | return outputPin; |
---|
| 35 | } |
---|
| 36 | |
---|
[643] | 37 | CFilterTemporalFieldExprNode::CFilterTemporalFieldExprNode(const std::string& fieldId) |
---|
| 38 | : fieldId(fieldId) |
---|
| 39 | { /* Nothing to do */ } |
---|
| 40 | |
---|
[1542] | 41 | std::shared_ptr<COutputPin> CFilterTemporalFieldExprNode::reduce(CGarbageCollector& gc, CField& thisField) const |
---|
[643] | 42 | { |
---|
[1542] | 43 | std::shared_ptr<COutputPin> outputPin; |
---|
[1158] | 44 | |
---|
| 45 | if (fieldId == "this") |
---|
| 46 | outputPin = thisField.getSelfTemporalDataFilter(gc, thisField.freq_op.isEmpty() ? TimeStep : thisField.freq_op); |
---|
| 47 | else if (CField::has(fieldId)) |
---|
| 48 | { |
---|
| 49 | CField* field = CField::get(fieldId); |
---|
| 50 | if (field == &thisField) |
---|
[1542] | 51 | ERROR("std::shared_ptr<COutputPin> CFilterTemporalFieldExprNode::reduce(CGarbageCollector& gc, CField& thisField) const", |
---|
[1158] | 52 | << "The field " << fieldId << " has an invalid reference to itself. " |
---|
| 53 | << "Use the keyword \"this\" if you want to reference the input data sent to this field."); |
---|
| 54 | |
---|
| 55 | field->buildFilterGraph(gc, false); |
---|
| 56 | outputPin = field->getTemporalDataFilter(gc, thisField.freq_op.isEmpty() ? TimeStep : thisField.freq_op); |
---|
| 57 | } |
---|
| 58 | else |
---|
[1542] | 59 | ERROR("std::shared_ptr<COutputPin> CFilterTemporalFieldExprNode::reduce(CGarbageCollector& gc, CField& thisField) const", |
---|
[643] | 60 | << "The field " << fieldId << " does not exist."); |
---|
| 61 | |
---|
[1158] | 62 | return outputPin; |
---|
[643] | 63 | } |
---|
| 64 | |
---|
[642] | 65 | CFilterUnaryOpExprNode::CFilterUnaryOpExprNode(const std::string& opId, IFilterExprNode* child) |
---|
| 66 | : opId(opId) |
---|
| 67 | , child(child) |
---|
| 68 | { |
---|
| 69 | if (!child) |
---|
| 70 | ERROR("CFilterUnaryOpExprNode::CFilterUnaryOpExprNode(const std::string& opId, IFilterExprNode* child)", |
---|
| 71 | "Impossible to create the new expression node, an invalid child node was provided."); |
---|
| 72 | } |
---|
| 73 | |
---|
[1542] | 74 | std::shared_ptr<COutputPin> CFilterUnaryOpExprNode::reduce(CGarbageCollector& gc, CField& thisField) const |
---|
[642] | 75 | { |
---|
[1542] | 76 | std::shared_ptr<CUnaryArithmeticFilter> filter(new CUnaryArithmeticFilter(gc, opId)); |
---|
[642] | 77 | child->reduce(gc, thisField)->connectOutput(filter, 0); |
---|
| 78 | return filter; |
---|
| 79 | } |
---|
| 80 | |
---|
| 81 | CFilterScalarFieldOpExprNode::CFilterScalarFieldOpExprNode(IScalarExprNode* child1, const std::string& opId, IFilterExprNode* child2) |
---|
| 82 | : child1(child1) |
---|
| 83 | , opId(opId) |
---|
| 84 | , child2(child2) |
---|
| 85 | { |
---|
| 86 | if (!child1 || !child2) |
---|
| 87 | ERROR("CFilterScalarFieldOpExprNode::CFilterScalarFieldOpExprNode(IScalarExprNode* child1, const std::string& opId, IFilterExprNode* child2)", |
---|
| 88 | "Impossible to create the new expression node, an invalid child node was provided."); |
---|
| 89 | } |
---|
| 90 | |
---|
[1542] | 91 | std::shared_ptr<COutputPin> CFilterScalarFieldOpExprNode::reduce(CGarbageCollector& gc, CField& thisField) const |
---|
[642] | 92 | { |
---|
[1542] | 93 | std::shared_ptr<CScalarFieldArithmeticFilter> filter(new CScalarFieldArithmeticFilter(gc, opId, child1->reduce())); |
---|
[642] | 94 | child2->reduce(gc, thisField)->connectOutput(filter, 0); |
---|
| 95 | return filter; |
---|
| 96 | } |
---|
| 97 | |
---|
| 98 | CFilterFieldScalarOpExprNode::CFilterFieldScalarOpExprNode(IFilterExprNode* child1, const std::string& opId, IScalarExprNode* child2) |
---|
| 99 | : child1(child1) |
---|
| 100 | , opId(opId) |
---|
| 101 | , child2(child2) |
---|
| 102 | { |
---|
| 103 | if (!child1 || !child2) |
---|
| 104 | ERROR("CFilterFieldScalarOpExprNode::CFilterFieldScalarOpExprNode(IFilterExprNode* child1, const std::string& opId, IScalarExprNode* child2)", |
---|
| 105 | "Impossible to create the new expression node, an invalid child node was provided."); |
---|
| 106 | } |
---|
| 107 | |
---|
[1542] | 108 | std::shared_ptr<COutputPin> CFilterFieldScalarOpExprNode::reduce(CGarbageCollector& gc, CField& thisField) const |
---|
[642] | 109 | { |
---|
[1542] | 110 | std::shared_ptr<CFieldScalarArithmeticFilter> filter(new CFieldScalarArithmeticFilter(gc, opId, child2->reduce())); |
---|
[642] | 111 | child1->reduce(gc, thisField)->connectOutput(filter, 0); |
---|
| 112 | return filter; |
---|
| 113 | } |
---|
| 114 | |
---|
| 115 | CFilterFieldFieldOpExprNode::CFilterFieldFieldOpExprNode(IFilterExprNode* child1, const std::string& opId, IFilterExprNode* child2) |
---|
| 116 | : child1(child1) |
---|
| 117 | , opId(opId) |
---|
| 118 | , child2(child2) |
---|
| 119 | { |
---|
| 120 | if (!child1 || !child2) |
---|
| 121 | ERROR("CFilterFieldFieldOpExprNode::CFilterFieldFieldOpExprNode(IFilterExprNode* child1, const std::string& opId, IFilterExprNode* child2)", |
---|
| 122 | "Impossible to create the new expression node, an invalid child node was provided."); |
---|
| 123 | } |
---|
| 124 | |
---|
[1542] | 125 | std::shared_ptr<COutputPin> CFilterFieldFieldOpExprNode::reduce(CGarbageCollector& gc, CField& thisField) const |
---|
[642] | 126 | { |
---|
[1542] | 127 | std::shared_ptr<CFieldFieldArithmeticFilter> filter(new CFieldFieldArithmeticFilter(gc, opId)); |
---|
[642] | 128 | child1->reduce(gc, thisField)->connectOutput(filter, 0); |
---|
| 129 | child2->reduce(gc, thisField)->connectOutput(filter, 1); |
---|
| 130 | return filter; |
---|
| 131 | } |
---|
[1158] | 132 | |
---|
| 133 | |
---|
| 134 | |
---|
| 135 | |
---|
| 136 | CFilterScalarScalarFieldOpExprNode::CFilterScalarScalarFieldOpExprNode(IScalarExprNode* child1, const std::string& opId, IScalarExprNode* child2, IFilterExprNode* child3) |
---|
| 137 | : child1(child1) |
---|
| 138 | , opId(opId) |
---|
| 139 | , child2(child2) |
---|
| 140 | , child3(child3) |
---|
| 141 | { |
---|
| 142 | if (!child1 || !child2 || !child3) |
---|
| 143 | ERROR(" CFilterScalarScalarFieldOpExprNode::CFilterScalarScalarFieldOpExprNode(IScalarExprNode* child1, const std::string& opId, IScalarExprNode* child2, IFilterExprNode* child3)", |
---|
| 144 | "Impossible to create the new expression node, an invalid child node was provided."); |
---|
| 145 | } |
---|
| 146 | |
---|
[1542] | 147 | std::shared_ptr<COutputPin> CFilterScalarScalarFieldOpExprNode::reduce(CGarbageCollector& gc, CField& thisField) const |
---|
[1158] | 148 | { |
---|
[1542] | 149 | std::shared_ptr<CScalarScalarFieldArithmeticFilter> filter(new CScalarScalarFieldArithmeticFilter(gc, opId, child1->reduce(),child2->reduce())); |
---|
[1158] | 150 | child3->reduce(gc, thisField)->connectOutput(filter, 0); |
---|
| 151 | return filter; |
---|
| 152 | } |
---|
| 153 | |
---|
| 154 | |
---|
| 155 | CFilterScalarFieldScalarOpExprNode::CFilterScalarFieldScalarOpExprNode(IScalarExprNode* child1, const std::string& opId, IFilterExprNode* child2, IScalarExprNode* child3) |
---|
| 156 | : child1(child1) |
---|
| 157 | , opId(opId) |
---|
| 158 | , child2(child2) |
---|
| 159 | , child3(child3) |
---|
| 160 | { |
---|
| 161 | if (!child1 || !child2 || !child3) |
---|
| 162 | ERROR(" CFilterScalarFieldScalarOpExprNode::CFilterScalarFieldScalarOpExprNode(IScalarExprNode* child1, const std::string& opId, IFilterExprNode* child2, IScalarExprNode* child3)", |
---|
| 163 | "Impossible to create the new expression node, an invalid child node was provided."); |
---|
| 164 | } |
---|
| 165 | |
---|
[1542] | 166 | std::shared_ptr<COutputPin> CFilterScalarFieldScalarOpExprNode::reduce(CGarbageCollector& gc, CField& thisField) const |
---|
[1158] | 167 | { |
---|
[1542] | 168 | std::shared_ptr<CScalarFieldScalarArithmeticFilter> filter(new CScalarFieldScalarArithmeticFilter(gc, opId, child1->reduce(),child3->reduce())); |
---|
[1158] | 169 | child2->reduce(gc, thisField)->connectOutput(filter, 0); |
---|
| 170 | return filter; |
---|
| 171 | } |
---|
| 172 | |
---|
| 173 | |
---|
| 174 | CFilterScalarFieldFieldOpExprNode::CFilterScalarFieldFieldOpExprNode(IScalarExprNode* child1, const std::string& opId, IFilterExprNode* child2, IFilterExprNode* child3) |
---|
| 175 | : child1(child1) |
---|
| 176 | , opId(opId) |
---|
| 177 | , child2(child2) |
---|
| 178 | , child3(child3) |
---|
| 179 | { |
---|
| 180 | if (!child1 || !child2 || !child3) |
---|
| 181 | ERROR(" CFilterScalarFieldFieldOpExprNode::CFilterScalarFieldFieldOpExprNode(IScalarExprNode* child1, const std::string& opId, IFilterExprNode* child2, IFilterExprNode* child3)", |
---|
| 182 | "Impossible to create the new expression node, an invalid child node was provided."); |
---|
| 183 | } |
---|
| 184 | |
---|
[1542] | 185 | std::shared_ptr<COutputPin> CFilterScalarFieldFieldOpExprNode::reduce(CGarbageCollector& gc, CField& thisField) const |
---|
[1158] | 186 | { |
---|
[1542] | 187 | std::shared_ptr<CScalarFieldFieldArithmeticFilter> filter(new CScalarFieldFieldArithmeticFilter(gc, opId, child1->reduce())); |
---|
[1158] | 188 | child2->reduce(gc, thisField)->connectOutput(filter, 0); |
---|
| 189 | child3->reduce(gc, thisField)->connectOutput(filter, 1); |
---|
| 190 | return filter; |
---|
| 191 | } |
---|
| 192 | |
---|
| 193 | |
---|
| 194 | |
---|
| 195 | CFilterFieldScalarScalarOpExprNode::CFilterFieldScalarScalarOpExprNode(IFilterExprNode* child1, const std::string& opId, IScalarExprNode* child2, IScalarExprNode* child3) |
---|
| 196 | : child1(child1) |
---|
| 197 | , opId(opId) |
---|
| 198 | , child2(child2) |
---|
| 199 | , child3(child3) |
---|
| 200 | { |
---|
| 201 | if (!child1 || !child2 || !child3) |
---|
| 202 | ERROR(" CFilterFieldScalarScalarOpExprNode::CFilterFieldScalarScalarOpExprNode(IFilterExprNode* child1, const std::string& opId, IScalarExprNode* child2, IScalarExprNode* child3)", |
---|
| 203 | "Impossible to create the new expression node, an invalid child node was provided."); |
---|
| 204 | } |
---|
| 205 | |
---|
[1542] | 206 | std::shared_ptr<COutputPin> CFilterFieldScalarScalarOpExprNode::reduce(CGarbageCollector& gc, CField& thisField) const |
---|
[1158] | 207 | { |
---|
[1542] | 208 | std::shared_ptr<CFieldScalarScalarArithmeticFilter> filter(new CFieldScalarScalarArithmeticFilter(gc, opId, child2->reduce(),child3->reduce())); |
---|
[1158] | 209 | child1->reduce(gc, thisField)->connectOutput(filter, 0); |
---|
| 210 | return filter; |
---|
| 211 | } |
---|
| 212 | |
---|
| 213 | |
---|
| 214 | |
---|
| 215 | CFilterFieldScalarFieldOpExprNode::CFilterFieldScalarFieldOpExprNode(IFilterExprNode* child1, const std::string& opId, IScalarExprNode* child2, IFilterExprNode* child3) |
---|
| 216 | : child1(child1) |
---|
| 217 | , opId(opId) |
---|
| 218 | , child2(child2) |
---|
| 219 | , child3(child3) |
---|
| 220 | { |
---|
| 221 | if (!child1 || !child2 || !child3) |
---|
| 222 | ERROR(" CFilterFieldScalarFieldOpExprNode::CFilterFieldScalarFieldOpExprNode(IFilterExprNode* child1, const std::string& opId, IScalarExprNode* child2, IFilterExprNode* child3)", |
---|
| 223 | "Impossible to create the new expression node, an invalid child node was provided."); |
---|
| 224 | } |
---|
| 225 | |
---|
[1542] | 226 | std::shared_ptr<COutputPin> CFilterFieldScalarFieldOpExprNode::reduce(CGarbageCollector& gc, CField& thisField) const |
---|
[1158] | 227 | { |
---|
[1542] | 228 | std::shared_ptr<CFieldScalarFieldArithmeticFilter> filter(new CFieldScalarFieldArithmeticFilter(gc, opId, child2->reduce())); |
---|
[1158] | 229 | child1->reduce(gc, thisField)->connectOutput(filter, 0); |
---|
| 230 | child3->reduce(gc, thisField)->connectOutput(filter, 1); |
---|
| 231 | return filter; |
---|
| 232 | } |
---|
| 233 | |
---|
| 234 | |
---|
| 235 | |
---|
| 236 | CFilterFieldFieldScalarOpExprNode::CFilterFieldFieldScalarOpExprNode(IFilterExprNode* child1, const std::string& opId, IFilterExprNode* child2, IScalarExprNode* child3) |
---|
| 237 | : child1(child1) |
---|
| 238 | , opId(opId) |
---|
| 239 | , child2(child2) |
---|
| 240 | , child3(child3) |
---|
| 241 | { |
---|
| 242 | if (!child1 || !child2 || !child3) |
---|
| 243 | ERROR(" CFilterFieldFieldScalarOpExprNode::CFilterFieldFieldScalarOpExprNode(IFilterExprNode* child1, const std::string& opId, IFilterExprNode* child2, IScalarExprNode* child3)", |
---|
| 244 | "Impossible to create the new expression node, an invalid child node was provided."); |
---|
| 245 | } |
---|
| 246 | |
---|
[1542] | 247 | std::shared_ptr<COutputPin> CFilterFieldFieldScalarOpExprNode::reduce(CGarbageCollector& gc, CField& thisField) const |
---|
[1158] | 248 | { |
---|
[1542] | 249 | std::shared_ptr<CFieldFieldScalarArithmeticFilter> filter(new CFieldFieldScalarArithmeticFilter(gc, opId, child3->reduce())); |
---|
[1158] | 250 | child1->reduce(gc, thisField)->connectOutput(filter, 0); |
---|
| 251 | child2->reduce(gc, thisField)->connectOutput(filter, 1); |
---|
| 252 | return filter; |
---|
| 253 | } |
---|
| 254 | |
---|
| 255 | |
---|
| 256 | CFilterFieldFieldFieldOpExprNode::CFilterFieldFieldFieldOpExprNode(IFilterExprNode* child1, const std::string& opId, IFilterExprNode* child2, IFilterExprNode* child3) |
---|
| 257 | : child1(child1) |
---|
| 258 | , opId(opId) |
---|
| 259 | , child2(child2) |
---|
| 260 | , child3(child3) |
---|
| 261 | { |
---|
| 262 | if (!child1 || !child2 || !child3) |
---|
| 263 | ERROR(" CFilterFieldFieldFieldOpExprNode::CFilterFieldFieldFieldOpExprNode(IFilterExprNode* child1, const std::string& opId, IFilterExprNode* child2, IFilterExprNode* child3)", |
---|
| 264 | "Impossible to create the new expression node, an invalid child node was provided."); |
---|
| 265 | } |
---|
| 266 | |
---|
[1542] | 267 | std::shared_ptr<COutputPin> CFilterFieldFieldFieldOpExprNode::reduce(CGarbageCollector& gc, CField& thisField) const |
---|
[1158] | 268 | { |
---|
[1542] | 269 | std::shared_ptr<CFieldFieldFieldArithmeticFilter> filter(new CFieldFieldFieldArithmeticFilter(gc, opId)); |
---|
[1158] | 270 | child1->reduce(gc, thisField)->connectOutput(filter, 0); |
---|
| 271 | child2->reduce(gc, thisField)->connectOutput(filter, 1); |
---|
| 272 | child3->reduce(gc, thisField)->connectOutput(filter, 2); |
---|
| 273 | return filter; |
---|
| 274 | } |
---|
| 275 | |
---|
[642] | 276 | } |
---|