Ignore:
Timestamp:
08/20/21 14:38:23 (3 years ago)
Author:
ymipsl
Message:

New functionnality : domain, axis and scalar can now be retrieve with new syntax id :
ex. for domain :

id="domainId" : old syntax, working as before
id="fieldId::domainId" : get the domain related to "domainId" associated to the field "fieldId", work if only 1 domain related to domainId is associated to the field.
id="fieldId::domainId[n]" : get the nth domain related to "domainId" associated to the field "fieldId"
id="fieldId::" : get the domain associated the the field "fieldId, work if grid associated to th field is composed with exactly 1 domain (and possibly other components axis or scalars)
id="fieldId::[n] : get the nth domain composing the grid associated to the field

YM

File:
1 edited

Legend:

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

    r2196 r2203  
    2626#include "transformation_path.hpp" 
    2727 
    28  
    29  
    30  
    3128#include <algorithm> 
     29#include <regex> 
     30 
    3231 
    3332namespace xios { 
     
    7978   } 
    8079   CATCH 
     80 
     81   CDomain* CDomain::get(const string& id) 
     82   { 
     83     const regex r("::"); 
     84     smatch m; 
     85     if (regex_search(id, m, r)) 
     86     { 
     87        if (m.size()!=1) ERROR("CDomain* CDomain::get(string& id)", <<" id = "<<id<< "  -> bad format id, separator :: append more than one time"); 
     88        string fieldId=m.prefix() ; 
     89        if (fieldId.empty()) ERROR("CDomain* CDomain::get(string& id)", <<" id = "<<id<< "  -> bad format id, field name is empty"); 
     90        string suffix=m.suffix() ; 
     91        CField* field=CField::get(fieldId) ; 
     92        return field->getAssociatedDomain(suffix) ; 
     93     } 
     94     else return CObjectFactory::GetObject<CDomain>(id).get(); 
     95   } 
     96 
    8197 
    8298   const std::set<StdString> & CDomain::getRelFiles(void) const 
Note: See TracChangeset for help on using the changeset viewer.