Changeset 509 for XIOS/trunk/src/node/context.cpp
- Timestamp:
- 11/13/14 15:09:14 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/node/context.cpp
r501 r509 16 16 17 17 namespace xios { 18 18 19 19 shared_ptr<CContextGroup> CContext::root ; 20 20 21 21 /// ////////////////////// Définitions ////////////////////// /// 22 22 23 23 CContext::CContext(void) 24 24 : CObjectTemplate<CContext>(), CContextAttributes() 25 , calendar(),hasClient(false),hasServer(false) 25 , calendar(),hasClient(false),hasServer(false), isPostProcessed(false), dataSize_() 26 26 { /* Ne rien faire de plus */ } 27 27 28 28 CContext::CContext(const StdString & id) 29 29 : CObjectTemplate<CContext>(id), CContextAttributes() 30 , calendar(),hasClient(false),hasServer(false) 30 , calendar(),hasClient(false),hasServer(false), isPostProcessed(false), dataSize_() 31 31 { /* Ne rien faire de plus */ } 32 32 33 33 CContext::~CContext(void) 34 { 34 { 35 35 if (hasClient) delete client ; 36 36 if (hasServer) delete server ; … … 38 38 39 39 //---------------------------------------------------------------- 40 40 //! Get name of context 41 41 StdString CContext::GetName(void) { return (StdString("context")); } 42 42 StdString CContext::GetDefName(void){ return (CContext::GetName()); } … … 44 44 45 45 //---------------------------------------------------------------- 46 46 /*! 47 \brief Get context group (context root) 48 \return Context root 49 */ 47 50 CContextGroup* CContext::getRoot(void) 48 { 51 { 49 52 if (root.get()==NULL) root=shared_ptr<CContextGroup>(new CContextGroup(xml::CXMLNode::GetRootName())) ; 50 return root.get(); 51 } 52 53 54 //---------------------------------------------------------------- 55 53 return root.get(); 54 } 55 56 57 //---------------------------------------------------------------- 58 /*! 59 \brief Get calendar of a context 60 \return Calendar 61 */ 56 62 boost::shared_ptr<CCalendar> CContext::getCalendar(void) const 57 63 { 58 64 return (this->calendar); 59 65 } 60 61 //---------------------------------------------------------------- 62 66 67 //---------------------------------------------------------------- 68 /*! 69 \brief Set a context with a calendar 70 \param[in] newCalendar new calendar 71 */ 63 72 void CContext::setCalendar(boost::shared_ptr<CCalendar> newCalendar) 64 73 { … … 67 76 start_date.setValue(this->calendar->getInitDate().toString()); 68 77 } 69 70 //---------------------------------------------------------------- 71 78 79 //---------------------------------------------------------------- 80 //! Process all information of calendar 72 81 void CContext::solveCalendar(void) 73 82 { … … 97 106 << "The calendar is not defined !"); 98 107 } 99 100 //---------------------------------------------------------------- 101 108 109 //---------------------------------------------------------------- 110 /*! 111 \brief Parse xml file and write information into context object 112 \param [in] node xmld node corresponding in xml file 113 */ 102 114 void CContext::parse(xml::CXMLNode & node) 103 115 { … … 135 147 136 148 if (attributes.end() != attributes.find("id")) 137 { DEBUG(<< "Definition node has an id," 138 << "it will not be taking account !"); } 149 { 150 DEBUG(<< "Definition node has an id," 151 << "it will not be taking account !"); 152 } 139 153 140 154 #define DECLARE_NODE(Name_, name_) \ … … 155 169 156 170 //---------------------------------------------------------------- 157 171 //! Show tree structure of context 158 172 void CContext::ShowTree(StdOStream & out) 159 173 { … … 166 180 out << "<? xml version=\"1.0\" ?>" << std::endl; 167 181 out << "<" << xml::CXMLNode::GetRootName() << " >" << std::endl; 168 182 169 183 for (; it != end; it++) 170 184 { 171 CContext* context = *it; 172 CContext::setCurrent(context->getId()); 185 CContext* context = *it; 186 CContext::setCurrent(context->getId()); 173 187 out << *context << std::endl; 174 188 } 175 189 176 190 out << "</" << xml::CXMLNode::GetRootName() << " >" << std::endl; 177 CContext::setCurrent(currentContextId); 178 } 179 180 181 //---------------------------------------------------------------- 182 191 CContext::setCurrent(currentContextId); 192 } 193 194 195 //---------------------------------------------------------------- 196 197 //! Convert context object into string (to print) 183 198 StdString CContext::toString(void) const 184 199 { … … 209 224 //---------------------------------------------------------------- 210 225 226 /*! 227 \brief Find all inheritace among objects in a context. 228 \param [in] apply (true) write attributes of parent into ones of child if they are empty 229 (false) write attributes of parent into a new container of child 230 \param [in] parent unused 231 */ 211 232 void CContext::solveDescInheritance(bool apply, const CAttributeMap * const UNUSED(parent)) 212 233 { … … 220 241 //---------------------------------------------------------------- 221 242 243 //! Verify if all root definition in the context have child. 222 244 bool CContext::hasChild(void) const 223 245 { … … 230 252 } 231 253 232 //----------------------------------------------------------------233 234 void CContext::solveFieldRefInheritance(bool apply)235 {236 if (!this->hasId()) return;237 vector<CField*> allField = CField::getAll() ;238 // = CObjectTemplate<CField>::GetAllVectobject(this->getId());239 std::vector<CField*>::iterator 240 it = allField.begin(), end = allField.end();241 242 for (; it != end; it++)243 {244 CField* field = *it;245 field->solveRefInheritance(apply);246 }247 }254 // //---------------------------------------------------------------- 255 // 256 // void CContext::solveFieldRefInheritance(bool apply) 257 // { 258 // if (!this->hasId()) return; 259 // vector<CField*> allField = CField::getAll() ; 260 //// = CObjectTemplate<CField>::GetAllVectobject(this->getId()); 261 // std::vector<CField*>::iterator 262 // it = allField.begin(), end = allField.end(); 263 // 264 // for (; it != end; it++) 265 // { 266 // CField* field = *it; 267 // field->solveRefInheritance(apply); 268 // } 269 // } 248 270 249 271 //---------------------------------------------------------------- … … 256 278 } 257 279 ///--------------------------------------------------------------- 258 280 281 //! Initialize client side 259 282 void CContext::initClient(MPI_Comm intraComm, MPI_Comm interComm) 260 283 { 261 284 hasClient=true ; 262 285 client = new CContextClient(this,intraComm, interComm) ; 263 } 264 286 } 287 288 void CContext::setClientServerBuffer() 289 { 290 if (hasClient) 291 { 292 client->setBufferSize(getDataSize()); 293 } 294 } 295 296 //! Verify whether a context is initialized 265 297 bool CContext::isInitialized(void) 266 298 { 267 299 return hasClient ; 268 300 } 269 301 302 //! Initialize server 270 303 void CContext::initServer(MPI_Comm intraComm,MPI_Comm interComm) 271 304 { 272 305 hasServer=true ; 273 306 server = new CContextServer(this,intraComm,interComm) ; 274 } 275 307 } 308 309 //! Server side: Put server into a loop in order to listen message from client 276 310 bool CContext::eventLoop(void) 277 311 { 278 312 return server->eventLoop() ; 279 } 280 313 } 314 315 //! Terminate a context 281 316 void CContext::finalize(void) 282 317 { … … 290 325 } 291 326 } 292 293 294 295 327 328 /*! 329 \brief Close all the context defintion and do processing data 330 After everything is well defined on client side, they will be processed and sent to server 331 From the version 2.0, sever and client work no more on the same database. Moreover, client(s) will send 332 all necessary information to server, from which each server can build its own database. 333 Because the role of server is to write out field data on a specific netcdf file, 334 the only information that it needs is the enabled files 335 and the active fields (fields will be written onto active files) 336 */ 296 337 void CContext::closeDefinition(void) 297 338 { 298 if (hasClient && !hasServer) sendCloseDefinition() ; 299 300 solveCalendar(); 301 302 // Résolution des héritages pour le context actuel. 303 this->solveAllInheritance(); 304 305 //Initialisation du vecteur 'enabledFiles' contenant la liste des fichiers à sortir. 306 this->findEnabledFiles(); 307 308 309 this->processEnabledFiles() ; 310 311 /* 339 if (hasClient && !hasServer) 340 { 341 // After xml is parsed, there are some more works with post processing 342 postProcessing(); 343 344 setClientServerBuffer(); 345 346 // Send all attributes of current context to server 347 this->sendAllAttributesToServer(); 348 349 // We have enough information to send to server 350 // First of all, send all enabled files 351 sendEnabledFiles(); 352 353 // Then, send all enabled fields 354 sendEnabledFields(); 355 356 // After that, send all grid (if any) 357 sendRefGrid(); 358 359 // At last, we have all info of domain and axis, then send them 360 sendRefDomainsAxis(); 361 } 362 363 // Now tell server that it can process all messages from client 364 if (hasClient && !hasServer) this->sendCloseDefinition(); 365 366 // We have a xml tree on the server side and now, it should be also processed 367 if (hasClient && !hasServer) sendPostProcessing(); 368 369 // There are some processings that should be done after all of above. For example: check mask or index 370 if (hasClient && !hasServer) 371 { 372 this->solveAllRefOfEnabledFields(true); 373 this->buildAllExpressionOfEnabledFields(); 374 } 375 376 // if (hasClient) 377 // { 378 // //solveCalendar(); 379 // 380 // // Résolution des héritages pour le context actuel. 381 //// this->solveAllInheritance(); 382 // 383 // 384 //// //Initialisation du vecteur 'enabledFiles' contenant la liste des fichiers à sortir. 385 //// this->findEnabledFiles(); 386 // 387 // this->processEnabledFiles() ; 388 // 389 // this->solveAllGridRef(); 390 // } 391 392 393 394 395 // solveCalendar(); 396 // 397 // // Résolution des héritages pour le context actuel. 398 // this->solveAllInheritance(); 399 // 400 // //Initialisation du vecteur 'enabledFiles' contenant la liste des fichiers à sortir. 401 // this->findEnabledFiles(); 402 // 403 // 404 // this->processEnabledFiles() ; 405 406 /* 312 407 //Recherche des champs à sortir (enable à true + niveau de sortie correct) 313 408 // pour chaque fichier précédemment listé. … … 324 419 */ 325 420 // Nettoyage de l'arborescence 326 CleanTree(); 421 if (hasClient && !hasServer) CleanTree(); // Only on client side?? 422 // if (hasClient) CleanTree(); 327 423 if (hasClient) sendCreateFileHeader() ; 328 424 } 329 425 330 426 void CContext::findAllEnabledFields(void) 331 427 { … … 333 429 (void)this->enabledFiles[i]->getEnabledFields(); 334 430 } 335 336 void CContext::processEnabledFiles(void) 337 { 338 for (unsigned int i = 0; i < this->enabledFiles.size(); i++) 339 this->enabledFiles[i]->processEnabledFile(); 340 } 341 342 343 void CContext::solveAllGridRef(void) 344 { 345 for (unsigned int i = 0; i < this->enabledFiles.size(); i++) 346 this->enabledFiles[i]->solveEFGridRef(); 347 } 348 349 void CContext::solveAllOperation(void) 350 { 351 for (unsigned int i = 0; i < this->enabledFiles.size(); i++) 352 this->enabledFiles[i]->solveEFOperation(); 353 } 354 355 void CContext::solveAllExpression(void) 356 { 357 for (unsigned int i = 0; i < this->enabledFiles.size(); i++) 358 this->enabledFiles[i]->solveEFExpression(); 359 } 360 431 432 // void CContext::processEnabledFiles(void) 433 // { 434 // for (unsigned int i = 0; i < this->enabledFiles.size(); i++) 435 // this->enabledFiles[i]->processEnabledFile(); 436 // } 437 438 439 void CContext::solveAllRefOfEnabledFields(bool sendToServer) 440 { 441 int size = this->enabledFiles.size(); 442 for (int i = 0; i < size; ++i) 443 { 444 this->enabledFiles[i]->solveAllRefOfEnabledFields(sendToServer); 445 } 446 } 447 448 void CContext::buildAllExpressionOfEnabledFields() 449 { 450 int size = this->enabledFiles.size(); 451 for (int i = 0; i < size; ++i) 452 { 453 this->enabledFiles[i]->buildAllExpressionOfEnabledFields(); 454 } 455 } 456 457 // void CContext::solveAllGridRef(void) 458 // { 459 // for (unsigned int i = 0; i < this->enabledFiles.size(); i++) 460 // this->enabledFiles[i]->solveEFGridRef(); 461 // } 462 // 463 // void CContext::solveAllOperation(void) 464 // { 465 // for (unsigned int i = 0; i < this->enabledFiles.size(); i++) 466 // this->enabledFiles[i]->solveEFOperation(); 467 // } 468 // 469 // void CContext::solveAllExpression(void) 470 // { 471 // for (unsigned int i = 0; i < this->enabledFiles.size(); i++) 472 // this->enabledFiles[i]->solveEFExpression(); 473 // } 474 361 475 void CContext::solveAllInheritance(bool apply) 362 476 { … … 368 482 const vector<CFile*> allFiles=CFile::getAll() ; 369 483 484 if (hasClient && !hasServer) 370 485 for (unsigned int i = 0; i < allFiles.size(); i++) 371 486 allFiles[i]->solveFieldRefInheritance(apply); … … 383 498 } 384 499 else enabledFiles.push_back(allFiles[i]); // otherwise true by default 385 500 386 501 387 502 if (enabledFiles.size() == 0) … … 394 509 std::vector<CFile*>::const_iterator 395 510 it = this->enabledFiles.begin(), end = this->enabledFiles.end(); 396 511 397 512 for (; it != end; it++) 398 513 { … … 401 516 } 402 517 } 403 518 519 /*! 520 \brief Dispatch event received from client 521 Whenever a message is received in buffer of server, it will be processed depending on 522 its event type. A new event type should be added in the switch list to make sure 523 it processed on server side. 524 \param [in] event: Received message 525 */ 404 526 bool CContext::dispatchEvent(CEventServer& event) 405 527 { 406 528 407 529 if (SuperClass::dispatchEvent(event)) return true ; 408 530 else … … 422 544 return true ; 423 545 break ; 546 case EVENT_ID_POST_PROCESS: 547 recvPostProcessing(event) ; 548 return true ; 549 break ; 424 550 default : 425 551 ERROR("bool CContext::dispatchEvent(CEventServer& event)", … … 429 555 } 430 556 } 431 557 558 //! Client side: Send a message to server to make it close 432 559 void CContext::sendCloseDefinition(void) 433 560 { 434 435 CEventClient event(getType(),EVENT_ID_CLOSE_DEFINITION) ; 561 CEventClient event(getType(),EVENT_ID_CLOSE_DEFINITION) ; 436 562 if (client->isServerLeader()) 437 563 { … … 443 569 else client->sendEvent(event) ; 444 570 } 445 571 572 //! Server side: Receive a message of client announcing a context close 446 573 void CContext::recvCloseDefinition(CEventServer& event) 447 574 { 448 575 449 576 CBufferIn* buffer=event.subEvents.begin()->buffer; 450 577 string id; 451 578 *buffer>>id ; 452 get(id)->closeDefinition() ; 453 } 454 579 get(id)->closeDefinition(); 580 } 581 582 //! Client side: Send a message to update calendar in each time step 455 583 void CContext::sendUpdateCalendar(int step) 456 584 { 457 585 if (!hasServer) 458 586 { 459 CEventClient event(getType(),EVENT_ID_UPDATE_CALENDAR) ; 587 CEventClient event(getType(),EVENT_ID_UPDATE_CALENDAR) ; 460 588 if (client->isServerLeader()) 461 589 { … … 468 596 } 469 597 } 470 598 599 //! Server side: Receive a message of client annoucing calendar update 471 600 void CContext::recvUpdateCalendar(CEventServer& event) 472 601 { 473 602 474 603 CBufferIn* buffer=event.subEvents.begin()->buffer; 475 604 string id; … … 477 606 get(id)->recvUpdateCalendar(*buffer) ; 478 607 } 479 608 609 //! Server side: Receive a message of client annoucing calendar update 480 610 void CContext::recvUpdateCalendar(CBufferIn& buffer) 481 611 { … … 484 614 updateCalendar(step) ; 485 615 } 486 616 617 //! Client side: Send a message to create header part of netcdf file 487 618 void CContext::sendCreateFileHeader(void) 488 619 { 489 490 CEventClient event(getType(),EVENT_ID_CREATE_FILE_HEADER) ; 620 CEventClient event(getType(),EVENT_ID_CREATE_FILE_HEADER) ; 491 621 if (client->isServerLeader()) 492 622 { … … 498 628 else client->sendEvent(event) ; 499 629 } 500 630 631 //! Server side: Receive a message of client annoucing the creation of header part of netcdf file 501 632 void CContext::recvCreateFileHeader(CEventServer& event) 502 633 { 503 504 634 CBufferIn* buffer=event.subEvents.begin()->buffer; 505 635 string id; … … 507 637 get(id)->recvCreateFileHeader(*buffer) ; 508 638 } 509 639 640 //! Server side: Receive a message of client annoucing the creation of header part of netcdf file 510 641 void CContext::recvCreateFileHeader(CBufferIn& buffer) 511 642 { 512 643 createFileHeader() ; 513 644 } 514 645 646 //! Client side: Send a message to do some post processing on server 647 void CContext::sendPostProcessing() 648 { 649 if (!hasServer) 650 { 651 CEventClient event(getType(),EVENT_ID_POST_PROCESS) ; 652 if (client->isServerLeader()) 653 { 654 CMessage msg ; 655 msg<<this->getId(); 656 event.push(client->getServerLeader(),1,msg) ; 657 client->sendEvent(event) ; 658 } 659 else client->sendEvent(event) ; 660 } 661 } 662 663 //! Server side: Receive a message to do some post processing 664 void CContext::recvPostProcessing(CEventServer& event) 665 { 666 CBufferIn* buffer=event.subEvents.begin()->buffer; 667 string id; 668 *buffer>>id; 669 get(id)->recvPostProcessing(*buffer); 670 } 671 672 //! Server side: Receive a message to do some post processing 673 void CContext::recvPostProcessing(CBufferIn& buffer) 674 { 675 postProcessing(); 676 } 677 678 /*! 679 \brief Do some simple post processings after parsing xml file 680 After the xml file (iodef.xml) is parsed, it is necessary to build all relations among 681 created object, e.g: inhertance among fields, domain, axis. After that, all fiels as well as their parents (reference fields), 682 which will be written out into netcdf files, are processed 683 */ 684 void CContext::postProcessing() 685 { 686 if (isPostProcessed) return; 687 688 this->solveCalendar(); 689 690 // Solve calendar for both side: client and server 691 this->solveCalendar(); 692 693 // Find all inheritance in xml structure 694 this->solveAllInheritance(); 695 696 //Initialisation du vecteur 'enabledFiles' contenant la liste des fichiers à sortir. 697 this->findEnabledFiles(); 698 699 // Find all enabled fields of each file 700 this->findAllEnabledFields(); 701 702 // Search and rebuild all reference object of enabled fields 703 this->solveAllRefOfEnabledFields(false); 704 isPostProcessed = true; 705 } 706 707 std::map<int, StdSize>& CContext::getDataSize() 708 { 709 std::set<StdString> domainIds; 710 711 // Find all reference domain and axis of all active fields 712 int numEnabledFiles = this->enabledFiles.size(); 713 for (int i = 0; i < numEnabledFiles; ++i) 714 { 715 std::vector<CField*> enabledFields = this->enabledFiles[i]->getEnabledFields(); 716 int numEnabledFields = enabledFields.size(); 717 for (int j = 0; j < numEnabledFields; ++j) 718 { 719 const std::pair<StdString, StdString>& prDomAxisId = enabledFields[j]->getDomainAxisIds(); 720 const std::map<int, StdSize> mapSize = enabledFields[j]->getGridDataSize(); 721 if (dataSize_.empty()) 722 { 723 dataSize_ = mapSize; 724 domainIds.insert(prDomAxisId.first); 725 } 726 else 727 { 728 if (domainIds.find(prDomAxisId.first) == domainIds.end()) 729 { 730 std::map<int, StdSize>::const_iterator it = mapSize.begin(), itE = mapSize.end(); 731 for (; it != itE; ++it) 732 { 733 if (0 < dataSize_.count(it->first)) dataSize_[it->first] += it->second; 734 else dataSize_.insert(make_pair(it->first, it->second)); 735 } 736 } 737 738 } 739 740 } 741 } 742 743 return dataSize_; 744 } 745 746 //! Client side: Send infomation of active files (files are enabled to write out) 747 void CContext::sendEnabledFiles() 748 { 749 int size = this->enabledFiles.size(); 750 751 // In a context, each type has a root definition, e.g: axis, domain, field. 752 // Every object must be a child of one of these root definition. In this case 753 // all new file objects created on server must be children of the root "file_definition" 754 StdString fileDefRoot("file_definition"); 755 CFileGroup* cfgrpPtr = CFileGroup::get(fileDefRoot); 756 757 for (int i = 0; i < size; ++i) 758 { 759 cfgrpPtr->sendCreateChild(this->enabledFiles[i]->getId()); 760 this->enabledFiles[i]->sendAllAttributesToServer(); 761 this->enabledFiles[i]->sendAddAllVariables(); 762 } 763 } 764 765 //! Client side: Send information of active fields (ones are written onto files) 766 void CContext::sendEnabledFields() 767 { 768 int size = this->enabledFiles.size(); 769 for (int i = 0; i < size; ++i) 770 { 771 this->enabledFiles[i]->sendEnabledFields(); 772 } 773 } 774 775 //! Client side: Send information of reference grid of active fields 776 void CContext::sendRefGrid() 777 { 778 std::set<StdString> gridIds; 779 int sizeFile = this->enabledFiles.size(); 780 CFile* filePtr(NULL); 781 782 // Firstly, find all reference grids of all active fields 783 for (int i = 0; i < sizeFile; ++i) 784 { 785 filePtr = this->enabledFiles[i]; 786 std::vector<CField*> enabledFields = filePtr->getEnabledFields(); 787 int sizeField = enabledFields.size(); 788 for (int numField = 0; numField < sizeField; ++numField) 789 { 790 if (0 != enabledFields[numField]->getRelGrid()) 791 gridIds.insert(CGrid::get(enabledFields[numField]->getRelGrid())->getId()); 792 } 793 } 794 795 // Create all reference grids on server side 796 StdString gridDefRoot("grid_definition"); 797 CGridGroup* gridPtr = CGridGroup::get(gridDefRoot); 798 std::set<StdString>::const_iterator it, itE = gridIds.end(); 799 for (it = gridIds.begin(); it != itE; ++it) 800 { 801 gridPtr->sendCreateChild(*it); 802 CGrid::get(*it)->sendAllAttributesToServer(); 803 } 804 } 805 806 807 //! Client side: Send information of reference domain and axis of active fields 808 void CContext::sendRefDomainsAxis() 809 { 810 std::set<StdString> domainIds; 811 std::set<StdString> axisIds; 812 813 // Find all reference domain and axis of all active fields 814 int numEnabledFiles = this->enabledFiles.size(); 815 for (int i = 0; i < numEnabledFiles; ++i) 816 { 817 std::vector<CField*> enabledFields = this->enabledFiles[i]->getEnabledFields(); 818 int numEnabledFields = enabledFields.size(); 819 for (int j = 0; j < numEnabledFields; ++j) 820 { 821 const std::pair<StdString, StdString>& prDomAxisId = enabledFields[j]->getDomainAxisIds(); 822 domainIds.insert(prDomAxisId.first); 823 axisIds.insert(prDomAxisId.second); 824 } 825 } 826 827 // Create all reference axis on server side 828 std::set<StdString>::iterator itDom, itAxis; 829 std::set<StdString>::const_iterator itE; 830 831 StdString axiDefRoot("axis_definition"); 832 CAxisGroup* axisPtr = CAxisGroup::get(axiDefRoot); 833 itE = axisIds.end(); 834 for (itAxis = axisIds.begin(); itAxis != itE; ++itAxis) 835 { 836 axisPtr->sendCreateChild(*itAxis); 837 CAxis::get(*itAxis)->sendAllAttributesToServer(); 838 } 839 840 // Create all reference domains on server side 841 StdString domDefRoot("domain_definition"); 842 CDomainGroup* domPtr = CDomainGroup::get(domDefRoot); 843 itE = domainIds.end(); 844 for (itDom = domainIds.begin(); itDom != itE; ++itDom) 845 { 846 domPtr->sendCreateChild(*itDom); 847 CDomain::get(*itDom)->sendAllAttributesToServer(); 848 } 849 } 850 851 //! Update calendar in each time step 515 852 void CContext::updateCalendar(int step) 516 853 { … … 519 856 info(50)<<"updateCalendar : after : "<<calendar->getCurrentDate()<<endl ; 520 857 } 521 858 859 //! Server side: Create header of netcdf file 522 860 void CContext::createFileHeader(void ) 523 861 { 524 862 vector<CFile*>::const_iterator it ; 525 863 526 864 for (it=enabledFiles.begin(); it != enabledFiles.end(); it++) 527 865 { 528 866 (*it)->initFile(); 529 867 } 530 } 531 868 } 869 870 //! Get current context 532 871 CContext* CContext::getCurrent(void) 533 872 { 534 873 return CObjectFactory::GetObject<CContext>(CObjectFactory::GetCurrentContextId()).get() ; 535 874 } 536 875 876 /*! 877 \brief Set context with an id be the current context 878 \param [in] id identity of context to be set to current 879 */ 537 880 void CContext::setCurrent(const string& id) 538 881 { … … 540 883 CGroupFactory::SetCurrentContextId(id); 541 884 } 542 885 886 /*! 887 \brief Create a context with specific id 888 \param [in] id identity of new context 889 \return pointer to the new context or already-existed one with identity id 890 */ 543 891 CContext* CContext::create(const StdString& id) 544 892 { 545 893 CContext::setCurrent(id) ; 546 894 547 895 bool hasctxt = CContext::has(id); 548 896 CContext* context = CObjectFactory::CreateObject<CContext>(id).get();
Note: See TracChangeset
for help on using the changeset viewer.