source: XIOS/dev/dev_trunk_graph/src/filter/pass_through_filter.cpp @ 2023

Last change on this file since 2023 was 2023, checked in by yushan, 8 months ago

Graph intermediate commit to a tmp branch.

File size: 2.1 KB
Line 
1#include "pass_through_filter.hpp"
2#include "workflow_graph.hpp"
3#include <algorithm>
4
5namespace xios
6{
7  CPassThroughFilter::CPassThroughFilter(CGarbageCollector& gc)
8    : CFilter(gc, 1, this)
9  { /* Nothing to do */ }
10
11  CDataPacketPtr CPassThroughFilter::apply(std::vector<CDataPacketPtr> data)
12  {
13    buildWorkflowGraph(data);
14    return data[0];
15  }
16
17  void CPassThroughFilter::buildWorkflowGraph(std::vector<CDataPacketPtr> data)
18  {
19    if(this->graphEnabled)
20    {
21      if(data[0]->graphPackage->currentField->getId() == this->graphPackage->inFields[0]->getId())
22      {
23        std::cout<<"PASS THROUGH FILTER OMITTED "<<this<<std::endl;
24        std::cout<<data[0]->graphPackage->currentField->getId()<< "-------"<< this->graphPackage->inFields[0]->getId()<<std::endl;
25        return;
26      }
27      this->graphPackage->filterId = CWorkflowGraph::getNodeSize();
28     
29      if(!data[0]->graphPackage) 
30      {
31        data[0]->graphPackage = new CGraphDataPackage;
32        data[0]->graphPackage->fromFilter = -1;
33      }
34
35      for(int i=0; i<this->graphPackage->filterId; i++)
36      {
37        if(  (*CWorkflowGraph::vectorOfNodes_)[i].label_field_id == this->label_field_id 
38          && (*CWorkflowGraph::vectorOfNodes_)[i].timestamp == data[0]->timestamp
39          && CXios::isClient
40          && (*CWorkflowGraph::vectorOfNodes_)[i].filter_name == "Pass through filter" )
41        {
42          data[0]->graphPackage->fromFilter = i;
43          return;
44        } 
45      }
46     
47      CWorkflowGraph::addNode("Pass through filter", 2, false, 1, data[0]);
48      if(CXios::isClient) (*CWorkflowGraph::vectorOfNodes_)[this->graphPackage->filterId].label_field_id = this->label_field_id;
49      CWorkflowGraph::addEdge(data[0]->graphPackage->fromFilter, this->graphPackage->filterId, data[0]);
50     
51      data[0]->graphPackage->currentField = this->graphPackage->inFields[0];
52      std::rotate(this->graphPackage->inFields.begin(), this->graphPackage->inFields.begin() + 1, this->graphPackage->inFields.end());
53     
54     
55      data[0]->graphPackage->fromFilter = this->graphPackage->filterId;
56       
57    } 
58  }
59
60
61} // namespace xios
62
Note: See TracBrowser for help on using the repository browser.