Changeset 459 for XIOS/trunk/src/node/field.cpp
- Timestamp:
- 01/16/14 14:28:23 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/node/field.cpp
r449 r459 11 11 #include "type.hpp" 12 12 #include "context_client.hpp" 13 #include <set> 13 14 14 15 namespace xios{ … … 23 24 , nstep(0) 24 25 , last_Write(), last_operation() 25 , foperation() 26 , foperation(), hasInstantData(false), hasExpression(false) 27 , active(false) , hasOutputFile(false), slotUpdateDate(NULL) 28 , processed(false) 26 29 { /* Ne rien faire de plus */ } 27 30 … … 33 36 , nstep(0) 34 37 , last_Write(), last_operation() 35 , foperation() 38 , foperation(), hasExpression(false) 39 , active(false), hasOutputFile(false), slotUpdateDate(NULL) 40 , processed(false) 36 41 { /* Ne rien faire de plus */ } 37 42 … … 41 46 // this->file.reset() ; 42 47 this->foperation.reset() ; 48 if (hasExpression) delete expression ; 49 if (slotUpdateDate!=NULL) delete slotUpdateDate ; 50 43 51 } 44 52 … … 199 207 void CField::setRelFile(CFile* _file) 200 208 { 201 this->file = _file; 209 this->file = _file; 210 hasOutputFile=true ; 202 211 } 203 212 … … 327 336 //---------------------------------------------------------------- 328 337 338 void CField::processEnabledField(void) 339 { 340 if (!processed) 341 { 342 processed=true ; 343 solveRefInheritance(true) ; 344 solveOperation() ; 345 solveGridReference() ; 346 347 if (hasDirectFieldReference()) baseRefObject->processEnabledField() ; 348 buildExpression(); 349 active=true; 350 } 351 } 352 329 353 void CField::solveRefInheritance(bool apply) 330 354 { … … 333 357 CField * refer_ptr = this; 334 358 335 this->baseRefObject = CField::get(this); 359 if (this->hasDirectFieldReference()) baseRefObject = getDirectFieldReference(); 360 else baseRefObject = CField::get(this); 336 361 337 362 while (refer_ptr->hasDirectFieldReference()) … … 349 374 SuperClassAttribute::setAttributes(refer_ptr, apply); 350 375 sset.insert(refer_ptr); 351 baseRefObject = refer_sptr;376 //ym baseRefObject = refer_sptr; 352 377 //ym refObject.push_back(refer_sptr); 353 378 } 379 380 if (hasDirectFieldReference()) baseRefObject->addReference(this) ; 354 381 } 355 382 … … 359 386 { 360 387 using namespace func; 361 362 StdString id = this->getBaseFieldReference()->getId(); 388 389 if (!hasOutputFile) return ; 390 391 StdString id ; 392 if (hasId()) id=getId(); 393 else if (!name.isEmpty()) id=name ; 394 else if (hasDirectFieldReference()) id=baseRefObject->getId() ; 395 363 396 CContext* context = CContext::getCurrent(); 364 397 365 398 if (freq_op.isEmpty()) freq_op=string("1ts") ; 366 399 367 if (operation.isEmpty() || this->file->output_freq.isEmpty())400 if (operation.isEmpty() ) 368 401 { 369 402 ERROR("CField::solveOperation(void)", … … 548 581 549 582 grid->solveReference() ; 583 550 584 } 551 585 … … 598 632 ///------------------------------------------------------------------- 599 633 634 void CField::parse(xml::CXMLNode & node) 635 { 636 SuperClass::parse(node); 637 node.getContent(this->content) ; 638 } 639 640 CArray<double,1>* CField::getInstantData(void) 641 { 642 if (!hasInstantData) 643 { 644 instantData.resize(grid->storeIndex_client.numElements()) ; 645 hasInstantData=true ; 646 } 647 return &instantData ; 648 } 649 650 void CField::addReference(CField* field) 651 { 652 refObject.push_back(field) ; 653 } 654 655 void CField::addDependency(CField* field, int slotId) 656 { 657 fieldDependency.push_back(pair<CField*,int>(field,slotId)) ; 658 } 659 660 void CField::buildExpression(void) 661 { 662 if (content.size() > 0) 663 { 664 CSimpleNodeExpr* simpleExpr=parseExpr(content+'\0') ; 665 expression=CFieldNode::newNode(simpleExpr) ; 666 delete simpleExpr ; 667 set<string> fieldIds ; 668 expression->getFieldIds(fieldIds) ; 669 for (set<string>::iterator it=fieldIds.begin() ; it!=fieldIds.end();++it) if (*it!="this") CField::get(*it)->processEnabledField() ; 670 671 expression->reduce(this) ; 672 673 slots.resize(fieldIds.size()) ; 674 resetSlots() ; 675 int slotId=0 ; 676 set<CField*> fields ; 677 expression->getFields(fields) ; 678 for (set<CField*>::iterator it=fields.begin() ; it!=fields.end();++it,++slotId) (*it)->addDependency(this,slotId) ; 679 hasExpression=true; 680 } 681 } 682 683 void CField::resetSlots(void) 684 { 685 for(vector<bool>::iterator it=slots.begin();it!=slots.end();++it) *it=false ; 686 } 687 688 bool CField::slotsFull(void) 689 { 690 bool ret=true ; 691 for(vector<bool>::iterator it=slots.begin();it!=slots.end();++it) ret &= *it; 692 return ret ; 693 } 694 695 696 void CField::setSlot(int slotId) 697 { 698 CContext* context = CContext::getCurrent() ; 699 const CDate & currDate = context->getCalendar()->getCurrentDate(); 700 if (slotUpdateDate==NULL || currDate!=*slotUpdateDate) 701 { 702 resetSlots() ; 703 if (slotUpdateDate==NULL) slotUpdateDate=new CDate(currDate) ; 704 else *slotUpdateDate=currDate ; 705 } 706 slots[slotId]=true ; 707 if (slotsFull()) 708 { 709 CArray<double,1> expr(expression->compute()) ; 710 711 if (hasInstantData) 712 { 713 instantData=expr ; 714 for(list< pair<CField *,int> >::iterator it=fieldDependency.begin(); it!=fieldDependency.end(); ++it) 715 if (it->first!=this) it->first->setSlot(it->second) ; 716 } 717 718 if (hasOutputFile) updateDataFromExpression(expr) ; 719 720 } 721 } 722 600 723 } // namespace xios
Note: See TracChangeset
for help on using the changeset viewer.