- Timestamp:
- 08/24/21 13:48:12 (3 years ago)
- Location:
- XIOS/dev/dev_ym/XIOS_COUPLING/src/node
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/axis.cpp
r2203 r2206 221 221 CATCH 222 222 223 CAxis* CAxis::get(const string& id )223 CAxis* CAxis::get(const string& id, bool noError) 224 224 { 225 225 const regex r("::"); … … 231 231 if (fieldId.empty()) ERROR("CAxis* CAxis::get(string& id)", <<" id = "<<id<< " -> bad format id, field name is empty"); 232 232 string suffix=m.suffix() ; 233 if (!CField::has(fieldId)) 234 if (noError) return nullptr ; 235 else ERROR("CAxis* CAxis::get(string& id, bool noError)", <<" id = "<<id<< " -> field Id : < "<<fieldId<<" > doesn't exist"); 233 236 CField* field=CField::get(fieldId) ; 234 return field->getAssociatedAxis(suffix ) ;237 return field->getAssociatedAxis(suffix, noError) ; 235 238 } 236 else return CObjectFactory::GetObject<CAxis>(id).get(); 239 { 240 if (noError) if(!CObjectFactory::HasObject<CAxis>(id)) return nullptr ; 241 return CObjectFactory::GetObject<CAxis>(id).get(); 242 } 243 } 244 245 bool CAxis::has(const string& id) 246 { 247 if (CAxis::get(id,true)==nullptr) return false ; 248 else return true ; 249 } 250 251 CField* CAxis::getFieldFromId(const string& id) 252 { 253 const regex r("::"); 254 smatch m; 255 if (regex_search(id, m, r)) 256 { 257 if (m.size()!=1) ERROR("CField* CAxis::getFieldFromId(const string& id)", <<" id = "<<id<< " -> bad format id, separator :: append more than one time"); 258 string fieldId=m.prefix() ; 259 if (fieldId.empty()) ERROR("CField* CAxis::getFieldFromId(const string& id)", <<" id = "<<id<< " -> bad format id, field name is empty"); 260 string suffix=m.suffix() ; 261 CField* field=CField::get(fieldId) ; 262 return field ; 263 } 264 else return nullptr; 237 265 } 238 266 … … 635 663 } 636 664 CATCH_DUMP_ATTR 665 666 bool CAxis::activateFieldWorkflow(CGarbageCollector& gc) 667 TRY 668 { 669 if (!axis_ref.isEmpty()) 670 { 671 CField* field=getFieldFromId(axis_ref) ; 672 if (field!=nullptr) 673 { 674 bool ret = field->buildWorkflowGraph(gc) ; 675 if (!ret) return false ; // cannot build workflow graph at this state 676 } 677 else 678 { 679 CAxis* axis = get(axis_ref) ; 680 bool ret = axis->activateFieldWorkflow(gc) ; 681 if (!ret) return false ; // cannot build workflow graph at this state 682 axis_ref=axis->getId() ; // replace domain_ref by solved reference 683 } 684 } 685 activateFieldWorkflow_done_=true ; 686 return true ; 687 } 688 CATCH_DUMP_ATTR 689 637 690 638 691 void CAxis::setContextClient(CContextClient* contextClient) -
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/axis.hpp
r2203 r2206 32 32 class CAxisAttributes; 33 33 class CAxis; 34 class CField; 34 35 35 36 ///-------------------------------------------------------------- … … 69 70 70 71 static CAxis* createAxis(); 71 static CAxis* get(const string& id) ; //<! return axis pointer using id 72 static CAxis* get(const string& id, bool noError=false) ; //<! return axis pointer using id 73 static bool has(const string& id) ; //<! return domain pointer using id 74 static CField* getFieldFromId(const string& id) ; 72 75 73 76 /// Accesseurs /// … … 144 147 private: 145 148 bool solveInheritanceTransformation_done_= false ; 149 public: 150 bool activateFieldWorkflow(CGarbageCollector& gc) ; 151 private: 152 bool activateFieldWorkflow_done_=false ; 146 153 private: 147 154 CGenericAlgorithmTransformation* transformationAlgorithm_ = nullptr ; -
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/domain.cpp
r2203 r2206 79 79 CATCH 80 80 81 CDomain* CDomain::get(const string& id )81 CDomain* CDomain::get(const string& id, bool noError) 82 82 { 83 83 const regex r("::"); … … 89 89 if (fieldId.empty()) ERROR("CDomain* CDomain::get(string& id)", <<" id = "<<id<< " -> bad format id, field name is empty"); 90 90 string suffix=m.suffix() ; 91 if (!CField::has(fieldId)) 92 if (noError) return nullptr ; 93 else ERROR("CDomain* CDomain::get(string& id)", <<" id = "<<id<< " -> field Id : < "<<fieldId<<" > doesn't exist"); 91 94 CField* field=CField::get(fieldId) ; 92 return field->getAssociatedDomain(suffix) ; 93 } 94 else return CObjectFactory::GetObject<CDomain>(id).get(); 95 } 96 95 return field->getAssociatedDomain(suffix, noError) ; 96 } 97 else 98 { 99 if (noError) if(!CObjectFactory::HasObject<CDomain>(id)) return nullptr ; 100 return CObjectFactory::GetObject<CDomain>(id).get(); 101 } 102 } 103 104 bool CDomain::has(const string& id) 105 { 106 if (CDomain::get(id,true)==nullptr) return false ; 107 else return true ; 108 } 109 110 CField* CDomain::getFieldFromId(const string& id) 111 { 112 const regex r("::"); 113 smatch m; 114 if (regex_search(id, m, r)) 115 { 116 if (m.size()!=1) ERROR("CField* CDomain::getFieldFromId(const string& id)", <<" id = "<<id<< " -> bad format id, separator :: append more than one time"); 117 string fieldId=m.prefix() ; 118 if (fieldId.empty()) ERROR("CField* CDomain::getFieldFromId(const string& id)", <<" id = "<<id<< " -> bad format id, field name is empty"); 119 string suffix=m.suffix() ; 120 CField* field=CField::get(fieldId) ; 121 return field ; 122 } 123 else return nullptr; 124 } 97 125 98 126 const std::set<StdString> & CDomain::getRelFiles(void) const … … 2337 2365 CATCH_DUMP_ATTR 2338 2366 2367 2368 bool CDomain::activateFieldWorkflow(CGarbageCollector& gc) 2369 TRY 2370 { 2371 if (!domain_ref.isEmpty()) 2372 { 2373 CField* field=getFieldFromId(domain_ref) ; 2374 if (field!=nullptr) 2375 { 2376 bool ret = field->buildWorkflowGraph(gc) ; 2377 if (!ret) return false ; // cannot build workflow graph at this state 2378 } 2379 else 2380 { 2381 CDomain* domain = get(domain_ref) ; 2382 bool ret = domain->activateFieldWorkflow(gc) ; 2383 if (!ret) return false ; // cannot build workflow graph at this state 2384 domain_ref=domain->getId() ; // replace domain_ref by solved reference 2385 } 2386 } 2387 activateFieldWorkflow_done_=true ; 2388 return true ; 2389 } 2390 CATCH_DUMP_ATTR 2339 2391 ///////////////////////////////////////////////////////////////////////////////////////////// 2340 2392 ///////////////////////////////////////////////////////////////////////////////////////////// -
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/domain.hpp
r2203 r2206 36 36 class CDomain; 37 37 class CFile; 38 class CField ; 38 39 39 40 ///-------------------------------------------------------------- … … 72 73 73 74 static CDomain* createDomain(); 74 static CDomain* get(const string& id) ; //<! return domain pointer using id 75 // static bool has(const string& id) ; //<! return true if domain with identifier id exist 75 static CDomain* get(const string& id, bool noError=false) ; //<! return domain pointer using id 76 static bool has(const string& id) ; //<! return domain pointer using id 77 static CField* getFieldFromId(const string& id) ; 76 78 77 79 CMesh* mesh; … … 109 111 private: 110 112 bool solveInheritanceTransformation_done_= false ; 113 public: 114 bool activateFieldWorkflow(CGarbageCollector& gc) ; 115 private: 116 bool activateFieldWorkflow_done_=false ; 117 111 118 private: 112 119 CGenericAlgorithmTransformation* transformationAlgorithm_ = nullptr ; -
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/field.cpp
r2203 r2206 327 327 CATCH 328 328 329 CDomain* CField::getAssociatedDomain(const string& domainId) const 330 { 331 if (grid_==nullptr) ERROR("CDomain* CField::getAssociatedDomain(const string& domainId)", <<" field with id="<<getId()<<" has no associated grid, " 329 CDomain* CField::getAssociatedDomain(const string& domainId, bool noError) const 330 { 331 if (grid_==nullptr) 332 { 333 if (noError) return nullptr ; 334 else ERROR("CDomain* CField::getAssociatedDomain(const string& domainId)", <<" field with id="<<getId()<<" has no associated grid, " 332 335 <<"check if the worklfow is enabled for this field"); 333 grid_->getAssociatedDomain(domainId) ; 334 } 335 336 CAxis* CField::getAssociatedAxis(const string& axisId) const 337 { 338 if (grid_==nullptr) ERROR("CAxis* CField::getAssociatedAxis(const string& axisId)", <<" field with id="<<getId()<<" has no associated grid, " 336 } 337 return grid_->getAssociatedDomain(domainId, noError) ; 338 } 339 340 CAxis* CField::getAssociatedAxis(const string& axisId, bool noError) const 341 { 342 if (grid_==nullptr) 343 { 344 if (noError) return nullptr ; 345 else ERROR("CAxis* CField::getAssociatedAxis(const string& axisId)", <<" field with id="<<getId()<<" has no associated grid, " 339 346 <<"check if the worklfow is enabled for this field"); 340 grid_->getAssociatedAxis(axisId) ; 341 } 342 343 CScalar* CField::getAssociatedScalar(const string& scalarId) const 344 { 345 if (grid_==nullptr) ERROR("CScalar* CField::getAssociatedScalar(const string& scalarId)", <<" field with id="<<getId()<<" has no associated grid, " 347 } 348 return grid_->getAssociatedAxis(axisId, noError) ; 349 } 350 351 CScalar* CField::getAssociatedScalar(const string& scalarId, bool noError) const 352 { 353 if (grid_==nullptr) 354 { 355 if (noError) return nullptr ; 356 else ERROR("CScalar* CField::getAssociatedScalar(const string& scalarId)", <<" field with id="<<getId()<<" has no associated grid, " 346 357 <<"check if the worklfow is enabled for this field"); 347 grid_->getAssociatedScalar(scalarId) ; 358 } 359 return grid_->getAssociatedScalar(scalarId, noError) ; 348 360 } 349 361 … … 618 630 solveGridReference() ; // grid_ is now defined 619 631 if (!isGridCompleted()) return false; 632 if (grid_->activateFieldWorkflow(gc)==false) return false; // workflow graph cannot be built at this stage 620 633 621 634 // Check if we have an expression to parse … … 1181 1194 if (!domain_ref.isEmpty()) 1182 1195 { 1183 StdString tmp = domain_ref.getValue(); 1196 CField* field=CDomain::getFieldFromId(domain_ref) ; 1197 if (field!=nullptr) field->solveGridReference() ; 1184 1198 if (CDomain::has(domain_ref)) 1185 1199 { … … 1195 1209 if (!axis_ref.isEmpty()) 1196 1210 { 1211 CField* field=CAxis::getFieldFromId(axis_ref) ; 1212 if (field!=nullptr) field->solveGridReference() ; 1197 1213 if (CAxis::has(axis_ref)) 1198 1214 { … … 1208 1224 if (!scalar_ref.isEmpty()) 1209 1225 { 1226 CField* field=CScalar::getFieldFromId(scalar_ref) ; 1227 if (field!=nullptr) field->solveGridReference() ; 1210 1228 if (CScalar::has(scalar_ref)) 1211 1229 { -
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/field.hpp
r2203 r2206 104 104 CGrid* getRelGrid(void) const; 105 105 CFile* getRelFile(void) const; 106 CDomain* getAssociatedDomain(const std::string& domainId ) const;107 CAxis* getAssociatedAxis(const std::string& axisId ) const;108 CScalar* getAssociatedScalar(const std::string& scalarId ) const;106 CDomain* getAssociatedDomain(const std::string& domainId, bool noError=false) const; 107 CAxis* getAssociatedAxis(const std::string& axisId, bool noError=false) const; 108 CScalar* getAssociatedScalar(const std::string& scalarId, bool noError=false) const; 109 109 110 110 func::CFunctor::ETimeType getOperationTimeType() const; -
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/grid.cpp
r2203 r2206 400 400 CATCH_DUMP_ATTR 401 401 402 CDomain* CGrid::getAssociatedDomain(const string& domainId )402 CDomain* CGrid::getAssociatedDomain(const string& domainId, bool noError) 403 403 { 404 404 const regex r("\\[[0-9]*\\]"); … … 413 413 } 414 414 std::vector<CDomain*> domainList = this->getDomains(); 415 if (domainList.empty()) ERROR("CGrid::getAssociatedDomain(const string& domainId)", <<"no domain is compsing the grid"); 415 if (domainList.empty()) 416 if (noError) return nullptr ; 417 else ERROR("CGrid::getAssociatedDomain(const string& domainId)", <<"no domain is composing the grid"); 416 418 if (id.empty()) 417 419 { … … 419 421 { 420 422 if (domainList.size()==1) return domainList[0] ; 421 else ERROR("CGrid::getAssociatedDomain(const string& domainId)", <<"the grid contain more than 1 domain, use [#n] to specify which one must be retrieved"); 423 else 424 if (noError) return nullptr ; 425 else ERROR("CGrid::getAssociatedDomain(const string& domainId)", <<"the grid contain more than 1 domain, use [#n] to specify which one must be retrieved"); 422 426 } 423 427 else 424 428 { 425 429 if (domainList.size()>pos) return domainList[pos] ; 430 else if (noError) return nullptr ; 426 431 else ERROR("CGrid::getAssociatedDomain(const string& domainId)", <<"the position of the requested domain [ pos = "<<pos 427 432 <<" ] is greater than the number of domain composing the grid [ numDomain = "<<domainList.size()<<" ]"); … … 434 439 int nbDomain=0 ; 435 440 for(int i=0; i<domainList.size();i++) if (domainList[i]->getTemplateId()==id) nbDomain++ ; 436 if (nbDomain>1) ERROR("CGrid::getAssociatedDomain(const string& domainId)", <<"no domain with the id = "<<id 441 if (nbDomain>1) 442 if (noError) return nullptr ; 443 else ERROR("CGrid::getAssociatedDomain(const string& domainId)", <<"no domain with the id = "<<id 437 444 <<" is composing the grid") ; 438 if (nbDomain==0) ERROR("CGrid::getAssociatedDomain(const string& domainId)", <<"the grid contain more than 1 domain with the id = " 445 if (nbDomain==0) 446 if (noError) return nullptr ; 447 else ERROR("CGrid::getAssociatedDomain(const string& domainId)", <<"the grid contain more than 1 domain with the id = " 439 448 <<id<<" , use [#n] to specify which one must be retrieved") ; 440 449 for(int i=0; i<domainList.size();i++) if (domainList[i]->getTemplateId()==id) return domainList[i] ; … … 448 457 currentPos++ ; 449 458 } 450 ERROR("CGrid::getAssociatedDomain(const string& domainId)",<<"Cannot find domain with [ id = "<< id <<" ] at [ pos = "<<pos<<" ] in the grid"); 459 if (noError) return nullptr ; 460 else ERROR("CGrid::getAssociatedDomain(const string& domainId)",<<"Cannot find domain with [ id = "<< id <<" ] at [ pos = "<<pos<<" ] in the grid"); 451 461 } 452 462 } 453 463 } 454 464 455 CAxis* CGrid::getAssociatedAxis(const string& axisId )465 CAxis* CGrid::getAssociatedAxis(const string& axisId, bool noError) 456 466 { 457 467 const regex r("\\[[0-9]*\\]"); … … 466 476 } 467 477 std::vector<CAxis*> axisList = this->getAxis(); 468 if (axisList.empty()) ERROR("CGrid::getAssociatedAxis(const string& AxisId)", <<"no axis is composing the grid"); 478 if (axisList.empty()) 479 if (noError) return nullptr; 480 else ERROR("CGrid::getAssociatedAxis(const string& AxisId)", <<"no axis is composing the grid"); 469 481 if (id.empty()) 470 482 { … … 472 484 { 473 485 if (axisList.size()==1) return axisList[0] ; 474 else ERROR("CGrid::getAssociatedAxis(const string& axisId)", <<"the grid contain more than 1 axis, use [#n] to specify which one must be retrieved"); 486 else 487 if (noError) return nullptr; 488 else ERROR("CGrid::getAssociatedAxis(const string& axisId)", <<"the grid contain more than 1 axis, use [#n] to specify which one must be retrieved"); 475 489 } 476 490 else 477 491 { 478 492 if (axisList.size()>pos) return axisList[pos] ; 479 else ERROR("CGrid::getAssociatedAxis(const string& axisId)", <<"the position of the requested axis [ pos = "<<pos 493 else 494 if (noError) return nullptr; 495 else ERROR("CGrid::getAssociatedAxis(const string& axisId)", <<"the position of the requested axis [ pos = "<<pos 480 496 <<" ] is greater than the number of axis composing the grid [ numAxis = "<<axisList.size()<<" ]"); 481 497 } … … 487 503 int nbAxis=0 ; 488 504 for(int i=0; i<axisList.size();i++) if (axisList[i]->getTemplateId()==id) nbAxis++ ; 489 if (nbAxis>1) ERROR("CGrid::getAssociatedAxis(const string& axisId)", <<"no axis with the id = "<<id 505 if (nbAxis>1) 506 if (noError) return nullptr; 507 else ERROR("CGrid::getAssociatedAxis(const string& axisId)", <<"no axis with the id = "<<id 490 508 <<" is composing the grid") ; 491 if (nbAxis==0) ERROR("CGrid::getAssociatedAxis(const string& axisId)", <<"the grid contain more than 1 axis with the id = " 509 if (nbAxis==0) 510 if (noError) return nullptr; 511 else ERROR("CGrid::getAssociatedAxis(const string& axisId)", <<"the grid contain more than 1 axis with the id = " 492 512 <<id<<" , use [#n] to specify which one must be retrieved") ; 493 513 for(int i=0; i<axisList.size();i++) if (axisList[i]->getTemplateId()==id) return axisList[i] ; … … 501 521 currentPos++ ; 502 522 } 503 ERROR("CGrid::getAssociatedAxis(const string& axisId)",<<"Cannot find axis with [ id = "<< id <<" ] at [ pos = "<<pos<<" ] in the grid"); 523 if (noError) return nullptr; 524 else ERROR("CGrid::getAssociatedAxis(const string& axisId)",<<"Cannot find axis with [ id = "<< id <<" ] at [ pos = "<<pos<<" ] in the grid"); 504 525 } 505 526 } 506 527 } 507 528 508 CScalar* CGrid::getAssociatedScalar(const string& scalarId )529 CScalar* CGrid::getAssociatedScalar(const string& scalarId, bool noError) 509 530 { 510 531 const regex r("\\[[0-9]*\\]"); … … 519 540 } 520 541 std::vector<CScalar*> scalarList = this->getScalars(); 521 if (scalarList.empty()) ERROR("CGrid::getAssociatedScalar(const string& scalarId)", <<"no scalar is composing the grid"); 542 if (scalarList.empty()) 543 if (noError) return nullptr; 544 else ERROR("CGrid::getAssociatedScalar(const string& scalarId)", <<"no scalar is composing the grid"); 522 545 if (id.empty()) 523 546 { … … 525 548 { 526 549 if (scalarList.size()==1) return scalarList[0] ; 527 else ERROR("CGrid::getAssociatedScalar(const string& scalarId)", <<"the grid contain more than 1 scalar, use [#n] to specify which one must be retrieved"); 550 else 551 if (noError) return nullptr; 552 else ERROR("CGrid::getAssociatedScalar(const string& scalarId)", <<"the grid contain more than 1 scalar, use [#n] to specify which one must be retrieved"); 528 553 } 529 554 else 530 555 { 531 556 if (scalarList.size()>pos) return scalarList[pos] ; 532 else ERROR("CGrid::getAssociatedScalar(const string& scalarId)", <<"the position of the requested scalar [ pos = "<<pos 557 else 558 if (noError) return nullptr; 559 else ERROR("CGrid::getAssociatedScalar(const string& scalarId)", <<"the position of the requested scalar [ pos = "<<pos 533 560 <<" ] is greater than the number of scalar composing the grid [ numScalar = "<<scalarList.size()<<" ]"); 534 561 } … … 540 567 int nbScalar=0 ; 541 568 for(int i=0; i<scalarList.size();i++) if (scalarList[i]->getTemplateId()==id) nbScalar++ ; 542 if (nbScalar>1) ERROR("CGrid::getAssociatedScalar(const string& scalarId)", <<"no scalar with the id = "<<id 569 if (nbScalar>1) 570 if (noError) return nullptr; 571 else ERROR("CGrid::getAssociatedScalar(const string& scalarId)", <<"no scalar with the id = "<<id 543 572 <<" is composing the grid") ; 544 if (nbScalar==0) ERROR("CGrid::getAssociatedScalar(const string& scalarId)", <<"the grid contain more than 1 scalar with the id = " 573 if (nbScalar==0) 574 if (noError) return nullptr; 575 else ERROR("CGrid::getAssociatedScalar(const string& scalarId)", <<"the grid contain more than 1 scalar with the id = " 545 576 <<id<<" , use [#n] to specify which one must be retrieved") ; 546 577 for(int i=0; i<scalarList.size();i++) if (scalarList[i]->getTemplateId()==id) return scalarList[i] ; … … 554 585 currentPos++ ; 555 586 } 556 ERROR("CGrid::getAssociatedScalar(const string& scalarId)",<<"Cannot find scalar with [ id = "<< id <<" ] at [ pos = "<<pos<<" ] in the grid"); 587 if (noError) return nullptr; 588 else ERROR("CGrid::getAssociatedScalar(const string& scalarId)",<<"Cannot find scalar with [ id = "<< id <<" ] at [ pos = "<<pos<<" ] in the grid"); 557 589 } 558 590 } … … 1774 1806 pScalar->solveInheritanceTransformation(); 1775 1807 } 1808 } 1809 CATCH_DUMP_ATTR 1810 1811 bool CGrid::activateFieldWorkflow(CGarbageCollector& gc) 1812 TRY 1813 { 1814 setDomainList(); 1815 for (auto domainId : domList_) 1816 { 1817 CDomain* pDom = CDomain::get(domainId); 1818 bool ret = pDom->activateFieldWorkflow(gc); 1819 if (!ret) return false ; 1820 } 1821 1822 setAxisList(); 1823 for (auto axisId : axisList_) 1824 { 1825 CAxis* pAxis = CAxis::get(axisId); 1826 bool ret = pAxis->activateFieldWorkflow(gc); 1827 if (!ret) return false ; 1828 } 1829 1830 setScalarList(); 1831 for (auto scalarId : scalarList_) 1832 { 1833 CScalar* pScalar = CScalar::get(scalarId); 1834 bool ret = pScalar->activateFieldWorkflow(gc); 1835 if (!ret) return false ; 1836 } 1837 return true ; 1776 1838 } 1777 1839 CATCH_DUMP_ATTR -
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/grid.hpp
r2203 r2206 147 147 static CGrid* cloneGrid(const StdString& idNewGrid, CGrid* gridSrc); 148 148 149 CDomain* getAssociatedDomain(const string& domainId ) ;150 CAxis* getAssociatedAxis(const string& axisId ) ;151 CScalar* getAssociatedScalar(const string& scalarId ) ;149 CDomain* getAssociatedDomain(const string& domainId, bool noError=false) ; 150 CAxis* getAssociatedAxis(const string& axisId, bool noError=false) ; 151 CScalar* getAssociatedScalar(const string& scalarId, bool noError=false) ; 152 152 public: 153 153 void solveDomainAxisRef(bool areAttributesChecked); … … 158 158 void solveScalarRef(bool checkAtt); 159 159 void solveElementsRefInheritance(bool apply = true); 160 bool activateFieldWorkflow(CGarbageCollector& gc) ; 160 161 // void solveTransformations(); 161 162 void solveDomainAxisBaseRef(); -
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/scalar.cpp
r2203 r2206 53 53 } 54 54 55 CScalar* CScalar::get(const string& id )55 CScalar* CScalar::get(const string& id, bool noError) 56 56 { 57 57 const regex r("::"); … … 63 63 if (fieldId.empty()) ERROR("CScalar* CScalar::get(string& id)", <<" id = "<<id<< " -> bad format id, field name is empty"); 64 64 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"); 65 68 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 } 70 99 71 100 bool CScalar::IsWritten(const StdString & filename) const … … 210 239 } 211 240 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 212 266 213 267 /* obsolete, to remove after reimplementing coupling */ -
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/scalar.hpp
r2203 r2206 29 29 class CScalarAttributes; 30 30 class CScalar; 31 class CField; 31 32 ///-------------------------------------------------------------- 32 33 … … 78 79 public: 79 80 static CScalar* createScalar(); 80 static CScalar* get(const string& id) ; //<! return scalar pointer using id 81 static CScalar* get(const string& id, bool noError=false) ; //<! return scalar pointer using id 82 static bool has(const string& id) ; //<! return domain pointer using id 83 static CField* getFieldFromId(const string& id) ; 81 84 82 85 public: … … 118 121 private: 119 122 bool solveInheritanceTransformation_done_= false ; 123 public: 124 bool activateFieldWorkflow(CGarbageCollector& gc) ; 125 private: 126 bool activateFieldWorkflow_done_=false ; 120 127 private: 121 128 CGenericAlgorithmTransformation* transformationAlgorithm_ = nullptr ;
Note: See TracChangeset
for help on using the changeset viewer.