Changeset 472 for XIOS/trunk/src/node/file.cpp
- Timestamp:
- 02/03/14 14:16:20 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/node/file.cpp
r459 r472 24 24 : CObjectTemplate<CFile>(), CFileAttributes() 25 25 , vFieldGroup(), data_out(), enabledFields(), fileComm(MPI_COMM_NULL) 26 { setVirtualFieldGroup() ;} 26 { 27 setVirtualFieldGroup() ; 28 setVirtualVariableGroup() ; 29 } 27 30 28 31 CFile::CFile(const StdString & id) 29 32 : CObjectTemplate<CFile>(id), CFileAttributes() 30 33 , vFieldGroup(), data_out(), enabledFields(), fileComm(MPI_COMM_NULL) 31 { setVirtualFieldGroup() ;} 34 { 35 setVirtualFieldGroup() ; 36 setVirtualVariableGroup() ; 37 } 32 38 33 39 CFile::~CFile(void) … … 52 58 } 53 59 60 CVariableGroup* CFile::getVirtualVariableGroup(void) const 61 { 62 return (this->vVariableGroup); 63 } 64 54 65 std::vector<CField*> CFile::getAllFields(void) const 55 66 { 56 67 return (this->vFieldGroup->getAllChildren()); 68 } 69 70 std::vector<CVariable*> CFile::getAllVariables(void) const 71 { 72 return (this->vVariableGroup->getAllChildren()); 57 73 } 58 74 … … 120 136 } 121 137 138 void CFile::setVirtualVariableGroup(CVariableGroup* newVVariableGroup) 139 { 140 this->vVariableGroup = newVVariableGroup; 141 } 142 122 143 //---------------------------------------------------------------- 123 144 … … 125 146 { 126 147 this->setVirtualFieldGroup(CFieldGroup::create()); 148 } 149 150 void CFile::setVirtualVariableGroup(void) 151 { 152 this->setVirtualVariableGroup(CVariableGroup::create()); 127 153 } 128 154 … … 313 339 } 314 340 341 vector<CVariable*> listVars = getAllVariables() ; 342 for (vector<CVariable*>::iterator it = listVars.begin() ;it != listVars.end(); it++) this-> data_out-> writeAttribute(*it) ; 343 315 344 this->data_out->definition_end(); 316 345 } … … 333 362 { 334 363 SuperClass::parse(node); 335 if (node.goToChildElement() & this->hasId()) 336 { // Si la définition du fichier intégre des champs et si le fichier est identifié. 337 node.goToParentElement(); 338 // this->setVirtualFieldGroup(this->getId()); 339 this->getVirtualFieldGroup()->parse(node, false); 340 } 364 365 if (node.goToChildElement()) 366 { 367 do 368 { 369 if (node.getElementName()=="field" || node.getElementName()=="field_group") this->getVirtualFieldGroup()->parseChild(node); 370 else if (node.getElementName()=="variable" || node.getElementName()=="variable_group") this->getVirtualVariableGroup()->parseChild(node); 371 } while (node.goToNextElement()) ; 372 node.goToParentElement(); 373 } 374 341 375 } 342 376 //---------------------------------------------------------------- … … 361 395 { 362 396 SuperClassAttribute::setAttributes(parent,apply); 363 this->getVirtualFieldGroup()->solveDescInheritance(apply, NULL); 397 this->getVirtualFieldGroup()->solveDescInheritance(apply, NULL); 398 this->getVirtualVariableGroup()->solveDescInheritance(apply, NULL); 364 399 } 365 400 … … 422 457 { 423 458 return vFieldGroup->createChildGroup(id) ; 459 } 460 461 CVariable* CFile::addVariable(const string& id) 462 { 463 return vVariableGroup->createChild(id) ; 464 } 465 466 CVariableGroup* CFile::addVariableGroup(const string& id) 467 { 468 return vVariableGroup->createChildGroup(id) ; 424 469 } 425 470 … … 502 547 } 503 548 549 550 551 552 553 554 555 556 557 558 559 void CFile::sendAddVariable(const string& id) 560 { 561 CContext* context=CContext::getCurrent() ; 562 563 if (! context->hasServer ) 564 { 565 CContextClient* client=context->client ; 566 567 CEventClient event(this->getType(),EVENT_ID_ADD_VARIABLE) ; 568 if (client->isServerLeader()) 569 { 570 CMessage msg ; 571 msg<<this->getId() ; 572 msg<<id ; 573 event.push(client->getServerLeader(),1,msg) ; 574 client->sendEvent(event) ; 575 } 576 else client->sendEvent(event) ; 577 } 578 579 } 580 581 void CFile::sendAddVariableGroup(const string& id) 582 { 583 CContext* context=CContext::getCurrent() ; 584 if (! context->hasServer ) 585 { 586 CContextClient* client=context->client ; 587 588 CEventClient event(this->getType(),EVENT_ID_ADD_VARIABLE_GROUP) ; 589 if (client->isServerLeader()) 590 { 591 CMessage msg ; 592 msg<<this->getId() ; 593 msg<<id ; 594 event.push(client->getServerLeader(),1,msg) ; 595 client->sendEvent(event) ; 596 } 597 else client->sendEvent(event) ; 598 } 599 600 } 601 602 void CFile::recvAddVariable(CEventServer& event) 603 { 604 605 CBufferIn* buffer=event.subEvents.begin()->buffer; 606 string id; 607 *buffer>>id ; 608 get(id)->recvAddVariable(*buffer) ; 609 } 610 611 612 void CFile::recvAddVariable(CBufferIn& buffer) 613 { 614 string id ; 615 buffer>>id ; 616 addVariable(id) ; 617 } 618 619 void CFile::recvAddVariableGroup(CEventServer& event) 620 { 621 622 CBufferIn* buffer=event.subEvents.begin()->buffer; 623 string id; 624 *buffer>>id ; 625 get(id)->recvAddVariableGroup(*buffer) ; 626 } 627 628 629 void CFile::recvAddVariableGroup(CBufferIn& buffer) 630 { 631 string id ; 632 buffer>>id ; 633 addVariableGroup(id) ; 634 } 635 636 637 638 504 639 505 640 bool CFile::dispatchEvent(CEventServer& event) … … 519 654 return true ; 520 655 break ; 656 657 case EVENT_ID_ADD_VARIABLE : 658 recvAddVariable(event) ; 659 return true ; 660 break ; 521 661 662 case EVENT_ID_ADD_VARIABLE_GROUP : 663 recvAddVariableGroup(event) ; 664 return true ; 665 break ; 522 666 default : 523 667 ERROR("bool CFile::dispatchEvent(CEventServer& event)", <<"Unknown Event") ;
Note: See TracChangeset
for help on using the changeset viewer.