- Timestamp:
- 06/25/19 16:14:54 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/dev_trunk_omp/src/filter/binary_arithmetic_filter.cpp
r804 r1677 1 1 #include "binary_arithmetic_filter.hpp" 2 #include "workflow_graph.hpp" 2 3 3 4 namespace xios … … 7 8 , op(operatorExpr.getOpScalarField(op)) 8 9 , value(value) 9 { /* Nothing to do */ }; 10 { 11 StdString input_op_expression=op; 12 if(input_op_expression == "add") 13 op_expression = "+"; 14 else if(input_op_expression == "minus") 15 op_expression = "-"; 16 else if(input_op_expression == "mult") 17 op_expression = "x"; 18 else if(input_op_expression == "div") 19 op_expression = "/"; 20 else if(input_op_expression == "eq") 21 op_expression = "="; 22 else if(input_op_expression == "lt") 23 op_expression = "<"; 24 else if(input_op_expression == "gt") 25 op_expression = ">"; 26 else if(input_op_expression == "le") 27 op_expression = "<="; 28 else if(input_op_expression == "ge") 29 op_expression = ">="; 30 else if(input_op_expression == "ne") 31 op_expression = "!="; 32 else 33 op_expression = " "; 34 }; 10 35 11 36 CDataPacketPtr CScalarFieldArithmeticFilter::apply(std::vector<CDataPacketPtr> data) 12 37 { 38 if(this->tag) 39 { 40 this->filterID = InvalidableObject::filterIdGenerator++; 41 42 if(CWorkflowGraph::mapFieldToFilters_ptr==0) CWorkflowGraph::mapFieldToFilters_ptr = new std::unordered_map <StdString, vector <int> >; 43 if(CWorkflowGraph::mapFilters_ptr==0) CWorkflowGraph::mapFilters_ptr = new std::unordered_map <int, StdString>; 44 45 (*CWorkflowGraph::mapFilters_ptr)[this->filterID] = "S "+op_expression +" F Filter" ; 46 std::cout<<"CScalarFieldArithmeticFilter::apply filter tag = "<<this->tag<<std::endl; 47 48 StdString str = data[0]->fieldID +" ts=" + to_string(data[0]->timestamp); 49 (*CWorkflowGraph::mapFieldToFilters_ptr)[str].push_back(data[0]->src_filterID); 50 (*CWorkflowGraph::mapFieldToFilters_ptr)[str].push_back(this->filterID); 51 } 52 13 53 CDataPacketPtr packet(new CDataPacket); 14 54 packet->date = data[0]->date; 15 55 packet->timestamp = data[0]->timestamp; 16 56 packet->status = data[0]->status; 57 if(this->tag) packet->src_filterID = this->filterID; 58 packet->fieldID = this->output_field_id; 17 59 18 60 if (packet->status == CDataPacket::NO_ERROR) … … 26 68 , op(operatorExpr.getOpFieldScalar(op)) 27 69 , value(value) 28 { /* Nothing to do */ }; 70 { 71 StdString input_op_expression=op; 72 if(input_op_expression == "add") 73 op_expression = "+"; 74 else if(input_op_expression == "minus") 75 op_expression = "-"; 76 else if(input_op_expression == "mult") 77 op_expression = "x"; 78 else if(input_op_expression == "div") 79 op_expression = "/"; 80 else if(input_op_expression == "pow") 81 op_expression = "^"; 82 else if(input_op_expression == "eq") 83 op_expression = "="; 84 else if(input_op_expression == "lt") 85 op_expression = "<"; 86 else if(input_op_expression == "gt") 87 op_expression = ">"; 88 else if(input_op_expression == "le") 89 op_expression = "<="; 90 else if(input_op_expression == "ge") 91 op_expression = ">="; 92 else if(input_op_expression == "ne") 93 op_expression = "!="; 94 else 95 op_expression = " "; 96 }; 29 97 30 98 CDataPacketPtr CFieldScalarArithmeticFilter::apply(std::vector<CDataPacketPtr> data) 31 99 { 100 if(this->tag) 101 { 102 this->filterID = InvalidableObject::filterIdGenerator++; 103 104 if(CWorkflowGraph::mapFieldToFilters_ptr==0) CWorkflowGraph::mapFieldToFilters_ptr = new std::unordered_map <StdString, vector <int> >; 105 if(CWorkflowGraph::mapFilters_ptr==0) CWorkflowGraph::mapFilters_ptr = new std::unordered_map <int, StdString>; 106 107 (*CWorkflowGraph::mapFilters_ptr)[this->filterID] = "F "+op_expression +" S Filter" ; 108 std::cout<<"CFieldScalarArithmeticFilter::apply filter tag = "<<this->tag<<std::endl; 109 110 StdString str = data[0]->fieldID +" ts=" + to_string(data[0]->timestamp); 111 (*CWorkflowGraph::mapFieldToFilters_ptr)[str].push_back(data[0]->src_filterID); 112 (*CWorkflowGraph::mapFieldToFilters_ptr)[str].push_back(this->filterID); 113 } 114 32 115 CDataPacketPtr packet(new CDataPacket); 33 116 packet->date = data[0]->date; 34 117 packet->timestamp = data[0]->timestamp; 35 118 packet->status = data[0]->status; 119 if(this->tag) packet->src_filterID = this->filterID; 120 packet->fieldID = this->output_field_id; 121 36 122 37 123 if (packet->status == CDataPacket::NO_ERROR) … … 44 130 : CFilter(gc, 2, this) 45 131 , op(operatorExpr.getOpFieldField(op)) 46 { /* Nothing to do */ }; 132 { 133 StdString input_op_expression=op; 134 if(input_op_expression == "add") 135 op_expression = "+"; 136 else if(input_op_expression == "minus") 137 op_expression = "-"; 138 else if(input_op_expression == "mult") 139 op_expression = "x"; 140 else if(input_op_expression == "div") 141 op_expression = "/"; 142 else if(input_op_expression == "pow") 143 op_expression = "^"; 144 else if(input_op_expression == "eq") 145 op_expression = "="; 146 else if(input_op_expression == "lt") 147 op_expression = "<"; 148 else if(input_op_expression == "gt") 149 op_expression = ">"; 150 else if(input_op_expression == "le") 151 op_expression = "<="; 152 else if(input_op_expression == "ge") 153 op_expression = ">="; 154 else if(input_op_expression == "ne") 155 op_expression = "!="; 156 else 157 op_expression = " "; 158 }; 47 159 48 160 CDataPacketPtr CFieldFieldArithmeticFilter::apply(std::vector<CDataPacketPtr> data) 49 161 { 162 if(this->tag) 163 { 164 165 this->filterID = InvalidableObject::filterIdGenerator++; 166 167 if(CWorkflowGraph::mapFieldToFilters_ptr==0) CWorkflowGraph::mapFieldToFilters_ptr = new std::unordered_map <StdString, vector <int> >; 168 if(CWorkflowGraph::mapFilters_ptr==0) CWorkflowGraph::mapFilters_ptr = new std::unordered_map <int, StdString>; 169 170 (*CWorkflowGraph::mapFilters_ptr)[this->filterID] = "F "+op_expression +" F Filter" ; 171 std::cout<<"CFieldFieldArithmeticFilter::apply filter tag = "<<this->tag<<std::endl; 172 173 StdString str = data[0]->fieldID +" ts=" + to_string(data[0]->timestamp); 174 (*CWorkflowGraph::mapFieldToFilters_ptr)[str].push_back(data[0]->src_filterID); 175 (*CWorkflowGraph::mapFieldToFilters_ptr)[str].push_back(this->filterID); 176 177 str = data[1]->fieldID +" ts=" + to_string(data[0]->timestamp); 178 179 (*CWorkflowGraph::mapFieldToFilters_ptr)[str].push_back(data[1]->src_filterID); 180 (*CWorkflowGraph::mapFieldToFilters_ptr)[str].push_back(this->filterID); 181 } 182 183 50 184 CDataPacketPtr packet(new CDataPacket); 51 185 packet->date = data[0]->date; 52 186 packet->timestamp = data[0]->timestamp; 187 if(this->tag) packet->src_filterID = this->filterID; 188 packet->fieldID = this->output_field_id; 189 53 190 54 191 if (data[0]->status != CDataPacket::NO_ERROR) … … 64 201 return packet; 65 202 } 203 204 StdString CScalarFieldArithmeticFilter::GetName(void) { return StdString("CScalarFieldArithmeticFilter"); } 205 StdString CFieldScalarArithmeticFilter::GetName(void) { return StdString("CFieldScalarArithmeticFilter"); } 206 StdString CFieldFieldArithmeticFilter::GetName(void) { return StdString("CFieldFieldArithmeticFilter"); } 207 208 66 209 } // namespace xios
Note: See TracChangeset
for help on using the changeset viewer.