Ignore:
Timestamp:
08/24/21 13:48:12 (3 years ago)
Author:
ymipsl
Message:

New feature : when can now use the syntax :
fieldId:domainId[n], in domain reference inside the workflow (XML). Same for axis and scalar.

YM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/scalar.cpp

    r2203 r2206  
    5353  } 
    5454 
    55   CScalar* CScalar::get(const string& id) 
     55  CScalar* CScalar::get(const string& id, bool noError) 
    5656  { 
    5757    const regex r("::"); 
     
    6363      if (fieldId.empty()) ERROR("CScalar* CScalar::get(string& id)", <<" id = "<<id<< "  -> bad format id, field name is empty"); 
    6464      string suffix=m.suffix() ; 
     65      if (!CField::has(fieldId))  
     66          if (noError)  return nullptr ; 
     67          else ERROR("CScalar* CScalar::get(const string& id, bool noError)", <<" id = "<<id<< "  -> field Id : < "<<fieldId<<" > doesn't exist"); 
    6568      CField* field=CField::get(fieldId) ; 
    66       return field->getAssociatedScalar(suffix) ; 
    67     } 
    68     else return CObjectFactory::GetObject<CScalar>(id).get(); 
    69   } 
     69      return field->getAssociatedScalar(suffix, noError) ; 
     70    } 
     71    else 
     72    { 
     73       if (noError) if(!CObjectFactory::HasObject<CScalar>(id)) return nullptr ; 
     74       return CObjectFactory::GetObject<CScalar>(id).get(); 
     75     } 
     76   } 
     77 
     78   bool CScalar::has(const string& id) 
     79   { 
     80     if (CScalar::get(id,true)==nullptr) return false ; 
     81     else return true ; 
     82   } 
     83    
     84   CField* CScalar::getFieldFromId(const string& id) 
     85   { 
     86     const regex r("::"); 
     87     smatch m; 
     88     if (regex_search(id, m, r)) 
     89     { 
     90        if (m.size()!=1) ERROR("CField* CScalar::getFieldFromId(const string& id)", <<" id = "<<id<< "  -> bad format id, separator :: append more than one time"); 
     91        string fieldId=m.prefix() ; 
     92        if (fieldId.empty()) ERROR("CField* CScalar::getFieldFromId(const string& id)", <<" id = "<<id<< "  -> bad format id, field name is empty"); 
     93        string suffix=m.suffix() ; 
     94        CField* field=CField::get(fieldId) ; 
     95        return field ; 
     96     } 
     97     else return nullptr; 
     98   } 
    7099 
    71100  bool CScalar::IsWritten(const StdString & filename) const 
     
    210239  } 
    211240  CATCH_DUMP_ATTR 
     241 
     242  bool CScalar::activateFieldWorkflow(CGarbageCollector& gc) 
     243  TRY 
     244  { 
     245    if (!scalar_ref.isEmpty()) 
     246    { 
     247      CField* field=getFieldFromId(scalar_ref) ; 
     248      if (field!=nullptr) 
     249      { 
     250        bool ret = field->buildWorkflowGraph(gc) ; 
     251        if (!ret) return false ; // cannot build workflow graph at this state 
     252      } 
     253      else  
     254      { 
     255        CScalar* scalar = get(scalar_ref) ; 
     256        bool ret = scalar->activateFieldWorkflow(gc) ; 
     257        if (!ret) return false ; // cannot build workflow graph at this state 
     258        scalar_ref=scalar->getId() ; // replace domain_ref by solved reference 
     259      } 
     260    } 
     261    activateFieldWorkflow_done_=true ; 
     262    return true ; 
     263  } 
     264  CATCH_DUMP_ATTR 
     265 
    212266 
    213267  /* obsolete, to remove after reimplementing coupling */ 
Note: See TracChangeset for help on using the changeset viewer.