Changeset 737


Ignore:
Timestamp:
10/14/15 13:58:26 (6 years ago)
Author:
rlacroix
Message:

Correctly support expression with the "this" keyword when using a field_ref.

Location:
XIOS/trunk/src/node
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/node/field.cpp

    r731 r737  
    608608       // Check if we have a reference on another field 
    609609       else if (!field_ref.isEmpty()) 
    610        { 
    611          CField* fieldRef = CField::get(field_ref); 
    612          fieldRef->buildFilterGraph(gc, false); 
    613  
    614          std::pair<boost::shared_ptr<CFilter>, boost::shared_ptr<CFilter> > filters; 
    615          // Check if a spatial transformation is needed 
    616          if (!grid_ref.isEmpty() && !fieldRef->grid_ref.isEmpty() && grid_ref.getValue() != fieldRef->grid_ref.getValue()) 
    617            filters = CSpatialTransformFilter::buildFilterGraph(gc, fieldRef->grid, grid); 
    618          else 
    619            filters.first = filters.second = boost::shared_ptr<CFilter>(new CPassThroughFilter(gc)); 
    620  
    621          fieldRef->getInstantDataFilter()->connectOutput(filters.first, 0); 
    622          instantDataFilter = filters.second; 
    623        } 
     610         instantDataFilter = getFieldReference(gc); 
    624611       // Check if the data is to be read from a file 
    625612       else if (file && !file->mode.isEmpty() && file->mode == CFile::mode_attr::read) 
     
    647634 
    648635   /*! 
    649     * Returns the source filter to handle a self reference in the field's expression. 
    650     * If the needed source filter does not exist, it is created, otherwise it is reused. 
     636    * Returns the filter needed to handle the field reference. 
     637    * This method should only be called when building the filter graph corresponding to the field. 
     638    * 
     639    * \param gc the garbage collector to use 
     640    * \return the output pin corresponding to the field reference 
     641    */ 
     642   boost::shared_ptr<COutputPin> CField::getFieldReference(CGarbageCollector& gc) 
     643   { 
     644     if (instantDataFilter || field_ref.isEmpty()) 
     645       ERROR("COutputPin* CField::getFieldReference(CGarbageCollector& gc)", 
     646             "Impossible to get the field reference for a field which has already been parsed or which does not have a field_ref."); 
     647 
     648     CField* fieldRef = CField::get(field_ref); 
     649     fieldRef->buildFilterGraph(gc, false); 
     650 
     651     std::pair<boost::shared_ptr<CFilter>, boost::shared_ptr<CFilter> > filters; 
     652     // Check if a spatial transformation is needed 
     653     if (!grid_ref.isEmpty() && !fieldRef->grid_ref.isEmpty() && grid_ref.getValue() != fieldRef->grid_ref.getValue()) 
     654       filters = CSpatialTransformFilter::buildFilterGraph(gc, fieldRef->grid, grid); 
     655     else 
     656       filters.first = filters.second = boost::shared_ptr<CFilter>(new CPassThroughFilter(gc)); 
     657 
     658     fieldRef->getInstantDataFilter()->connectOutput(filters.first, 0); 
     659 
     660     return filters.second; 
     661   } 
     662 
     663   /*! 
     664    * Returns the filter needed to handle a self reference in the field's expression. 
     665    * If the needed filter does not exist, it is created, otherwise it is reused. 
    651666    * This method should only be called when building the filter graph corresponding 
    652667    * to the field's expression. 
     
    661676             "Impossible to add a self reference to a field which has already been parsed or which does not have an expression."); 
    662677 
    663      if (!clientSourceFilter) 
    664        clientSourceFilter = boost::shared_ptr<CSourceFilter>(new CSourceFilter(grid)); 
    665  
    666      return clientSourceFilter; 
     678     if (!selfReferenceFilter) 
     679     { 
     680       if (!field_ref.isEmpty()) 
     681         selfReferenceFilter = getFieldReference(gc); 
     682       else 
     683       { 
     684         if (!clientSourceFilter) 
     685           clientSourceFilter = boost::shared_ptr<CSourceFilter>(new CSourceFilter(grid)); 
     686 
     687         selfReferenceFilter = clientSourceFilter; 
     688       } 
     689     } 
     690 
     691     return selfReferenceFilter; 
    667692   } 
    668693 
  • XIOS/trunk/src/node/field.hpp

    r731 r737  
    116116 
    117117         void buildFilterGraph(CGarbageCollector& gc, bool enableOutput); 
     118         boost::shared_ptr<COutputPin> getFieldReference(CGarbageCollector& gc); 
    118119         boost::shared_ptr<COutputPin> getSelfReference(CGarbageCollector& gc); 
    119120         boost::shared_ptr<COutputPin> getTemporalDataFilter(CGarbageCollector& gc, CDuration outFreq); 
     
    208209         //! The output pin of the filters providing the result of the field's temporal operation 
    209210         std::map<CDuration, boost::shared_ptr<COutputPin>, DurationFakeLessComparator> temporalDataFilters; 
     211         //! The output pin of the filter providing the instant data for self references 
     212         boost::shared_ptr<COutputPin> selfReferenceFilter; 
    210213         //! The source filter for data provided by the client 
    211214         boost::shared_ptr<CSourceFilter> clientSourceFilter; 
Note: See TracChangeset for help on using the changeset viewer.