source: XIOS/dev/dev_trunk_omp/src/filter/pass_through_filter.cpp @ 1685

Last change on this file since 1685 was 1685, checked in by yushan, 2 years ago

dev for graph

File size: 2.0 KB
Line 
1#include "pass_through_filter.hpp"
2#include "workflow_graph.hpp"
3#include "field.hpp"
4#include "file.hpp"
5
6namespace xios
7{
8  CPassThroughFilter::CPassThroughFilter(CGarbageCollector& gc)
9    : CFilter(gc, 1, this)
10  { 
11  }
12
13  void CPassThroughFilter::buildGraph(std::vector<CDataPacketPtr> data)
14  {
15    bool building_graph = this->tag ? data[0]->timestamp >= this->start_graph && data[0]->timestamp <= this->end_graph : false;
16    // bool building_graph = this->tag ? data[0]->timestamp >= this->field->field_graph_start && data[0]->timestamp <= this->field->field_graph_end : false;
17
18    if(building_graph)
19    {
20      std::cout<<"pass through packet->distance = "<<data[0]->distance<<std::endl;
21      // std::cout<<"CPassThroughFilter::apply field_id = "<<this->field->getId()<<" start = "<<start_graph<<" end = "<<end_graph<<std::endl;
22      this->filterID = InvalidableObject::filterIdGenerator++;
23      int edgeID = InvalidableObject::edgeIdGenerator++;
24
25      CWorkflowGraph::allocNodeEdge();
26
27      CWorkflowGraph::addNode(this->filterID, "Pass Through Filter\\n("+data[0]->field->getId()+")", 2, 1, 1, data[0]);
28      (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].distance = data[0]->distance+1;
29
30      (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes = this->field->record4graphXiosAttributes();
31      if(this->field->file) (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes += "</br>file attributes : </br>" +this->field->file->record4graphXiosAttributes();
32
33     
34      if(CWorkflowGraph::build_begin)
35      {
36        CWorkflowGraph::addEdge(edgeID, this->filterID, data[0]);
37        (*CWorkflowGraph::mapFilters_ptr_with_info)[data[0]->src_filterID].filter_filled = 0;
38      }
39      else CWorkflowGraph::build_begin = true;
40     
41      data[0]->src_filterID=this->filterID;
42      data[0]->distance++;
43
44    }
45
46    data[0]->field = this->field;
47
48  }
49
50  CDataPacketPtr CPassThroughFilter::apply(std::vector<CDataPacketPtr> data)
51  {
52    if(CXios::isClient) buildGraph(data);
53    return data[0];
54  }
55
56} // namespace xios
Note: See TracBrowser for help on using the repository browser.