Changeset 540
- Timestamp:
- 12/16/14 12:55:53 (10 years ago)
- Location:
- XIOS/trunk
- Files:
-
- 2 added
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/bld.cfg
r489 r540 31 31 bld::target libxios.a 32 32 #bld::target generate_fortran_interface.exe 33 bld::target xios_server.exe test_client.exe parse_xml.exe test_complete.exe test_xios_interface.exe 33 bld::target xios_server.exe test_client.exe parse_xml.exe test_complete.exe test_xios_interface.exe test_new_features.exe 34 34 bld::exe_dep 35 35 -
XIOS/trunk/src/config/axis_attribute.conf
r501 r540 12 12 DECLARE_ARRAY(double, 1, value) 13 13 14 DECLARE_ATTRIBUTE(StdString, axis_ref) 14 15 16 -
XIOS/trunk/src/config/domain_attribute.conf
r501 r540 62 62 63 63 DECLARE_ENUM3(type,regular,curvilinear,unstructured) 64 DECLARE_ATTRIBUTE(StdString, domain_ref) 64 65 -
XIOS/trunk/src/config/grid_attribute.conf
r501 r540 4 4 DECLARE_ATTRIBUTE(StdString, axis_ref) 5 5 DECLARE_ARRAY(bool, 3 , mask) 6 7 // These attributes should be used privately 8 // An array contains order of axis and domains composing of the grid 9 DECLARE_ARRAY(int, 1 , axisDomOrder) 10 //DECLARE_ARRAY(StdString, 1 , axisList) 11 //DECLARE_ARRAY(StdString, 1 , domainList) -
XIOS/trunk/src/data_output.cpp
r501 r540 16 16 void CDataOutput::writeGrid(CGrid* grid) 17 17 { 18 if (grid->domain_ref.isEmpty()) 19 ERROR("CDataOutput::writeGrid(grid)", 20 << " domain is not defined !"); 21 22 if (grid->axis_ref.isEmpty()) 23 { 24 this->writeGrid(CDomain::get(grid->domain_ref.getValue())); 25 } 26 else 27 { 28 this->writeGrid(CDomain::get(grid->domain_ref.getValue()), 29 CAxis::get(grid->axis_ref.getValue())); 30 } 18 // if (grid->domain_ref.isEmpty()) 19 // ERROR("CDataOutput::writeGrid(grid)", 20 // << " domain is not defined !"); 21 // 22 // if (grid->axis_ref.isEmpty()) 23 // { 24 // this->writeGrid(CDomain::get(grid->domain_ref.getValue())); 25 // } 26 // else 27 // { 28 // this->writeGrid(CDomain::get(grid->domain_ref.getValue()), 29 // CAxis::get(grid->axis_ref.getValue())); 30 // } 31 // this->writeGrid(grid->domain, grid->axis); 32 this->writeGrid(grid->getDomains(), grid->getAxis()); 31 33 } 32 34 … … 61 63 } 62 64 65 void CDataOutput::writeGrid(std::vector<CDomain*> domains, std::vector<CAxis*> axis) 66 { 67 int domSize = domains.size(); 68 int aSize = axis.size(); 69 for (int i = 0; i < domSize; ++i) this->writeDomain_(domains[i]); 70 for (int i = 0; i < aSize; ++i) this->writeAxis_(axis[i]); 71 } 72 63 73 //---------------------------------------------------------------- 64 74 … … 79 89 CContext* context = CContext::getCurrent() ; 80 90 boost::shared_ptr<CCalendar> calendar = context->getCalendar(); 81 91 82 92 this->writeField_(field); 83 93 this->writeTimeAxis_(field, calendar); … … 90 100 this->writeGrid(field->getRelGrid()); 91 101 } 92 102 93 103 //---------------------------------------------------------------- 94 104 95 105 void CDataOutput::writeFieldData(CField* field) 96 106 { 97 CGrid* grid = CGrid::get(field->grid_ref.getValue());98 CDomain* domain = CDomain::get(grid->domain_ref.getValue());107 // CGrid* grid = CGrid::get(field->grid_ref.getValue()); 108 // CDomain* domain = CDomain::get(grid->domain_ref.getValue()); 99 109 this->writeFieldData_(field); 100 110 } 101 111 102 112 ///---------------------------------------------------------------- 103 113 -
XIOS/trunk/src/data_output.hpp
r528 r540 44 44 CAxis* axis); 45 45 void writeGrid(CDomain* domain); 46 void writeGrid(std::vector<CDomain*> domain, std::vector<CAxis*> axis); 46 47 47 48 virtual void writeFile_ (CFile* file) = 0; -
XIOS/trunk/src/node/axis.cpp
r501 r540 9 9 10 10 namespace xios { 11 11 12 12 /// ////////////////////// Définitions ////////////////////// /// 13 13 14 14 CAxis::CAxis(void) 15 15 : CObjectTemplate<CAxis>() 16 , CAxisAttributes(), isChecked(false), relFiles() 16 , CAxisAttributes(), isChecked(false), relFiles(), baseRefObject() 17 17 { /* Ne rien faire de plus */ } 18 18 19 19 CAxis::CAxis(const StdString & id) 20 20 : CObjectTemplate<CAxis>(id) 21 , CAxisAttributes(), isChecked(false), relFiles() 21 , CAxisAttributes(), isChecked(false), relFiles(), baseRefObject() 22 22 { /* Ne rien faire de plus */ } 23 23 … … 56 56 ERROR("CAxis::checkAttributes(void)",<< "Attribut <size> of the axis must be specified") ; 57 57 StdSize size = this->size.getValue(); 58 58 59 59 StdSize zoom_begin,zoom_end, zoom_size ; 60 60 61 61 zoom_begin = (this->zoom_begin.isEmpty()) ? 1 : this->zoom_begin.getValue() ; 62 zoom_end = (this->zoom_end.isEmpty()) ? size : this->zoom_end.getValue() ; 62 zoom_end = (this->zoom_end.isEmpty()) ? size : this->zoom_end.getValue() ; 63 63 zoom_size = (this->zoom_size.isEmpty()) ? size : this->zoom_size.getValue() ; 64 64 65 65 if (this->zoom_begin.isEmpty()) zoom_begin=zoom_end-zoom_size+1 ; 66 66 if (this->zoom_end.isEmpty()) zoom_end=zoom_begin+zoom_size-1 ; 67 67 if (this->zoom_size.isEmpty()) zoom_size=zoom_end-zoom_begin+1 ; 68 68 69 69 if ( (zoom_begin < 1) || (zoom_begin > size) || (zoom_end<1) || (zoom_end>size) || (zoom_size<1) || (zoom_size>size) || (zoom_begin>zoom_end)) 70 70 ERROR("CAxis::checkAttributes(void)",<< "One or more attribut of <zoom_begin>, <zoom_end>, <zoom_size>, are not well specified") ; … … 72 72 this->zoom_end.setValue(zoom_end) ; 73 73 this->zoom_size.setValue(zoom_size) ; 74 74 75 75 StdSize true_size = value.numElements(); 76 76 if (size != true_size) … … 81 81 } 82 82 83 DEFINE_REF_FUNC(Axis,axis) 84 83 85 ///--------------------------------------------------------------- 84 86 -
XIOS/trunk/src/node/axis.hpp
r501 r540 7 7 8 8 #include "declare_group.hpp" 9 #include "declare_ref_func.hpp" 9 10 #include "attribute_array.hpp" 10 11 #include "attribute_enum.hpp" … … 12 13 13 14 namespace xios { 14 15 15 16 /// ////////////////////// Déclarations ////////////////////// /// 16 17 … … 65 66 static StdString GetName(void); 66 67 static StdString GetDefName(void); 67 68 68 69 static ENodeType GetType(void); 69 70 … … 72 73 bool isChecked; 73 74 std::set<StdString> relFiles; 75 76 DECLARE_REF_FUNC(Axis,axis) 74 77 75 78 -
XIOS/trunk/src/node/context.cpp
r537 r540 353 353 void CContext::closeDefinition(void) 354 354 { 355 355 356 if (hasClient) 356 357 { 358 std::cout << "Current context " << *this << std::endl; 357 359 // After xml is parsed, there are some more works with post processing 358 360 postProcessing(); … … 378 380 sendEnabledFields(); 379 381 382 // At last, we have all info of domain and axis, then send them 383 sendRefDomainsAxis(); 384 380 385 // After that, send all grid (if any) 381 386 sendRefGrid(); 382 387 383 // At last, we have all info of domain and axis, then send them 384 sendRefDomainsAxis(); 388 385 389 } 386 390 … … 508 512 // Résolution des héritages par référence au niveau des fichiers. 509 513 const vector<CFile*> allFiles=CFile::getAll() ; 514 const vector<CGrid*> allGrids= CGrid::getAll(); 510 515 511 516 //if (hasClient && !hasServer) 512 517 if (hasClient) 518 { 513 519 for (unsigned int i = 0; i < allFiles.size(); i++) 514 520 allFiles[i]->solveFieldRefInheritance(apply); 521 } 522 523 unsigned int vecSize = allGrids.size(); 524 unsigned int i = 0; 525 for (i = 0; i < vecSize; ++i) 526 allGrids[i]->solveDomainAxisRefInheritance(apply); 527 515 528 } 516 529 … … 702 715 { 703 716 postProcessing(); 717 std::cout << "server context " << *this << std::endl; 704 718 } 705 719 … … 848 862 gridPtr->sendCreateChild(*it); 849 863 CGrid::get(*it)->sendAllAttributesToServer(); 864 CGrid::get(*it)->sendAllDomains(); 865 CGrid::get(*it)->sendAllAxis(); 850 866 } 851 867 } … … 881 897 for (itAxis = axisIds.begin(); itAxis != itE; ++itAxis) 882 898 { 883 axisPtr->sendCreateChild(*itAxis); 884 CAxis::get(*itAxis)->sendAllAttributesToServer(); 899 if (!itAxis->empty()) 900 { 901 axisPtr->sendCreateChild(*itAxis); 902 CAxis::get(*itAxis)->sendAllAttributesToServer(); 903 } 885 904 } 886 905 … … 891 910 for (itDom = domainIds.begin(); itDom != itE; ++itDom) 892 911 { 893 domPtr->sendCreateChild(*itDom); 894 CDomain::get(*itDom)->sendAllAttributesToServer(); 912 if (!itDom->empty()) { 913 domPtr->sendCreateChild(*itDom); 914 CDomain::get(*itDom)->sendAllAttributesToServer(); 915 } 895 916 } 896 917 } -
XIOS/trunk/src/node/domain.cpp
r518 r540 1024 1024 //---------------------------------------------------------------- 1025 1025 1026 1026 DEFINE_REF_FUNC(Domain,domain) 1027 1027 1028 1028 ///--------------------------------------------------------------- -
XIOS/trunk/src/node/domain.hpp
r518 r540 7 7 8 8 #include "declare_group.hpp" 9 #include "declare_ref_func.hpp" 9 10 #include "event_client.hpp" 10 11 #include "event_server.hpp" … … 152 153 bool isClientChecked; // Verify whether all attributes of domain on the client side is good 153 154 155 DECLARE_REF_FUNC(Domain,domain) 156 154 157 }; // class CDomain 155 158 -
XIOS/trunk/src/node/field.cpp
r538 r540 288 288 //---------------------------------------------------------------- 289 289 290 /*!291 \brief Get pointer to direct field to which the current field refers.292 */293 CField* CField::getDirectFieldReference(void) const294 {295 if (this->field_ref.isEmpty())296 return (this->getBaseFieldReference());297 298 if (! CField::has(this->field_ref.getValue()))299 ERROR("CField::getDirectFieldReference(void)",300 << "[ ref_name = " << this->field_ref.getValue() << "]"301 << " invalid field name !");302 303 return (CField::get(this->field_ref.getValue()));304 }305 306 //----------------------------------------------------------------307 308 CField* CField::getBaseFieldReference(void) const309 {310 return (baseRefObject);311 }312 313 //----------------------------------------------------------------314 315 const std::vector<CField*>& CField::getAllReference(void) const316 {317 return (refObject);318 }319 320 //----------------------------------------------------------------321 322 const StdString & CField::getBaseFieldId(void) const323 {324 return (this->getBaseFieldReference()->getId());325 }326 327 //----------------------------------------------------------------328 329 290 const CDuration & CField::getFreqOperation(void) const 330 291 { … … 345 306 } 346 307 347 //----------------------------------------------------------------348 349 bool CField::hasDirectFieldReference(void) const350 {351 return (!this->field_ref.isEmpty());352 }353 308 354 309 bool CField::isActive(void) const … … 431 386 active=true; 432 387 } 433 }434 435 /*!436 \brief Searching for all reference of a field437 If a field refers to (an)other field(s), we will search for all its referenced parents.438 Moreover, if any father, direct or indirect (e.g: two levels up), has non-empty attributes,439 all its attributes will be added to the current field440 \param [in] apply Flag to specify whether current field uses attributes of its father441 in case the attribute is empty (true) or its attributes are replaced by ones of its father (false)442 */443 void CField::solveRefInheritance(bool apply)444 {445 std::set<CField *> sset;446 CField* refer_sptr;447 CField * refer_ptr = this;448 449 while (refer_ptr->hasDirectFieldReference())450 {451 refer_sptr = refer_ptr->getDirectFieldReference();452 refer_ptr = refer_sptr;453 454 if(sset.end() != sset.find(refer_ptr))455 {456 DEBUG (<< "Circular dependency stopped for field object on "457 << "\"" + refer_ptr->getId() + "\" !");458 break;459 }460 461 SuperClassAttribute::setAttributes(refer_ptr, apply);462 sset.insert(refer_ptr);463 }464 }465 466 467 /*!468 \brief Only on SERVER side. Remove all field_ref from current field469 On creating a new field on server side, redundant "field_ref" is still kept in the attribute list470 of the current field. This function removes this from current field471 */472 void CField::removeRefInheritance()473 {474 if (this->field_ref.isEmpty()) return;475 this->clearAttribute("field_ref");476 }477 478 void CField::solveBaseReference(void)479 {480 std::set<CField *> sset;481 CField* refer_sptr;482 CField * refer_ptr = this;483 484 if (this->hasDirectFieldReference()) baseRefObject = getDirectFieldReference();485 else baseRefObject = CField::get(this);486 487 while (refer_ptr->hasDirectFieldReference())488 {489 refer_sptr = refer_ptr->getDirectFieldReference();490 refer_ptr = refer_sptr;491 492 if(sset.end() != sset.find(refer_ptr))493 {494 DEBUG (<< "Circular dependency stopped for field object on "495 << "\"" + refer_ptr->getId() + "\" !");496 break;497 }498 499 sset.insert(refer_ptr);500 }501 502 if (hasDirectFieldReference()) baseRefObject->addReference(this) ;503 388 } 504 389 … … 652 537 } 653 538 654 if (grid_ref.isEmpty() && domain_ref.isEmpty() )539 if (grid_ref.isEmpty() && domain_ref.isEmpty() && axis_ref.isEmpty()) 655 540 { 656 541 ERROR("CField::solveGridReference(void)", 657 << "The horizontal domain for this field is not defined"); 658 542 << "At least one dimension must be defined for this field."); 543 } 544 545 // if (!grid_ref.isEmpty()) 546 // { 547 // domain = grid->domain; 548 // axis = grid->axis; 549 // } 550 551 // CType<string> goodDomain ; 552 // CType<string> goodAxis ; 553 // if (!grid_ref.isEmpty()) 554 // { 555 // if (!grid->domain_ref.isEmpty()) goodDomain=grid->domain_ref ; 556 // if (!grid->axis_ref.isEmpty()) goodAxis=grid->axis_ref ; 557 // } 558 // if (!domain_ref.isEmpty()) goodDomain=domain_ref ; 559 // if (!axis_ref.isEmpty()) goodAxis=axis_ref ; 560 561 // CArray<std::string,1> domListTmp = grid->domainList.getValue(); 562 // CArray<std::string,1> axisListTmp = grid->axisList.getValue(); 563 564 std::vector<std::string> domList, axisList; 565 if (0 != grid) 566 { 567 domList = grid->getDomainList(); 568 axisList = grid->getAxisList(); 659 569 } 660 570 661 CType<string> goodDomain ; 662 CType<string> goodAxis ; 663 if (!grid_ref.isEmpty()) 571 if (domList.empty() && axisList.empty()) 664 572 { 665 if (!grid->domain_ref.isEmpty()) goodDomain=grid->domain_ref ; 666 if (!grid->axis_ref.isEmpty()) goodAxis=grid->axis_ref ; 573 std::vector<CDomain*> vecDom; 574 if (0 != domain) vecDom.push_back(domain); 575 std::vector<CAxis*> vecAxis; 576 if (0 != axis) vecAxis.push_back(axis); 577 this->grid = CGrid::createGrid(vecDom, vecAxis); 667 578 } 668 if (!domain_ref.isEmpty()) goodDomain=domain_ref ; 669 if (!axis_ref.isEmpty()) goodAxis=axis_ref ; 670 671 672 if (goodDomain.isEmpty()) 673 { 674 ERROR("CField::solveGridReference(void)", << "The horizontal domain for this field is not defined"); 675 } 676 else 677 { 678 if (CDomain::has(goodDomain)) domain = CDomain::get(goodDomain) ; 679 else ERROR("CField::solveGridReference(void)",<< "Reference to the domain \'"<<goodDomain.get() << "\' is wrong") ; 680 } 681 682 if (!goodAxis.isEmpty()) 683 { 684 if (CAxis::has(goodAxis)) axis = CAxis::get(goodAxis) ; 685 else ERROR("CField::solveGridReference(void)", << "Reference to the axis \'" 686 << goodAxis.get() <<"\' is wrong") ; 687 } 688 689 bool nothingToDo=false ; 690 691 if (!grid_ref.isEmpty()) 692 { 693 if (!grid->domain_ref.isEmpty() && goodDomain.get() == grid->domain_ref.get()) 694 if (goodAxis.isEmpty()) nothingToDo=true ; 695 else if (!grid->axis_ref.isEmpty()) 696 if (grid->axis_ref.get()==goodAxis.get()) nothingToDo=true ; 697 } 698 699 if (!nothingToDo) 700 { 701 if (!goodAxis.isEmpty()) 702 { 703 this->grid = CGrid::createGrid(domain, axis) ; 704 this->grid_ref.setValue(this->grid->getId()); 705 } 706 else 707 { 708 this->grid = CGrid::createGrid(domain) ; 709 this->grid_ref.setValue(this->grid->getId()); 710 } 711 } 579 580 // std::string goodDomain = domListTmp[0]; 581 // std::string goodAxis = axisListTmp[0]; 582 583 // if (goodDomain.isEmpty()) 584 // if (goodDomain.empty()) 585 // { 586 // ERROR("CField::solveGridReference(void)", << "The horizontal domain for this field is not defined"); 587 // } 588 // else 589 // { 590 // if (CDomain::has(goodDomain)) domain = CDomain::get(goodDomain) ; 591 // else ERROR("CField::solveGridReference(void)",<< "Reference to the domain \'" 592 // <<goodDomain << "\' is wrong") ; 593 //// <<goodDomain.get() << "\' is wrong") ; 594 // } 595 // 596 //// if (!goodAxis.isEmpty()) 597 // if (!goodAxis.empty()) 598 // { 599 // if (CAxis::has(goodAxis)) axis = CAxis::get(goodAxis) ; 600 // else ERROR("CField::solveGridReference(void)", << "Reference to the axis \'" 601 // << goodAxis <<"\' is wrong") ; 602 // << goodAxis.get() <<"\' is wrong") ; 603 // } 604 605 // bool nothingToDo=false ; 606 // 607 // if (!grid_ref.isEmpty()) 608 // { 609 // if (!grid->domain_ref.isEmpty() && goodDomain.get() == grid->domain_ref.get()) 610 // if (goodAxis.isEmpty()) nothingToDo=true ; 611 // else if (!grid->axis_ref.isEmpty()) 612 // if (grid->axis_ref.get()==goodAxis.get()) nothingToDo=true ; 613 // } 614 // 615 // nothingToDo = true; 616 // if (!nothingToDo) 617 // { 618 // if (!goodAxis.isEmpty()) 619 // { 620 // this->grid = CGrid::createGrid(domain, axis) ; 621 // this->grid_ref.setValue(this->grid->getId()); 622 // } 623 // else 624 // { 625 // this->grid = CGrid::createGrid(domain) ; 626 // this->grid_ref.setValue(this->grid->getId()); 627 // } 628 // } 712 629 713 630 // grid->solveReference() ; … … 803 720 } 804 721 return &instantData ; 805 }806 807 void CField::addReference(CField* field)808 {809 refObject.push_back(field) ;810 722 } 811 723 … … 1047 959 } 1048 960 1049 1050 961 DEFINE_REF_FUNC(Field,field) 962 963 // void CField::addReference(CField* field) 964 // { 965 // refObject.push_back(field) ; 966 // } 967 // 968 // //---------------------------------------------------------------- 969 // 970 // bool CField::hasDirectFieldReference(void) const 971 // { 972 // return (!this->field_ref.isEmpty()); 973 // } 974 // 975 // //---------------------------------------------------------------- 976 // 977 // const StdString & CField::getBaseFieldId(void) const 978 // { 979 // return (this->getBaseFieldReference()->getId()); 980 // } 981 // 982 // 983 // //---------------------------------------------------------------- 984 // 985 // /*! 986 // \brief Get pointer to direct field to which the current field refers. 987 // */ 988 // CField* CField::getDirectFieldReference(void) const 989 // { 990 // if (this->field_ref.isEmpty()) 991 // return (this->getBaseFieldReference()); 992 // 993 // if (! CField::has(this->field_ref.getValue())) 994 // ERROR("CField::getDirectFieldReference(void)", 995 // << "[ ref_name = " << this->field_ref.getValue() << "]" 996 // << " invalid field name !"); 997 // 998 // return (CField::get(this->field_ref.getValue())); 999 // } 1000 // 1001 // //---------------------------------------------------------------- 1002 // 1003 // CField* CField::getBaseFieldReference(void) const 1004 // { 1005 // return (baseRefObject); 1006 // } 1007 // 1008 // //---------------------------------------------------------------- 1009 // 1010 // const std::vector<CField*>& CField::getAllReference(void) const 1011 // { 1012 // return (refObject); 1013 // } 1014 // 1015 // 1016 // /*! 1017 // \brief Searching for all reference of a field 1018 // If a field refers to (an)other field(s), we will search for all its referenced parents. 1019 // Moreover, if any father, direct or indirect (e.g: two levels up), has non-empty attributes, 1020 // all its attributes will be added to the current field 1021 // \param [in] apply Flag to specify whether current field uses attributes of its father 1022 // in case the attribute is empty (true) or its attributes are replaced by ones of its father (false) 1023 // */ 1024 // void CField::solveRefInheritance(bool apply) 1025 // { 1026 // std::set<CField *> sset; 1027 // CField* refer_sptr; 1028 // CField * refer_ptr = this; 1029 // 1030 // while (refer_ptr->hasDirectFieldReference()) 1031 // { 1032 // refer_sptr = refer_ptr->getDirectFieldReference(); 1033 // refer_ptr = refer_sptr; 1034 // 1035 // if(sset.end() != sset.find(refer_ptr)) 1036 // { 1037 // DEBUG (<< "Circular dependency stopped for field object on " 1038 // << "\"" + refer_ptr->getId() + "\" !"); 1039 // break; 1040 // } 1041 // 1042 // SuperClassAttribute::setAttributes(refer_ptr, apply); 1043 // sset.insert(refer_ptr); 1044 // } 1045 // } 1046 // 1047 // /*! 1048 // \brief Only on SERVER side. Remove all field_ref from current field 1049 // On creating a new field on server side, redundant "field_ref" is still kept in the attribute list 1050 // of the current field. This function removes this from current field 1051 // */ 1052 // void CField::removeRefInheritance() 1053 // { 1054 // if (this->field_ref.isEmpty()) return; 1055 // this->clearAttribute("field_ref"); 1056 // } 1057 // 1058 // void CField::solveBaseReference(void) 1059 // { 1060 // std::set<CField *> sset; 1061 // CField* refer_sptr; 1062 // CField * refer_ptr = this; 1063 // 1064 // if (this->hasDirectFieldReference()) baseRefObject = getDirectFieldReference(); 1065 // else baseRefObject = CField::get(this); 1066 // 1067 // while (refer_ptr->hasDirectFieldReference()) 1068 // { 1069 // refer_sptr = refer_ptr->getDirectFieldReference(); 1070 // refer_ptr = refer_sptr; 1071 // 1072 // if(sset.end() != sset.find(refer_ptr)) 1073 // { 1074 // DEBUG (<< "Circular dependency stopped for field object on " 1075 // << "\"" + refer_ptr->getId() + "\" !"); 1076 // break; 1077 // } 1078 // 1079 // sset.insert(refer_ptr); 1080 // } 1081 // 1082 // if (hasDirectFieldReference()) baseRefObject->addReference(this) ; 1083 // } 1084 // 1051 1085 1052 1086 } // namespace xios -
XIOS/trunk/src/node/field.hpp
r509 r540 14 14 #include "attribute_array.hpp" 15 15 #include "expr_node.hpp" 16 //#include "context.hpp"16 #include "declare_ref_func.hpp" 17 17 18 18 … … 64 64 65 65 /// Accesseurs /// 66 CField* getDirectFieldReference(void) const;67 CField* getBaseFieldReference(void) const;68 void addReference(CField* field) ;69 const std::vector<CField*> & getAllReference(void) const;70 66 71 67 CGrid* getRelGrid(void) const ; … … 86 82 CArray<double, 1> getData(void) const; 87 83 88 const StdString & getBaseFieldId(void) const; 84 89 85 90 86 /// Mutateur /// … … 104 100 105 101 public : 106 107 /// Test ///108 bool hasDirectFieldReference(void) const;109 102 bool isActive(void) const; 110 103 bool active ; … … 114 107 /// Traitements /// 115 108 void processEnabledField(void) ; 116 void solveRefInheritance(bool apply); 117 void solveBaseReference(void); 109 118 110 void solveGridReference(void); 119 111 void solveOperation(void); … … 122 114 void buildAllExpressionEnabledField(); 123 115 void solveGridDomainAxisRef(bool checkAtt); 124 void removeRefInheritance(); // Remove all reference of current field (it refers to itself) 116 125 117 126 118 // virtual void fromBinary(StdIStream & is); … … 166 158 const std::pair<StdString, StdString>& getDomainAxisIds(); 167 159 public : 168 169 160 /// Propriétés privées /// 170 161 CVariableGroup* vVariableGroup ; 171 162 172 std::vector<CField*> refObject;173 CField* baseRefObject;174 163 CGrid* grid ; 175 164 CFile* file; … … 208 197 bool areAllExpressionBuilt; 209 198 std::pair<StdString,StdString> domAxisIds_; 199 DECLARE_REF_FUNC(Field,field) 200 // public: 201 // bool hasDirectFieldReference(void) const; 202 // CField* getDirectFieldReference(void) const; 203 // CField* getBaseFieldReference(void) const; 204 // void addReference(CField* field); 205 // const std::vector<CField*> & getAllReference(void) const; 206 //void solveRefInheritance(bool apply); 207 //void solveBaseReference(void); 208 // void removeRefInheritance(); 209 // const StdString & getBaseFieldId(void) const; 210 // 211 // std::vector<CField*> refObject; 212 // CField* baseRefObject; 213 210 214 211 215 }; // class CField -
XIOS/trunk/src/node/grid.cpp
r518 r540 21 21 , withAxis(false), isChecked(false), isDomainAxisChecked(false), axis(), domain() 22 22 , storeIndex(1), out_i_index(1), out_j_index(1), out_l_index(1), isDomConServerComputed_(false) 23 { /* Ne rien faire de plus */ } 23 , vDomainGroup_(), vAxisGroup_(), axisOrder_(), axisList_(), isAxisListSet(false), isDomListSet(false) 24 { 25 setVirtualDomainGroup(); 26 setVirtualAxisGroup(); 27 } 24 28 25 29 CGrid::CGrid(const StdString & id) … … 27 31 , withAxis(false), isChecked(false), isDomainAxisChecked(false), axis(), domain() 28 32 , storeIndex(1), out_i_index(1), out_j_index(1), out_l_index(1), isDomConServerComputed_(false) 29 { /* Ne rien faire de plus */ } 33 , vDomainGroup_(), vAxisGroup_(), axisOrder_(), axisList_(), isAxisListSet(false), isDomListSet(false) 34 { 35 setVirtualDomainGroup(); 36 setVirtualAxisGroup(); 37 } 30 38 31 39 CGrid::~CGrid(void) … … 317 325 void CGrid::solveDomainRef(bool sendAtt) 318 326 { 319 if (!domain_ref.isEmpty()) 320 { 321 if (CDomain::has(domain_ref.getValue())) 322 { 323 this->domain = CDomain::get(domain_ref.getValue()) ; 324 if (sendAtt) domain->sendCheckedAttributes(); 325 else domain->checkAttributesOnClient() ; 326 } 327 else ERROR("CGrid::solveDomainRef(void)", 328 << "Wrong domain reference") ; 327 // if (!domain_ref.isEmpty()) 328 // { 329 // if (CDomain::has(domain_ref.getValue())) 330 // { 331 // this->domain = CDomain::get(domain_ref.getValue()) ; 332 // if (sendAtt) domain->sendCheckedAttributes(); 333 // else domain->checkAttributesOnClient() ; 334 // } 335 // else ERROR("CGrid::solveDomainRef(void)", 336 // << "Wrong domain reference") ; 337 // } 338 // else ERROR("CGrid::solveDomainRef(void)", 339 // << "Domain reference is not defined") ; 340 setDomainList(); 341 this->domain = CDomain::get(domList_.at(0)); 342 if (0 != this->domain) 343 { 344 // this->domain = this->getDomain(); 345 if (sendAtt) domain->sendCheckedAttributes(); 346 else domain->checkAttributesOnClient() ; 329 347 } 330 348 else ERROR("CGrid::solveDomainRef(void)", … … 336 354 void CGrid::solveAxisRef(bool checkAtt) 337 355 { 338 if (!axis_ref.isEmpty()) 339 { 340 this->withAxis = true ; 341 if (CAxis::get(axis_ref.getValue())) 342 { 343 this->axis = CAxis::get(axis_ref.getValue()) ; 344 axis->checkAttributes() ; 345 } 346 else ERROR("CGrid::solveAxisRef(void)", 347 << "Wrong axis reference") ; 348 } 356 // if (!axis_ref.isEmpty()) 357 // { 358 // this->withAxis = true ; 359 // if (CAxis::get(axis_ref.getValue())) 360 // { 361 // this->axis = CAxis::get(axis_ref.getValue()) ; 362 // axis->checkAttributes() ; 363 // } 364 // else ERROR("CGrid::solveAxisRef(void)", 365 // << "Wrong axis reference") ; 366 // } 367 // else withAxis = false ; 368 // getAllAxis(); 369 setAxisList(); 370 if (!axisList_.empty()) 371 { 372 int sizeList = axisList_.size(); 373 for (int i = 0; i < sizeList; ++i) 374 { 375 CAxis::get(axisList_.at(i))->checkAttributes(); 376 this->axis = CAxis::get(axisList_.at(i)); 377 } 378 withAxis = true; 379 380 } 381 // if (!axis_ref.isEmpty()) 382 // { 383 // this->withAxis = true ; 384 // if (CAxis::get(axis_ref.getValue())) 385 // { 386 // this->axis = CAxis::get(axis_ref.getValue()) ; 387 // axis->checkAttributes() ; 388 // } 389 // else ERROR("CGrid::solveAxisRef(void)", 390 // << "Wrong axis reference") ; 391 // } 349 392 else withAxis = false ; 350 393 } … … 445 488 StdString new_id = StdString("__") + domain->getId() + StdString("__") ; 446 489 CGrid* grid = CGridGroup::get("grid_definition")->createChild(new_id) ; 447 grid->domain_ref.setValue(domain->getId()); 490 491 std::vector<CDomain*> vecDom(1,domain); 492 grid->setDomainList(vecDom); 493 // grid->domain_ref.setValue(domain->getId()); 448 494 return (grid); 449 495 } … … 454 500 StdString("_") + axis->getId() + StdString("__") ; 455 501 CGrid* grid = CGridGroup::get("grid_definition")->createChild(new_id) ; 456 grid->domain_ref.setValue(domain->getId()); 457 grid->axis_ref.setValue(axis->getId()); 502 503 std::vector<CDomain*> vecDom(1,domain); 504 std::vector<CAxis*> vecAxis(1,axis); 505 grid->setDomainList(vecDom); 506 grid->setAxisList(vecAxis); 507 // grid->domain_ref.setValue(domain->getId()); 508 // grid->axis_ref.setValue(axis->getId()); 458 509 return (grid); 510 } 511 512 CGrid* CGrid::createGrid(std::vector<CDomain*> domains, std::vector<CAxis*> axis) 513 { 514 StdString new_id = StdString("__"); 515 if (!domains.empty()) for (int i = 0; i < domains.size(); ++i) new_id += domains[i]->getId() + StdString("_"); 516 if (!axis.empty()) for (int i = 0; i < axis.size(); ++i) new_id += axis[i]->getId() + StdString("_") ; 517 new_id += StdString("_"); 518 519 CGrid* grid = CGridGroup::get("grid_definition")->createChild(new_id) ; 520 grid->setDomainList(domains); 521 grid->setAxisList(axis); 522 return (grid); 523 } 524 525 CDomainGroup* CGrid::getVirtualDomainGroup() const 526 { 527 return (this->vDomainGroup_); 528 } 529 530 CAxisGroup* CGrid::getVirtualAxisGroup() const 531 { 532 return (this->vAxisGroup_); 459 533 } 460 534 … … 679 753 } 680 754 755 /*! 756 \brief Dispatch event received from client 757 Whenever a message is received in buffer of server, it will be processed depending on 758 its event type. A new event type should be added in the switch list to make sure 759 it processed on server side. 760 \param [in] event: Received message 761 */ 681 762 bool CGrid::dispatchEvent(CEventServer& event) 682 763 { … … 692 773 break ; 693 774 775 case EVENT_ID_ADD_DOMAIN : 776 recvAddDomain(event) ; 777 return true ; 778 break ; 779 780 case EVENT_ID_ADD_AXIS : 781 recvAddAxis(event) ; 782 return true ; 783 break ; 694 784 default : 695 785 ERROR("bool CDomain::dispatchEvent(CEventServer& event)", … … 724 814 ///--------------------------------------------------------------- 725 815 816 CDomain* CGrid::addDomain(const std::string& id) 817 { 818 return vDomainGroup_->createChild(id) ; 819 } 820 821 CAxis* CGrid::addAxis(const std::string& id) 822 { 823 return vAxisGroup_->createChild(id) ; 824 } 825 826 //! Change virtual field group to a new one 827 void CGrid::setVirtualDomainGroup(CDomainGroup* newVDomainGroup) 828 { 829 this->vDomainGroup_ = newVDomainGroup; 830 } 831 832 //! Change virtual variable group to new one 833 void CGrid::setVirtualAxisGroup(CAxisGroup* newVAxisGroup) 834 { 835 this->vAxisGroup_ = newVAxisGroup; 836 } 837 838 //---------------------------------------------------------------- 839 //! Create virtual field group, which is done normally on initializing file 840 void CGrid::setVirtualDomainGroup(void) 841 { 842 this->setVirtualDomainGroup(CDomainGroup::create()); 843 } 844 845 //! Create virtual variable group, which is done normally on initializing file 846 void CGrid::setVirtualAxisGroup(void) 847 { 848 this->setVirtualAxisGroup(CAxisGroup::create()); 849 } 850 851 /*! 852 \brief Send a message to create a domain on server side 853 \param[in] id String identity of domain that will be created on server 854 */ 855 void CGrid::sendAddDomain(const string& id) 856 { 857 CContext* context=CContext::getCurrent() ; 858 859 if (! context->hasServer ) 860 { 861 CContextClient* client=context->client ; 862 863 CEventClient event(this->getType(),EVENT_ID_ADD_DOMAIN) ; 864 if (client->isServerLeader()) 865 { 866 CMessage msg ; 867 msg<<this->getId() ; 868 msg<<id ; 869 event.push(client->getServerLeader(),1,msg) ; 870 client->sendEvent(event) ; 871 } 872 else client->sendEvent(event) ; 873 } 874 } 875 876 /*! 877 \brief Send a message to create an axis on server side 878 \param[in] id String identity of axis that will be created on server 879 */ 880 void CGrid::sendAddAxis(const string& id) 881 { 882 CContext* context=CContext::getCurrent() ; 883 884 if (! context->hasServer ) 885 { 886 CContextClient* client=context->client ; 887 888 CEventClient event(this->getType(),EVENT_ID_ADD_AXIS) ; 889 if (client->isServerLeader()) 890 { 891 CMessage msg ; 892 msg<<this->getId() ; 893 msg<<id ; 894 event.push(client->getServerLeader(),1,msg) ; 895 client->sendEvent(event) ; 896 } 897 else client->sendEvent(event) ; 898 } 899 } 900 901 /*! 902 \brief Receive a message annoucing the creation of a domain on server side 903 \param[in] event Received event 904 */ 905 void CGrid::recvAddDomain(CEventServer& event) 906 { 907 908 CBufferIn* buffer=event.subEvents.begin()->buffer; 909 string id; 910 *buffer>>id ; 911 get(id)->recvAddDomain(*buffer) ; 912 } 913 914 /*! 915 \brief Receive a message annoucing the creation of a domain on server side 916 \param[in] buffer Buffer containing message 917 */ 918 void CGrid::recvAddDomain(CBufferIn& buffer) 919 { 920 string id ; 921 buffer>>id ; 922 addDomain(id) ; 923 } 924 925 /*! 926 \brief Receive a message annoucing the creation of an axis on server side 927 \param[in] event Received event 928 */ 929 void CGrid::recvAddAxis(CEventServer& event) 930 { 931 932 CBufferIn* buffer=event.subEvents.begin()->buffer; 933 string id; 934 *buffer>>id ; 935 get(id)->recvAddAxis(*buffer) ; 936 } 937 938 /*! 939 \brief Receive a message annoucing the creation of an axis on server side 940 \param[in] buffer Buffer containing message 941 */ 942 void CGrid::recvAddAxis(CBufferIn& buffer) 943 { 944 string id ; 945 buffer>>id ; 946 addAxis(id) ; 947 } 948 949 void CGrid::solveDomainAxisRefInheritance(bool apply) 950 { 951 CContext* context = CContext::getCurrent(); 952 unsigned int vecSize, i; 953 std::vector<StdString>::iterator it, itE; 954 setDomainList(); 955 it = domList_.begin(); itE = domList_.end(); 956 for (; it != itE; ++it) 957 { 958 CDomain* pDom = CDomain::get(*it); 959 if (context->hasClient) 960 { 961 pDom->solveRefInheritance(apply); 962 pDom->solveBaseReference(); 963 if ((!pDom->domain_ref.isEmpty()) && (pDom->name.isEmpty())) 964 pDom->name.setValue(pDom->getBaseDomainReference()->getId()); 965 966 } 967 } 968 969 setAxisList(); 970 it = axisList_.begin(); itE = axisList_.end(); 971 for (; it != itE; ++it) 972 { 973 CAxis* pAxis = CAxis::get(*it); 974 if (context->hasClient) 975 { 976 pAxis->solveRefInheritance(apply); 977 pAxis->solveBaseReference(); 978 if ((!pAxis->axis_ref.isEmpty()) && (pAxis->name.isEmpty())) 979 pAxis->name.setValue(pAxis->getBaseAxisReference()->getId()); 980 } 981 } 982 } 983 984 std::vector<CDomain*> CGrid::getDomains() 985 { 986 std::vector<CDomain*> domList; 987 if (!domList_.empty()) 988 { 989 for (int i = 0; i < domList_.size(); ++i) domList.push_back(CDomain::get(domList_[i])); 990 } 991 return domList; 992 } 993 994 std::vector<CAxis*> CGrid::getAxis() 995 { 996 std::vector<CAxis*> aList; 997 if (!axisList_.empty()) 998 for (int i =0; i < axisList_.size(); ++i) aList.push_back(CAxis::get(axisList_[i])); 999 1000 return aList; 1001 } 1002 1003 void CGrid::setDomainList(const std::vector<CDomain*> domains) 1004 { 1005 if (isDomListSet) return; 1006 std::vector<CDomain*> domList = this->getVirtualDomainGroup()->getAllChildren(); 1007 if (!domains.empty() && domList.empty()) domList = domains; 1008 if (!domList.empty()) 1009 { 1010 int sizeDom = domList.size(); 1011 domList_.resize(sizeDom); 1012 for (int i = 0 ; i < sizeDom; ++i) 1013 { 1014 domList_[i] = domList[i]->getId(); 1015 } 1016 isDomListSet = true; 1017 } 1018 1019 } 1020 1021 void CGrid::setAxisList(const std::vector<CAxis*> axis) 1022 { 1023 if (isAxisListSet) return; 1024 std::vector<CAxis*> aList = this->getVirtualAxisGroup()->getAllChildren(); 1025 if (!axis.empty() && aList.empty()) aList = axis; 1026 if (!aList.empty()) 1027 { 1028 int sizeAxis = aList.size(); 1029 axisList_.resize(sizeAxis); 1030 for (int i = 0; i < sizeAxis; ++i) 1031 { 1032 axisList_[i] = aList[i]->getId(); 1033 } 1034 isAxisListSet = true; 1035 } 1036 } 1037 1038 std::vector<StdString> CGrid::getDomainList() 1039 { 1040 setDomainList(); 1041 return domList_; 1042 } 1043 1044 std::vector<StdString> CGrid::getAxisList() 1045 { 1046 setAxisList(); 1047 return axisList_; 1048 } 1049 1050 void CGrid::sendAllDomains() 1051 { 1052 std::vector<CDomain*> domList = this->getVirtualDomainGroup()->getAllChildren(); 1053 int dSize = domList.size(); 1054 for (int i = 0; i < dSize; ++i) 1055 { 1056 sendAddDomain(domList[i]->getId()); 1057 domList[i]->sendAllAttributesToServer(); 1058 } 1059 } 1060 1061 void CGrid::sendAllAxis() 1062 { 1063 std::vector<CAxis*> aList = this->getVirtualAxisGroup()->getAllChildren(); 1064 int aSize = aList.size(); 1065 1066 for (int i = 0; i < aSize; ++i) 1067 { 1068 sendAddAxis(aList[i]->getId()); 1069 aList[i]->sendAllAttributesToServer(); 1070 } 1071 } 1072 1073 void CGrid::parse(xml::CXMLNode & node) 1074 { 1075 SuperClass::parse(node); 1076 1077 if (node.goToChildElement()) 1078 { 1079 int domainIdx = -1; 1080 int posAxis = 0; 1081 StdString domainName("domain"); 1082 StdString axisName("axis"); 1083 do 1084 { 1085 if (node.getElementName() == domainName) { 1086 axisOrder_.push_back(domainIdx); 1087 this->getVirtualDomainGroup()->parseChild(node); 1088 } 1089 if (node.getElementName() == axisName) { 1090 axisOrder_.push_back(posAxis); 1091 ++posAxis; 1092 this->getVirtualAxisGroup()->parseChild(node); 1093 } 1094 } while (node.goToNextElement()) ; 1095 node.goToParentElement(); 1096 } 1097 1098 if (!axisOrder_.empty()) 1099 { 1100 int sizeOrd = axisOrder_.size(); 1101 axisDomOrder.resize(sizeOrd); 1102 for (int i = 0; i < sizeOrd; ++i) 1103 { 1104 axisDomOrder(i) = axisOrder_[i]; 1105 } 1106 } 1107 1108 setDomainList(); 1109 setAxisList(); 1110 } 1111 726 1112 } // namespace xios -
XIOS/trunk/src/node/grid.hpp
r509 r540 18 18 class CGridGroup; 19 19 class CGridAttributes; 20 class CDomainGroup; 21 class CAxisGroup; 20 22 class CGrid; 21 23 … … 44 46 enum EEventId 45 47 { 46 EVENT_ID_INDEX 48 EVENT_ID_INDEX, EVENT_ID_ADD_DOMAIN, EVENT_ID_ADD_AXIS 47 49 } ; 48 50 … … 96 98 void outputField(int rank, const CArray<double,1>& stored, CArray<double,1>& field) ; 97 99 100 virtual void parse(xml::CXMLNode & node); 101 98 102 /// Destructeur /// 99 103 virtual ~CGrid(void); … … 110 114 static CGrid* createGrid(CDomain* domain); 111 115 static CGrid* createGrid(CDomain* domain, CAxis* axis); 116 static CGrid* createGrid(std::vector<CDomain*> domains, std::vector<CAxis*> axis); 112 117 113 118 public : … … 124 129 void solveDomainRef(bool checkAtt); 125 130 void solveAxisRef(bool checkAtt); 131 void solveDomainAxisRefInheritance(bool apply = true); 132 133 void sendAddDomain(const std::string& id=""); 134 void sendAddAxis(const std::string& id=""); 135 void sendAllDomains(); 136 void sendAllAxis(); 137 138 static void recvAddDomain(CEventServer& event) ; 139 void recvAddDomain(CBufferIn& buffer) ; 140 static void recvAddAxis(CEventServer& event) ; 141 void recvAddAxis(CBufferIn& buffer) ; 126 142 127 143 static bool dispatchEvent(CEventServer& event) ; … … 134 150 std::map<int, int> getDomConServerSide(); 135 151 std::map<int, StdSize> getConnectedServerDataSize(); 152 std::vector<StdString> getDomainList(); 153 std::vector<StdString> getAxisList(); 154 std::vector<CDomain*> getDomains(); 155 std::vector<CAxis*> getAxis(); 156 136 157 public: 137 158 … … 167 188 std::map<int, int> domConnectedServerSide_; 168 189 bool isDomConServerComputed_; 190 191 private: 192 void setVirtualDomainGroup(CDomainGroup* newVDomainGroup); 193 void setVirtualDomainGroup(); 194 void setVirtualAxisGroup(CAxisGroup* newVAxisGroup); 195 void setVirtualAxisGroup(); 196 // void setAxisList(); 197 void setAxisList(const std::vector<CAxis*> axis = std::vector<CAxis*>()); 198 // void setDomainList(); 199 void setDomainList(const std::vector<CDomain*> domains = std::vector<CDomain*>()); 200 201 CDomain* addDomain(const std::string& id); 202 CAxis* addAxis(const std::string& id); 203 204 CAxisGroup* getVirtualAxisGroup() const; 205 CDomainGroup* getVirtualDomainGroup() const; 206 private: 207 CDomainGroup* vDomainGroup_; 208 CAxisGroup* vAxisGroup_; 209 std::vector<std::string> axisList_, domList_; 210 bool isAxisListSet, isDomListSet; 211 212 // List order of axis in a grid, if there is a domain, it will take value -1 213 std::vector<int> axisOrder_; 169 214 }; // class CGrid 170 215 -
XIOS/trunk/src/output/nc4_data_output.cpp
r538 r540 489 489 std::vector<StdString> dims; 490 490 StdString axisid = (!axis->name.isEmpty()) 491 ? axis->name.getValue() : axis->getId();491 ? axis->name.getValue() : axis->getId(); 492 492 try 493 493 { … … 504 504 505 505 SuperClassWriter::addAttribute("axis", StdString("Z"), &axisid); 506 507 if (!axis->name.isEmpty()) 508 SuperClassWriter::addAttribute 509 ("name", axis->name.getValue(), &axisid); 506 510 507 511 if (!axis->standard_name.isEmpty()) … … 644 648 } 645 649 646 if (!grid->axis_ref.isEmpty()) 647 { 648 CAxis* axis = grid->axis ; 649 StdString axisid = (!axis->name.isEmpty()) ? axis->name.getValue() : axis->getId(); 650 dims.push_back(axisid); 651 coodinates.push_back(axisid); 650 std::vector<StdString> axisList = grid->getAxisList(); 651 if (!axisList.empty()) 652 { 653 std::vector<StdString>::const_iterator itAxis = axisList.begin(), iteAxis = axisList.end(); 654 for (; itAxis != iteAxis; ++itAxis) 655 { 656 CAxis* axis = CAxis::get(*itAxis); 657 StdString axisid = (!axis->name.isEmpty()) 658 ? axis->name.getValue() : axis->getId(); 659 660 dims.push_back(axisid); 661 coodinates.push_back(axisid); 662 } 652 663 } 653 664
Note: See TracChangeset
for help on using the changeset viewer.