Changeset 1575


Ignore:
Timestamp:
09/10/18 14:21:17 (3 years ago)
Author:
ymipsl
Message:

New functionnalité for parsing expression : new keyword "this_ref" representing the flux of the referenced field tghrough field_ref attribute.
Very close to the "this" keyword, excepted when applied @ operator, freq_op and freq_offset are taking from the referenced field.

YM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/parse_expr/filter_expr_node.cpp

    r1542 r1575  
    1111  { /* Nothing to do */ } 
    1212 
     13   
    1314  std::shared_ptr<COutputPin> CFilterFieldExprNode::reduce(CGarbageCollector& gc, CField& thisField) const 
    1415  { 
    1516    std::shared_ptr<COutputPin> outputPin; 
    1617 
    17     if (fieldId == "this") 
    18       outputPin = thisField.getSelfReference(gc); 
    19     else if (CField::has(fieldId)) 
     18    if (fieldId == "this") outputPin = thisField.getSelfReference(gc); 
     19    else 
    2020    { 
    21       CField* field = CField::get(fieldId); 
    22       if (field == &thisField) 
    23         ERROR("std::shared_ptr<COutputPin> CFilterFieldExprNode::reduce(CGarbageCollector& gc, CField& thisField) const", 
    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(); 
     21      string id ; 
     22 
     23      if (fieldId == "this_ref") 
     24      { 
     25        if (thisField.field_ref.isEmpty()) 
     26        { 
     27          ERROR("shared_ptr<COutputPin> CFilterFieldExprNode::reduce(CGarbageCollector& gc, CField& thisField) const", 
     28                << "field_ref attribute is empty."); 
     29        } 
     30        else id = thisField.field_ref ; 
     31      } 
     32      else id= fieldId ; 
     33        
     34      if (CField::has(id)) 
     35      { 
     36        CField* field = CField::get(id); 
     37        if (field == &thisField) 
     38          ERROR("shared_ptr<COutputPin> CFilterFieldExprNode::reduce(CGarbageCollector& gc, CField& thisField) const", 
     39                << "The field " << id << " has an invalid reference to itself. " 
     40                << "Use the keyword \"this\" if you want to reference the input data sent to this field."); 
     41 
     42        field->buildFilterGraph(gc, false); 
     43        outputPin = field->getInstantDataFilter(); 
     44      } 
     45      else ERROR("boost::shared_ptr<COutputPin> CFilterFieldExprNode::reduce(CGarbageCollector& gc, CField& thisField) const", 
     46                  << "The field " << id << " does not exist."); 
    2947    } 
    30     else 
    31       ERROR("std::shared_ptr<COutputPin> CFilterFieldExprNode::reduce(CGarbageCollector& gc, CField& thisField) const", 
    32             << "The field " << fieldId << " does not exist."); 
    33  
    3448    return outputPin; 
    3549  } 
     50 
    3651 
    3752  CFilterTemporalFieldExprNode::CFilterTemporalFieldExprNode(const std::string& fieldId) 
     
    3954  { /* Nothing to do */ } 
    4055 
     56 
    4157  std::shared_ptr<COutputPin> CFilterTemporalFieldExprNode::reduce(CGarbageCollector& gc, CField& thisField) const 
    4258  { 
     
    4561    if (fieldId == "this") 
    4662      outputPin = thisField.getSelfTemporalDataFilter(gc, thisField.freq_op.isEmpty() ? TimeStep : thisField.freq_op); 
    47     else if (CField::has(fieldId)) 
     63    else 
    4864    { 
    49       CField* field = CField::get(fieldId); 
    50       if (field == &thisField) 
    51         ERROR("std::shared_ptr<COutputPin> CFilterTemporalFieldExprNode::reduce(CGarbageCollector& gc, CField& thisField) const", 
    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); 
     65      string id ; 
     66 
     67      if (fieldId == "this_ref") 
     68      { 
     69        if (thisField.field_ref.isEmpty()) 
     70        { 
     71          ERROR("shared_ptr<COutputPin> CFilterFieldExprNode::reduce(CGarbageCollector& gc, CField& thisField) const", 
     72                << "field_ref attribute is empty."); 
     73        } 
     74        else id = thisField.field_ref ; 
     75      } 
     76      else id = fieldId ; 
     77 
     78      if (CField::has(id)) 
     79      { 
     80        CField* field = CField::get(id); 
     81        if (field == &thisField) 
     82          ERROR("shared_ptr<COutputPin> CFilterTemporalFieldExprNode::reduce(CGarbageCollector& gc, CField& thisField) const", 
     83                << "The field " << fieldId << " has an invalid reference to itself. " 
     84                << "Use the keyword \"this\" if you want to reference the input data sent to this field."); 
     85 
     86        field->buildFilterGraph(gc, false); 
     87        outputPin = field->getTemporalDataFilter(gc, thisField.freq_op.isEmpty() ? TimeStep : thisField.freq_op); 
     88      } 
     89      else 
     90        ERROR("shared_ptr<COutputPin> CFilterTemporalFieldExprNode::reduce(CGarbageCollector& gc, CField& thisField) const", 
     91              << "The field " << fieldId << " does not exist."); 
    5792    } 
    58     else 
    59       ERROR("std::shared_ptr<COutputPin> CFilterTemporalFieldExprNode::reduce(CGarbageCollector& gc, CField& thisField) const", 
    60             << "The field " << fieldId << " does not exist."); 
    61  
    6293    return outputPin; 
    6394  } 
     95 
    6496 
    6597  CFilterUnaryOpExprNode::CFilterUnaryOpExprNode(const std::string& opId, IFilterExprNode* child) 
Note: See TracChangeset for help on using the changeset viewer.