Changeset 122 for XMLIO_V2


Ignore:
Timestamp:
09/20/10 17:30:34 (14 years ago)
Author:
hozdoba
Message:

Plusieurs modifications en attendant une version propre et stable.

Location:
XMLIO_V2/dev/dev_rv/src/XMLIO
Files:
2 added
14 edited

Legend:

Unmodified
Added
Removed
  • XMLIO_V2/dev/dev_rv/src/XMLIO/abstract_data_treatment.hpp

    r120 r122  
    3636         AbstractDataTreatment(Context* const _ctxt) : currentContext(_ctxt), enabledFiles() 
    3737         { 
     38            std::cout << "(Message temporaire) Résolution des héritages ..." << std::endl; 
    3839            // Résolution des héritages pour le context actuel (Context::ResolveInheritance() résoud les héritages pour tous les contextes). 
    3940            solveAllInheritance(); 
    4041 
    4142            // Initialisation du vecteur 'enabledFiles' contenant la liste des fichiers à sortir. 
     43            std::cout << "(Message temporaire) Initialisation du vecteur enabledFiles ..." << std::endl; 
    4244            findEnabledFiles(); 
    4345 
    4446            // Recherche des champs à sortir (enable à true + niveau de sortie correct) pour chaque fichier précédemment listé. 
     47            std::cout << "(Message temporaire) Recherche des champs à sortir ..." << std::endl; 
    4548            findAllEnabledFields(); 
    4649 
    4750            // Résolution des références de grilles pour chacun des champs. 
     51            std::cout << "(Message temporaire) Résolution des références de grilles ..." << std::endl; 
    4852            solveAllGridRef(); 
     53 
     54            std::cout << "(Message temporaire) fin traitement sorties ..." << std::endl; 
    4955         } 
    5056 
     
    5965         void solveAllGridRef(void) 
    6066         { 
    61  
     67            for (unsigned int i = 0; i < enabledFiles.size(); i++) 
     68               enabledFiles[i]->solveEFGridRef(); 
    6269         } 
    6370 
  • XMLIO_V2/dev/dev_rv/src/XMLIO/attribut.hpp

    r120 r122  
    8585 
    8686   template <> 
     87      ostream& Attribut<Array<double,1> >::print(ostream & o) const 
     88   { 
     89      if (_hasValue) o << " " << getName() << "=\"" << value(0); 
     90      for (int i = 1; i < value.size(); i++) { o << "," << value(i); } 
     91      o << "\"" ; 
     92      return (o) ; 
     93   } 
     94 
     95   template <> 
     96      void Attribut<Array<double,1> >::setFromString(const std::string& str) 
     97   { 
     98      istringstream iss(str) ; 
     99      char c = '\0'; double d = 0.; 
     100      vector<double> vect; 
     101      Array<double, 1> arr; 
     102 
     103      iss >> d; vect.push_back(d); 
     104      while(!iss.eof ()) { iss >> c >> d; vect.push_back(d); } 
     105 
     106      arr.resize(vect.size()); 
     107      for (unsigned int i = 0; i < vect.size(); i++) arr(i) = vect[i]; 
     108 
     109      this->setValue(arr); 
     110   } 
     111 
     112   template <> 
    87113      void Attribut<bool>::setFromString(const std::string& str) 
    88114   { 
  • XMLIO_V2/dev/dev_rv/src/XMLIO/base_attribut.hpp

    r120 r122  
    1717         virtual ostream & print(ostream& o) const = 0  ; 
    1818 
    19          friend ostream& operator <<(ostream& o,const BaseAttribut& Attr) { return (Attr.print(o)) ; } 
     19         friend ostream& operator <<(ostream& o,const BaseAttribut& attr) { return (attr.print(o)) ; } 
    2020 
    2121         bool hasId(void) const { return (true); } 
  • XMLIO_V2/dev/dev_rv/src/XMLIO/c_interface.cpp

    r120 r122  
    1212   try 
    1313   { 
    14       string file("/local/XMLIOSERVER_DEV/dev_rv/test/iodef_test.xml"); 
     14      //string file("/local/XMLIOSERVER_DEV/dev_rv/test/iodef_test.xml"); 
    1515      //string file("/local/XMLIOSERVER_DEV/dev_rv/iodef_test.xml"); 
     16      string file("/local/XMLIOSERVER_DEV/dev_rv/test/iodef_simple_test.xml"); 
    1617 
    1718      ifstream istr( file.c_str() , ifstream::in ); 
     
    2829      Context::SetCurrentContext("context1") ; 
    2930 
     31      std::cout << " * ----------- <<<TOP>>> Début du traitement ----------- * " << std::endl; 
    3032      // On crée une instance de traitement de données dans le format NetCDF4. 
    3133      AbstractDataTreatment *dtreat = new NetCDF4DataTreatment(Context::GetObject("context1")); 
    3234 
    3335      // Affichage de la liste des fichiers à sortir (par id). 
    34       dtreat->printEnabledFilesId(); 
     36      //dtreat->printEnabledFilesId(); 
     37 
     38      NetCDF4DataOutput dop(CFile::GetObject("fichier1")); 
     39      dop.createFileAndHeader(); 
    3540 
    3641      // On écrit l'arborescence résultante du traitement sur la sortie. 
  • XMLIO_V2/dev/dev_rv/src/XMLIO/context.hpp

    r120 r122  
    1010 
    1111         Context(void) : ObjectTemplate<Context>(), ccalendar(NULL), 
    12             fieldDef(NULL), fileDef(NULL), axisDef(NULL), gridDef(NULL) 
     12            fieldDef(NULL), fileDef(NULL), axisDef(NULL), gridDef(NULL), domainDef(NULL) 
    1313         {/* Ne rien faire de plus */} 
    1414 
    1515         Context(const string& _id) : ObjectTemplate<Context>(_id), ccalendar(NULL), 
    16             fieldDef(NULL), fileDef(NULL), axisDef(NULL), gridDef(NULL) 
     16            fieldDef(NULL), fileDef(NULL), axisDef(NULL), gridDef(NULL), domainDef(NULL) 
    1717         {/* Ne rien faire de plus */} 
    1818 
     
    2020         { 
    2121            os << NIndent << "<?xml version=\"1.0\"?>" << std::endl; 
    22             os << NIndent << "<"<< Context::GetRootName() << ">" << std::endl; 
     22            os << NIndent << "<" << Context::GetRootName() << ">" << std::endl; 
    2323 
    2424            Poco::HashMap<string, StrHashMap<Context> > &AllListContext = Context::GetAllListObject(); 
     
    5959 
    6060            // Changement de context pour les champs et groupes de champs. 
    61             FieldGroup::SetContext(id); CField::SetContext(id); 
     61            FieldGroup::SetContext(id);  CField::SetContext(id); 
    6262 
    6363            // Changement de context pour les fichiers et groupes de fichiers. 
    64             FileGroup::SetContext(id);  CFile::SetContext(id); 
     64            FileGroup::SetContext(id);   CFile::SetContext(id); 
    6565 
    6666            // Changement de context pour les grilles et groupes de grilles. 
    67             GridGroup::SetContext(id);  CGrid::SetContext(id); 
     67            GridGroup::SetContext(id);   CGrid::SetContext(id); 
    6868 
    6969            // Changement de context pour les axes et groupes d'axes. 
    70             AxisGroup::SetContext(id);  CAxis::SetContext(id); 
     70            AxisGroup::SetContext(id);   CAxis::SetContext(id); 
     71 
     72            // Changement de context pour les domaines et groupes de domaines. 
     73            DomainGroup::SetContext(id); CDomain::SetContext(id); 
    7174         } 
    7275 
     
    9295                  { WARNING("Le noeud de définition possÚde un identifiant, ce dernier ne sera pas pris en compte lors du traitement !"); } 
    9396 
    94                   if (name.compare(FieldDefinition::GetDefName()) == 0) // Parsing pour la définition des champs. 
    95                   { fieldDef = CreateInstanceAndParse<FieldDefinition>(_node, FieldDefinition::GetDefName().c_str()); continue; } 
     97                  if (attributes.end() != attributes.find("calendar_type") && attributes.end() != attributes.find("start_date")) 
     98                     setCalendar(attributes["calendar_type"], attributes["start_date"]); 
    9699 
    97                   if (name.compare(FileDefinition::GetDefName()) == 0) // Parsing pour la définition des fichiers. 
    98                   { fileDef  = CreateInstanceAndParse<FileDefinition >(_node, FileDefinition ::GetDefName().c_str()); continue; } 
    99100 
    100                   if (name.compare(AxisDefinition::GetDefName()) == 0) // Parsing pour la définition des axes. 
    101                   { axisDef  = CreateInstanceAndParse<AxisDefinition >(_node, AxisDefinition ::GetDefName().c_str()); continue; } 
     101                  if (name.compare(FieldDefinition::GetDefName())  == 0) // Parsing pour la définition des champs. 
     102                  { fieldDef  = CreateInstanceAndParse<FieldDefinition >(_node, FieldDefinition::GetDefName().c_str()); continue; } 
    102103 
    103                   if (name.compare(GridDefinition::GetDefName()) == 0) // Parsing pour la définition des grilles. 
    104                   { gridDef  = CreateInstanceAndParse<GridDefinition >(_node, GridDefinition ::GetDefName().c_str()); continue; } 
     104                  if (name.compare(FileDefinition::GetDefName())  == 0) // Parsing pour la définition des fichiers. 
     105                  { fileDef   = CreateInstanceAndParse<FileDefinition  >(_node, FileDefinition  ::GetDefName().c_str()); continue; } 
     106 
     107                  if (name.compare(AxisDefinition::GetDefName())  == 0) // Parsing pour la définition des axes. 
     108                  { axisDef   = CreateInstanceAndParse<AxisDefinition  >(_node, AxisDefinition  ::GetDefName().c_str()); continue; } 
     109 
     110                  if (name.compare(GridDefinition::GetDefName())  == 0) // Parsing pour la définition des grilles. 
     111                  { gridDef   = CreateInstanceAndParse<GridDefinition  >(_node, GridDefinition  ::GetDefName().c_str()); continue; } 
     112 
     113                  if (name.compare(DomainDefinition::GetDefName()) == 0) // Parsing pour la définition des domaines. 
     114                  { domainDef = CreateInstanceAndParse<DomainDefinition>(_node, DomainDefinition::GetDefName().c_str()); continue; } 
    105115 
    106116                  WARNING("La définition est invalide, seuls les champs, grilles, axes et fichiers peuvent être définis !"); 
     
    116126 
    117127         virtual bool hasChild(void) const 
    118          { return ((fieldDef != NULL) or (fileDef != NULL)  or (axisDef != NULL) or (gridDef != NULL)); } 
     128         { return ((fieldDef != NULL) or (fileDef != NULL)  or (axisDef != NULL) or (gridDef != NULL) or (domainDef != NULL)); } 
    119129 
    120130         virtual void printChild(ostream& out) const 
    121131         { 
    122             if(fieldDef != NULL) out << *(FieldGroup*)     fieldDef << std::endl; 
    123             if(fileDef  != NULL) out << *(FileGroup*)      fileDef  << std::endl; 
    124             if(axisDef  != NULL) out << *(AxisDefinition*) axisDef  << std::endl; 
    125             if(gridDef  != NULL) out << *(GridDefinition*) gridDef  << std::endl; 
     132            if(fieldDef  != NULL) out << *(FieldGroup*)       fieldDef  << std::endl; 
     133            if(fileDef   != NULL) out << *(FileGroup*)        fileDef   << std::endl; 
     134            if(axisDef   != NULL) out << *(AxisDefinition*)   axisDef   << std::endl; 
     135            if(gridDef   != NULL) out << *(GridDefinition*)   gridDef   << std::endl; 
     136            if(domainDef != NULL) out << *(DomainDefinition*) domainDef << std::endl; 
    126137         } 
    127138 
     
    130141            if (_parent != 0) return; 
    131142            // Résolution des héritages descendants pour chacun des groupes de définitions. 
    132             if(fieldDef != NULL) fieldDef->resolveDescInheritance(); 
    133             if(fileDef  != NULL) fileDef ->resolveDescInheritance(); 
    134             if(axisDef  != NULL) axisDef ->resolveDescInheritance(); 
    135             if(gridDef  != NULL) gridDef ->resolveDescInheritance(); 
     143            if(fieldDef  != NULL) fieldDef ->resolveDescInheritance(); 
     144            if(fileDef   != NULL) fileDef  ->resolveDescInheritance(); 
     145            if(axisDef   != NULL) axisDef  ->resolveDescInheritance(); 
     146            if(gridDef   != NULL) gridDef  ->resolveDescInheritance(); 
     147            if(domainDef != NULL) domainDef->resolveDescInheritance(); 
    136148         } 
    137149 
    138          FieldDefinition* getFieldDefinition(void) const { return (this->fieldDef); } 
    139          FileDefinition * getFileDefinition(void)  const { return (this->fileDef ); } 
    140          AxisDefinition * getAxisDefinition(void)  const { return (this->axisDef ); } 
    141          GridDefinition * getGridDefinition(void)  const { return (this->gridDef ); } 
     150         FieldDefinition  * getFieldDefinition(void)  const { return (this->fieldDef ); } 
     151         FileDefinition   * getFileDefinition(void)   const { return (this->fileDef  ); } 
     152         AxisDefinition   * getAxisDefinition(void)   const { return (this->axisDef  ); } 
     153         GridDefinition   * getGridDefinition(void)   const { return (this->gridDef  ); } 
     154         DomainDefinition * getDomainDefinition(void) const { return (this->domainDef); } 
    142155 
    143156         AbstractCalendar * getCalendar(void) const { return (this->ccalendar ); } 
     
    163176         { 
    164177            // Désallocation dynamique de mémoire pour chacun des groupes de définition si nécessaire. 
    165             if(fieldDef != NULL) delete fieldDef; if(fileDef  != NULL) delete fileDef ; 
    166             if(axisDef  != NULL) delete axisDef ; if(gridDef  != NULL) delete gridDef ; 
     178            if(fieldDef  != NULL) delete fieldDef  ; if(fileDef  != NULL) delete fileDef ; 
     179            if(axisDef   != NULL) delete axisDef   ; if(gridDef  != NULL) delete gridDef ; 
     180            if(domainDef != NULL) delete domainDef ; 
    167181 
    168182            // Désallocation dynamique de mémoire pour le calendrier associé au contexte courant si nécessaire. 
     
    178192         AxisDefinition*   axisDef; 
    179193         GridDefinition*   gridDef; 
     194         DomainDefinition* domainDef; 
    180195 
    181196   }; //class Context 
  • XMLIO_V2/dev/dev_rv/src/XMLIO/domain.hpp

    r120 r122  
    3131 
    3232      // domaine global 
    33       if (!ni_glo.hasValue() || ni_glo<=0 ) ERROR("domaine global mal defini") ; 
    34       if (!nj_glo.hasValue() || nj_glo<=0 ) ERROR("domaine global mal defini") ; 
     33      if (!ni_glo.hasValue() || ni_glo<=0 ) throw XMLIOSERVER::XMLIOUndefinedValueException("domaine global mal defini") ; 
     34      if (!nj_glo.hasValue() || nj_glo<=0 ) throw XMLIOSERVER::XMLIOUndefinedValueException("domaine global mal defini") ; 
    3535 
    3636      //domaine local en i 
    3737      if ( ni.hasValue() && ibegin.hasValue()) 
    3838      { 
    39          if (iend.hasValue() && iend!=ibegin+ni-1) ERROR("domain local mal défini 1") ; 
    40          iend=ibegin+ni-1 ; 
     39         if (iend.hasValue() && iend!=ibegin+ni-1) throw XMLIOSERVER::XMLIOUndefinedValueException("domain local mal défini 1") ; 
     40         iend = ibegin + ni - 1 ; 
    4141      } 
    4242      else if (ni.hasValue() && iend.hasValue()) 
    4343      { 
    44          if (ibegin!=ni-iend+1) ERROR("domain local mal défini 2") ; 
    45          ibegin=ni-iend+1 ; 
     44         if (ibegin != ni-iend+1) throw XMLIOSERVER::XMLIOUndefinedValueException("domain local mal défini 2") ; 
     45         ibegin = ni - iend + 1 ; 
    4646      } 
    4747      else if (ibegin.hasValue() && iend.hasValue()) 
    4848      { 
    49          if (ni!=iend-ibegin-1) ERROR("domain local mal défini 3") ; 
    50          ni=iend-ibegin-1 ; 
     49         if (ni!=iend-ibegin-1) throw XMLIOSERVER::XMLIOUndefinedValueException("domain local mal défini 3") ; 
     50         ni = iend - ibegin - 1 ; 
    5151      } 
    52       else ERROR("domain local non défini 4") ; 
     52      else throw XMLIOSERVER::XMLIOUndefinedValueException("domain local non défini 4") ; 
    5353 
    54       if (ni<0 || ibegin>iend || ibegin<1 || iend>ni_glo) ERROR("domain local mal défini 5") ; 
     54      if (ni<0 || ibegin>iend || ibegin<1 || iend>ni_glo) throw XMLIOSERVER::XMLIOUndefinedValueException("domain local mal défini 5") ; 
    5555 
    5656      //domaine local en j 
    5757      if ( nj.hasValue() && jbegin.hasValue()) 
    5858      { 
    59          if (jend.hasValue() && jend!=jbegin+nj-1) ERROR("domain local mal défini 6") ; 
    60          jend=jbegin+nj-1 ; 
     59         if (jend.hasValue() && jend!=jbegin+nj-1) throw XMLIOSERVER::XMLIOUndefinedValueException("domain local mal défini 6") ; 
     60         jend = jbegin + nj - 1 ; 
    6161      } 
    6262      else if (nj.hasValue() && jend.hasValue()) 
    6363      { 
    64          if (jbegin!=nj-jend+1) ERROR("domain local mal défini 7") ; 
    65          jbegin=nj-jend+1 ; 
     64         if (jbegin!=nj-jend+1) throw XMLIOSERVER::XMLIOUndefinedValueException("domain local mal défini 7") ; 
     65         jbegin = nj - jend + 1 ; 
    6666      } 
    6767      else if (jbegin.hasValue() && jend.hasValue()) 
    6868      { 
    69          if (nj!=jend-jbegin-1) ERROR("domain local mal défini 8") ; 
    70          nj=jend-jbegin-1 ; 
     69         if (nj!=jend-jbegin-1) throw XMLIOSERVER::XMLIOUndefinedValueException("domain local mal défini 8") ; 
     70         nj = jend - jbegin - 1 ; 
    7171      } 
    72       else ERROR("domain local non défini 9") ; 
     72      else throw XMLIOSERVER::XMLIOUndefinedValueException("domain local non défini 9") ; 
    7373 
    74       if (nj<0 || jbegin>jend || jbegin<1 || jend>nj_glo) ERROR("domain local mal défini 10") ; 
     74      if (nj<0 || jbegin>jend || jbegin<1 || jend>nj_glo) throw XMLIOSERVER::XMLIOUndefinedValueException("domain local mal défini 10") ; 
    7575 
    76       cout<<"mask ni "<<mask->extent(0)<<" nj "<<mask->extent(1)<<"  "<<mask<<endl ; 
     76      //cout<<"mask ni "<<mask->extent(0)<<" nj "<<mask->extent(1)<<"  "<<mask<<endl ; 
    7777      if (mask.hasValue()) 
    78          if (mask->extent(0) != ni || mask->extent(1) != nj) ERROR("le champ mask n'a pas la même taille que le domaine local") ; 
     78         if (mask->extent(0) != ni || mask->extent(1) != nj) 
     79            throw XMLIOSERVER::XMLIOUndefinedValueException("le champ mask n'a pas la même taille que le domaine local") ; 
    7980 
    8081      if (data_dim.hasValue()) 
    8182      { 
    82          if (!(data_dim==1 || data_dim==2)) ERROR("dimension non comptatible (doit être 1 ou 2)") ; 
     83         if (!(data_dim==1 || data_dim==2)) throw XMLIOSERVER::XMLIOUndefinedValueException("dimension non comptatible (doit être 1 ou 2)") ; 
    8384      } 
    84       else ERROR("Dimension des donnée non définie") ; 
     85      else throw XMLIOSERVER::XMLIOUndefinedValueException("Dimension des donnée non définie") ; 
    8586 
    8687      if (data_ni.hasValue()) 
    8788      { 
    88          if (data_ni<=0) ERROR("Dimension des données négative") ; 
     89         if (data_ni<=0) throw XMLIOSERVER::XMLIOUndefinedValueException("Dimension des données négative") ; 
    8990      } 
    9091      else 
     
    9899      if (data_nj.hasValue()) 
    99100      { 
    100          if (data_nj<=0) ERROR("Dimension des données négative") ; 
     101         if (data_nj<=0) throw XMLIOSERVER::XMLIOUndefinedValueException("Dimension des données négative") ; 
    101102      } 
    102103      else data_nj=(int) nj ; 
     
    105106 
    106107      if (!mask.hasValue()) 
    107       { 
     108      { // Si aucun masque n'est défini, on en crée un nouveau qui valide l'intégralité du domaine. 
    108109         mask->resize(shape(ni,nj)) ; 
    109110         *mask=true ; 
     
    116117         if (data_n_index.hasValue()) 
    117118         { 
    118             if (data_n_index!=data_i_index->extent(0)) ERROR("Dimension data_i_index incompatible avec data_n_index") ; 
     119            if (data_n_index!=data_i_index->extent(0)) 
     120               throw XMLIOSERVER::XMLIOUndefinedValueException("Dimension data_i_index incompatible avec data_n_index") ; 
    119121         } 
    120122         else data_n_index=data_i_index->extent(0) ; 
     
    125127            { 
    126128               if (data_j_index->extent(0)!=data_i_index->extent(0)) 
    127                ERROR("Dimension data_j_index incompatible avec data_i_index") ; 
     129                  throw XMLIOSERVER::XMLIOUndefinedValueException("Dimension data_j_index incompatible avec data_i_index") ; 
    128130            } 
    129             else ERROR("data_j_index non défini") ; 
     131            else throw XMLIOSERVER::XMLIOUndefinedValueException("data_j_index non défini") ; 
    130132         } 
    131133      } 
    132134      else 
    133135      { 
    134          if (data_n_index.hasValue() || (data_dim==2 && data_j_index.hasValue())) ERROR("data_i_index non défini") ; 
     136         if (data_n_index.hasValue() || (data_dim==2 && data_j_index.hasValue())) 
     137            throw XMLIOSERVER::XMLIOUndefinedValueException("data_i_index non défini") ; 
    135138      } 
    136       cout<<"data_n_index.hasValue() "<<data_n_index.hasValue()<<endl ; 
     139      //cout<<"data_n_index.hasValue() "<<data_n_index.hasValue()<<endl ; 
    137140      if (!data_n_index.hasValue()) 
    138141      { 
     
    141144            int i ; 
    142145            data_n_index=*data_ni ; 
    143             cout <<"data_n_index "<<data_n_index<<"  "<<data_ni<<" "<<data_nj<<endl ; 
     146            //cout <<"data_n_index "<<data_n_index<<"  "<<data_ni<<" "<<data_nj<<endl ; 
    144147 
    145148            data_i_index->resize(data_n_index) ; 
    146149 
    147150            for (i=0;i<data_ni;i++) (*data_i_index)(i)=i ; 
    148             cout <<"data_i_index "<<*data_i_index<<endl ; 
     151            //cout <<"data_i_index "<<*data_i_index<<endl ; 
    149152         } 
    150153         else   // data_dim=2 
     
    154157            int count ; 
    155158 
    156             data_n_index=data_ni*data_nj ; 
    157             data_i_index-> resize(data_n_index) ; 
    158             data_j_index-> resize(data_n_index) ; 
    159             for(count=0,i=0;i<data_ni;i++) 
    160                for(j=0;j<data_nj;j++) 
     159            data_n_index = data_ni * data_nj ; 
     160            data_i_index -> resize(data_n_index) ; 
     161            data_j_index -> resize(data_n_index) ; 
     162            for(count=0,i=0; i<data_ni;i++) 
     163               for(j=0; j<data_nj;j++) 
    161164               { 
    162165                  (*data_i_index)(count)=i ; 
    163                   cout<<count<<"  "<<(*data_i_index)(count)<<endl ; 
     166                 // cout<<count<<"  "<<(*data_i_index)(count)<<endl ; 
    164167                  (*data_j_index)(count)=j ; 
    165                   cout<<count<<"  "<<(*data_j_index)(count)<<endl ; 
     168                  //cout<<count<<"  "<<(*data_j_index)(count)<<endl ; 
    166169                  count++ ; 
    167170               } 
    168                cout<<data_ni<<" "<<data_nj<<" "<<data_n_index<<" "<<*data_i_index<<" "<<*data_j_index<<endl ; 
     171               //cout<<data_ni<<" "<<data_nj<<" "<<data_n_index<<" "<<*data_i_index<<" "<<*data_j_index<<endl ; 
    169172         } 
    170173      } 
  • XMLIO_V2/dev/dev_rv/src/XMLIO/field.hpp

    r120 r122  
    1818         {/* Ne rien faire de plus */} 
    1919 
    20          static string GetName(void) {return ("field"); } 
     20         static string GetName(void) { return ("field"); } 
    2121 
    2222         inline void SolveGridRef(void) ; 
    2323 
    24          CGrid* getGrid(void) const { return (grid); } 
     24         const CGrid* getGrid(void) const { return (grid); } 
    2525 
    2626         virtual CField* getReference(void) const 
  • XMLIO_V2/dev/dev_rv/src/XMLIO/field_gridrefsolver.hpp

    r120 r122  
    99      CAxis* axis = NULL ; 
    1010 
    11       if (domain_ref.hasValue()) 
     11     if (domain_ref.hasValue()) 
    1212      { 
    1313         if (CDomain::HasObject(domain_ref)) domain = CDomain::GetObject(domain_ref) ; 
    14          else ERROR("Référence au domaine incorrecte") ; 
     14         else throw XMLIOSERVER::XMLIOUndefinedValueException("Référence au domaine nommé \'"+ (string)domain_ref +"\' incorrecte") ; 
    1515      } 
    1616 
     
    1818      { 
    1919         if (CAxis::HasObject(axis_ref)) axis = CAxis::GetObject(axis_ref) ; 
    20          else ERROR("Référence a l'axe incorrecte") ; 
     20         else throw XMLIOSERVER::XMLIOUndefinedValueException("Référence à l'axe nommé \'"+ (string)axis_ref +"\' incorrecte") ; 
    2121      } 
    2222 
    2323      if (grid_ref.hasValue()) 
    2424      { 
    25          if (CGrid::HasObject(axis_ref)) grid = CGrid::GetObject(grid_ref) ; 
    26          else ERROR("Référence a la grille incorrecte") ; 
     25         if (CGrid::HasObject(grid_ref)) grid = CGrid::GetObject(grid_ref) ; 
     26         else throw XMLIOSERVER::XMLIOUndefinedValueException("Référence à la grille nommée \'"+ (string)grid_ref +"\' incorrecte"); 
    2727      } 
    2828 
  • XMLIO_V2/dev/dev_rv/src/XMLIO/file.hpp

    r120 r122  
    1111      public: 
    1212 
    13          CFile(void) : ObjectTemplate<CFile>(), FileAttribut(), vfieldGroup(NULL), enabledFields() 
     13         CFile(void) : ObjectTemplate<CFile>(), FileAttribut(), vfieldGroup(NULL), enabledFields(), output(NULL) 
    1414         {/* Ne rien faire de plus */} 
    15          CFile(const string& _id) : ObjectTemplate<CFile>(_id), FileAttribut(), vfieldGroup(NULL), enabledFields() 
     15         CFile(const string& _id) : ObjectTemplate<CFile>(_id), FileAttribut(), vfieldGroup(NULL), enabledFields(), output(NULL) 
    1616         {/* Ne rien faire de plus */} 
    1717 
     
    3636         } 
    3737 
     38         const AbstractDataOutput* getDataOutput(void) const { return (output); } 
     39         void initializeDataOutput(AbstractDataOutput* _output) 
     40         { 
     41            if (_output != NULL) output = _output; 
     42            else throw XMLIOSERVER::XMLIOUndefinedValueException("Impossible d'initialiser la sortie de données pour le fichier nommé '"+ getId() +"'.") ; 
     43         } 
     44 
    3845         void getAllFields(std::vector<CField*>& _allF) const {  if (vfieldGroup!=NULL) vfieldGroup->getAllChildren(_allF); } 
     46         const std::vector<CField*>& getEnabledFields(void) const { return (enabledFields); } 
     47 
     48         const std::set<const CGrid*> getEnabledGrids(void) const 
     49         { 
     50            std::set<const CGrid*> sgrid; 
     51            const std::vector<CField*> enabledFields = getEnabledFields(); 
     52            std::vector<CField*>::const_iterator it; 
     53 
     54            for ( it = enabledFields.begin() ; it != enabledFields.end(); it++ ) 
     55               sgrid.insert((*it)->getGrid()); 
     56 
     57            return (sgrid); 
     58         } 
     59 
     60         const std::set<const CDomain*> getEnabledDomains(void) const 
     61         { 
     62            const std::set<const CGrid*> sgrid = getEnabledGrids(); 
     63            std::set<const CDomain*> sdomain; 
     64 
     65            std::set<const CGrid*>::const_iterator it; 
     66 
     67            for ( it = sgrid.begin() ; it != sgrid.end(); it++ ) 
     68               sdomain.insert((*it)->getRelDomain()); 
     69 
     70            return (sdomain); 
     71         } 
     72 
     73         const std::set<const CAxis*> getEnabledAxis(void) const 
     74         { 
     75            const std::set<const CGrid*> sgrid = getEnabledGrids(); 
     76            std::set<const CAxis*> saxis; 
     77 
     78            std::set<const CGrid*>::const_iterator it; 
     79 
     80            for ( it = sgrid.begin() ; it != sgrid.end(); it++ ) 
     81               saxis.insert((*it)->getRelAxis()); 
     82 
     83            return (saxis); 
     84         } 
    3985 
    4086         virtual bool hasChild(void) const { return (vfieldGroup != NULL); } 
     87         virtual void printChild(ostream& out) const { out << *vfieldGroup << std::endl; } 
    4188 
    42          virtual void printChild(ostream& out) const { out << *vfieldGroup << std::endl; } 
    43          /*{ // Sortie sans affichage des groupes. 
    44             std::vector<CField*> allF; getAllFields(allF); 
    45             for (unsigned int i = 0; i < allF.size(); i++) 
    46                out << *(allF[i]) << std::endl; 
    47          }*/ 
    48  
    49          virtual void resolveDescInheritance(const AttributRegistrar* _parent = 0) 
     89         virtual void resolveDescInheritance(const AttributRegistrar* const _parent = 0) 
    5090         { addAttributes(*_parent); if(vfieldGroup != NULL) vfieldGroup->resolveDescInheritance(); } 
    5191 
     
    65105            getAllFields(enabledFields); 
    66106 
    67             for ( it = enabledFields.begin() ; it < enabledFields.end(); it++ ) 
     107            for ( it = enabledFields.begin() ; it != enabledFields.end(); it++ ) 
    68108            { 
    69109               if ((*it)->enabled.hasValue()) // Si l'attribut 'enabled' est défini ... 
     
    88128                  { enabledFields.erase(it); continue; } 
    89129               } 
    90  
    91130            } 
    92131         } 
    93132 
     133         void solveEFGridRef(void) 
     134         { 
     135            for (unsigned int i = 0; i < enabledFields.size(); i++) 
     136               enabledFields[i]->SolveGridRef(); 
     137         } 
     138 
    94139         virtual  ~CFile(void) 
    95          { if(vfieldGroup != NULL) delete vfieldGroup; } 
     140         { 
     141            if(vfieldGroup != NULL) delete vfieldGroup; 
     142            if(output != NULL) delete output; 
     143         } 
    96144 
    97145      private : 
    98146 
    99147         FieldGroup* vfieldGroup; // FieldGroup "virtuel" 
    100          std::vector<CField*> enabledFields; 
     148         std::vector<CField*> enabledFields; // Liste des champs à sortie dans le fichier courant. 
     149         AbstractDataOutput* output; // Gestion de la sortie des données. 
    101150 
    102151   }; // class CFile 
  • XMLIO_V2/dev/dev_rv/src/XMLIO/grid.hpp

    r120 r122  
    1313         CGrid(void) : ObjectTemplate<CGrid>(), GridAttribut(), hasAxis(false), axis(NULL), domain(NULL) 
    1414         { /* Ne rien faire de plus */ } 
     15 
    1516         CGrid(const string& _id) : ObjectTemplate<CGrid>(_id), GridAttribut(), hasAxis(false), axis(NULL), domain(NULL) 
    1617         { /* Ne rien faire de plus */ } 
    1718 
    1819         static string GetName(void) { return ("grid"); } 
     20 
     21         const CAxis* getRelAxis(void) const { return (axis); } 
     22         const CDomain* getRelDomain(void) const { return (domain); } 
    1923 
    2024         inline void solveReference(void) ; 
     
    2428         inline void computeIndex(void); 
    2529 
    26          inline void storeField(const Array<double,1>& field, Array<double,1>& stored); 
    27          inline void storeField(const Array<double,2>& field, Array<double,1>& stored); 
    28          inline void storeField(const Array<double,3>& field, Array<double,1>& stored); 
    29          inline void storeField(const double* const data, Array<double,1>& stored); 
    30  
    31          inline void outputField(const Array<double,1>& stored, Array<double,2>& outField); 
    32          inline void outputField(const Array<double,1>& stored, Array<double,3>& outField); 
     30         bool _hasAxis(void) const { return (hasAxis); } 
     31 
     32         inline void storeField(const Array<double, 1>& field, Array<double, 1>& stored); 
     33         inline void storeField(const Array<double, 2>& field, Array<double, 1>& stored); 
     34         inline void storeField(const Array<double, 3>& field, Array<double, 1>& stored); 
     35         inline void storeField(const double* const data, Array<double, 1>& stored); 
     36 
     37         inline void outputField(const Array<double,1>& stored, Array<double, 2>& outField); 
     38         inline void outputField(const Array<double,1>& stored, Array<double, 3>& outField); 
    3339 
    3440         inline static CGrid* CreateObject(const CDomain* const a_domain, const CAxis* const a_axis); 
     
    7783   void CGrid::solveReference(void) 
    7884   { 
     85 
    7986      static bool isReferenceSolved = false; 
    8087      if (isReferenceSolved) return; 
     
    94101         if (CDomain::HasObject(domain_ref)) 
    95102         { 
    96            domain=CDomain::GetObject(domain_ref) ; 
     103           domain = CDomain::GetObject(domain_ref) ; 
    97104           domain->check() ; 
    98105         } 
     
    115122   void CGrid::computeIndex(void) 
    116123   { 
     124 
    117125      int ni = domain->ni ; 
    118126      int nj = domain->nj ; 
     
    123131      int data_jbegin  = (data_dim == 2) ? (int)domain->data_jbegin : -1; 
    124132 
    125       Array<int,1>& data_i_index =* domain->data_i_index ; 
    126       Array<int,1>& data_j_index =* domain->data_j_index ; 
    127       Array<bool,2>& mask =* domain->mask ; 
     133      Array<int, 1>& data_i_index =* domain->data_i_index ; 
     134      Array<int, 1>& data_j_index =* domain->data_j_index ; 
     135      Array<bool, 2>& mask =* domain->mask ; 
    128136      int i, j, l, n ; 
    129137      int count, indexCount ; 
     
    131139      for(indexCount=0, l=0; l<size ; l++) 
    132140      { 
    133          for(n=0, indexCount=0; n<data_n_index; n++) 
     141         for(n=0; n<data_n_index; n++) 
    134142         { 
    135143            if (data_dim == 1) 
     
    137145               i = (data_i_index(n) + data_ibegin) % ni ; 
    138146               j = (data_i_index(n) + data_ibegin) / ni ; 
    139                cout<<i<<" "<<j<<" "<<mask(i,j)<<endl ; 
     147               //cout<<i<<" "<<j<<" "<<mask(i,j)<<endl ; 
    140148            } 
    141149            else 
     
    143151               i = data_i_index(n) + data_ibegin ; 
    144152               j = data_j_index(n) + data_jbegin ; 
    145                cout<<i<<" "<<j<<" "<<mask(i,j)<<endl ; 
     153               //cout<<i<<" "<<j<<" "<<mask(i,j)<<endl ; 
    146154            } 
    147155 
     
    157165      for(count=0, indexCount=0, l=0; l<size; l++) 
    158166      { 
    159          for(n=0; n<data_n_index; n++) 
     167         for(n=0; n<data_n_index; n++, count++) 
    160168         { 
    161169            if (data_dim == 1) 
     
    164172               j = (data_i_index(n) + data_ibegin) / ni ; 
    165173            } 
    166             else 
     174            else // (dat_dim == 2) 
    167175            { 
    168176               i = data_i_index(n) + data_ibegin ; 
     
    172180            if (i>=0 && i<ni && j>=0 && j<nj && mask(i,j)) 
    173181            { 
    174                storeIndex(indexCount) = n ; 
     182               storeIndex(indexCount) = count ; 
    175183               out_l_index(indexCount) = l ; 
    176184               out_i_index(indexCount) = i ; 
     
    178186               indexCount++ ; 
    179187            } 
    180             count++ ; 
    181188         } 
    182189      } 
    183190 
     191      /** Pour tests 
     192 
    184193      cout << "Out of CGrid::ComputeIndex" << endl ; 
     194 
     195      cout << "storeIndex : " << endl ; 
    185196      cout << storeIndex << endl ; 
     197 
     198      cout << "out_i_index : " << endl ; 
    186199      cout << out_i_index << endl ; 
     200 
     201      cout << "out_j_index : " << endl ; 
    187202      cout << out_j_index << endl ; 
     203 
     204      cout << "out_l_index : " << endl ; 
    188205      cout << out_l_index << endl ; 
     206 
     207      **/ 
     208 
    189209   } 
    190210 
  • XMLIO_V2/dev/dev_rv/src/XMLIO/group_template.hpp

    r120 r122  
    3030         } 
    3131 
    32          virtual void resolveDescInheritance(const AttributRegistrar* _parent = 0) 
     32         virtual void resolveDescInheritance(const AttributRegistrar* const _parent = 0) 
    3333         { 
    3434            const vector<T*>&  childvect = childList.getVector(); 
     
    112112 
    113113      protected: 
    114  
    115114 
    116115         template <class W> void _parse (XMLNode& _node, bool _withAttr = true) 
  • XMLIO_V2/dev/dev_rv/src/XMLIO/logger.hpp

    r120 r122  
    33 
    44// Entête Poco logging 
    5 #include <Poco/Logger.h> 
    6 #include <Poco/PatternFormatter.h> 
    7 #include <Poco/FormattingChannel.h> 
    8 #include <Poco/ConsoleChannel.h> 
    9 #include <Poco/FileChannel.h> 
    10 #include <Poco/Message.h> 
    11  
    12 #include <Poco/AutoPtr.h> 
    13  
    145#include <csignal> 
    156 
     
    1910#endif // __GNUC__ 
    2011 
    21 // Classes utilisées issues de Poco 
    22 using Poco::Logger; 
    23 using Poco::PatternFormatter; 
    24 using Poco::FormattingChannel; 
    25 using Poco::ConsoleChannel; 
    26 using Poco::FileChannel; 
    27 using Poco::Message; 
    28  
    29 using Poco::AutoPtr; 
     12using std::string; 
    3013 
    3114namespace XMLIOSERVER 
    3215{ 
    33    class ILogger 
     16   class ILogger : public std::ostringstream 
    3417   { 
     18      private : 
     19 
     20         ILogger() 
     21         { signal(SIGSEGV, SigHandler); } 
     22 
     23         static ILogger LOGGER; 
     24 
    3525      public : 
    3626 
    37          ILogger() 
    38          { 
    39             // TODO Créer une sortie fichier. 
    40             AutoPtr<PatternFormatter> pf = new PatternFormatter("[%Y-%m-%d %H:%M:%S] %t"); 
    41             AutoPtr<ConsoleChannel> cc = new ConsoleChannel(); 
    42             AutoPtr<FormattingChannel> pFCConsole = new FormattingChannel(pf); 
    43             pFCConsole->setChannel(cc); 
    44             pFCConsole->open(); 
    45             Logger::create("ConsoleLogger", pFCConsole, Message::PRIO_INFORMATION); 
    46  
    47             signal(SIGSEGV, SigHandler); 
    48          } 
     27         static ILogger& GetLogger(void) { return (ILogger::LOGGER); } 
    4928 
    5029         static void ShowBTrace(std::ostream& out = std::clog) 
     
    8463         } 
    8564 
    86  
    87          static Logger & GetConsoleLogger(void) {return (Logger::get("ConsoleLogger"));} 
    88  
    8965         ~ILogger(void) 
    90          { /* Ne rien faire de plus */ } 
     66         { std::cout << str() << std::endl; } 
    9167 
    9268   }; // class XMLIOLogger 
    9369 
    9470   // Initialisation de la classe de Logging 
    95    ILogger LOGGER; 
     71   ILogger ILogger::LOGGER; 
    9672 
    9773   ///////////////////////////////////////////////////////////////////// 
     
    11389} // namespace XMLIOSERVER 
    11490 
    115 #define   ERROR(MSG)   (XMLIOSERVER::ILogger::GetConsoleLogger().error(MSG)) 
    116 #define   WARNING(MSG) (XMLIOSERVER::ILogger::GetConsoleLogger().warning(MSG)) 
    117 #define   INFO(MSG)    (XMLIOSERVER::ILogger::GetConsoleLogger().information(MSG)) 
     91#define   ERROR(MSG)   (ILogger::GetLogger() << __FILE__ << ":" << __LINE__ << ": error : "   << MSG << std::endl) 
     92#define   WARNING(MSG) (ILogger::GetLogger() << __FILE__ << ":" << __LINE__ << ": warning : " << MSG << std::endl) 
     93#define   INFO(MSG)    (ILogger::GetLogger() << __FILE__ << ":" << __LINE__ << ": info : "    << MSG << std::endl) 
    11894// A compléter. 
    11995 
  • XMLIO_V2/dev/dev_rv/src/XMLIO/object_template.hpp

    r120 r122  
    4242 
    4343         string getName(void) const {return (T::GetName()); } 
     44 
     45         const T* getBaseObject(void) const { return (baseObject); } 
    4446 
    4547         virtual T* getReference(void) const { return (NULL); } 
  • XMLIO_V2/dev/dev_rv/src/XMLIO/xmlio.hpp

    r120 r122  
    1212#include <iostream> 
    1313#include <fstream> 
     14#include <sstream> 
    1415 
    1516/// Entêtes Poco /// 
     
    3435 
    3536/// Entêtes créés dans le cadre du projet XMLIOSERVER. /// 
     37#include "logger.hpp" 
    3638#include "exception.hpp" 
    37 #include "logger.hpp" 
    3839#include "container.hpp" 
    3940#include "abstract_object.hpp" 
     
    4546#include "calendar.hpp" 
    4647#include "calendar_utils.hpp" 
     48 
     49// Gestion de l'écriture des données 
     50#include "abstract_data_output.hpp" 
    4751 
    4852#include "xml_node.hpp" 
     
    6165// Prise en charge des champs, fichiers, axes, domaines, grilles ... 
    6266#include "field.hpp" 
    63 #include "file.hpp" 
    6467#include "axis.hpp" 
    6568#include "domain.hpp" 
    6669#include "grid.hpp" 
     70#include "file.hpp" 
    6771 
    6872#include "field_gridrefsolver.hpp" 
     
    7175#include "xml_parser.hpp" 
    7276 
     77 
     78// Gestion de l'écriture des données NetCDF 
     79#include "NetCDF4_data_output.hpp" 
     80 
     81// Traitement des données 
    7382#include "abstract_data_treatment.hpp" 
    7483#include "NetCDF4_data_treatment.hpp" 
Note: See TracChangeset for help on using the changeset viewer.