1 | #include "unary_arithmetic_filter.hpp" |
---|
2 | #include "workflow_graph.hpp" |
---|
3 | #include "yacc_var.hpp" |
---|
4 | #include "file.hpp" |
---|
5 | |
---|
6 | namespace xios |
---|
7 | { |
---|
8 | CUnaryArithmeticFilter::CUnaryArithmeticFilter(CGarbageCollector& gc, const std::string& op) |
---|
9 | : CFilter(gc, 1, this) |
---|
10 | , op(operatorExpr.getOpField(op)) |
---|
11 | { |
---|
12 | expression.assign(*yacc_globalInputText_ptr, 0, yacc_globalInputText_ptr->size()-1); |
---|
13 | }; |
---|
14 | |
---|
15 | CDataPacketPtr CUnaryArithmeticFilter::apply(std::vector<CDataPacketPtr> data) |
---|
16 | { |
---|
17 | bool building_graph = this->tag ? data[0]->timestamp >= this->start_graph && data[0]->timestamp <= this->end_graph : false; |
---|
18 | int unique_filter_id; |
---|
19 | |
---|
20 | if(building_graph) |
---|
21 | { |
---|
22 | CWorkflowGraph::allocNodeEdge(); |
---|
23 | size_t filterhash = std::hash<StdString>{}(expression+to_string(data[0]->timestamp)+this->field->getId()); |
---|
24 | |
---|
25 | // first round |
---|
26 | if(CWorkflowGraph::mapHashFilterID_ptr->find(filterhash) == CWorkflowGraph::mapHashFilterID_ptr->end()) |
---|
27 | { |
---|
28 | this->filterID = InvalidableObject::filterIdGenerator++; |
---|
29 | int edgeID = InvalidableObject::edgeIdGenerator++; |
---|
30 | |
---|
31 | CWorkflowGraph::addNode(this->filterID, "Arithmetic Filter\\n("+expression+")", 3, 1, 0, data[0]); |
---|
32 | (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].filter_tag = this->tag; |
---|
33 | |
---|
34 | (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes = this->field->recordXiosAttributes(); |
---|
35 | if(this->field->file) (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes += "</br>file attributes : </br>" +this->field->file->recordXiosAttributes(); |
---|
36 | |
---|
37 | if(CWorkflowGraph::build_begin) |
---|
38 | { |
---|
39 | |
---|
40 | CWorkflowGraph::addEdge(edgeID, this->filterID, data[0]); |
---|
41 | (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].expected_entry_nb ++; |
---|
42 | |
---|
43 | (*CWorkflowGraph::mapFilters_ptr_with_info)[data[0]->src_filterID].filter_filled = 0 ; |
---|
44 | } |
---|
45 | else CWorkflowGraph::build_begin = true; |
---|
46 | |
---|
47 | (*CWorkflowGraph::mapHashFilterID_ptr)[filterhash] = this->filterID; |
---|
48 | unique_filter_id = this->filterID; |
---|
49 | } |
---|
50 | else |
---|
51 | { |
---|
52 | unique_filter_id = (*CWorkflowGraph::mapHashFilterID_ptr)[filterhash]; |
---|
53 | if(data[0]->src_filterID != unique_filter_id) |
---|
54 | { |
---|
55 | int edgeID = InvalidableObject::edgeIdGenerator++; |
---|
56 | CWorkflowGraph::addEdge(edgeID, unique_filter_id, data[0]); |
---|
57 | (*CWorkflowGraph::mapFilters_ptr_with_info)[data[0]->src_filterID].filter_filled = 0 ; |
---|
58 | (*CWorkflowGraph::mapFilters_ptr_with_info)[unique_filter_id].expected_entry_nb ++; |
---|
59 | } |
---|
60 | |
---|
61 | |
---|
62 | } |
---|
63 | |
---|
64 | } |
---|
65 | |
---|
66 | CDataPacketPtr packet(new CDataPacket); |
---|
67 | packet->date = data[0]->date; |
---|
68 | packet->timestamp = data[0]->timestamp; |
---|
69 | packet->status = data[0]->status; |
---|
70 | packet->field = this->field; |
---|
71 | |
---|
72 | if (packet->status == CDataPacket::NO_ERROR) |
---|
73 | packet->data.reference(op(data[0]->data)); |
---|
74 | |
---|
75 | if(building_graph) packet->src_filterID = unique_filter_id; |
---|
76 | |
---|
77 | return packet; |
---|
78 | } |
---|
79 | } // namespace xios |
---|
80 | |
---|