Changeset 122 for XMLIO_V2/dev/dev_rv/src
- Timestamp:
- 09/20/10 17:30:34 (14 years ago)
- 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 36 36 AbstractDataTreatment(Context* const _ctxt) : currentContext(_ctxt), enabledFiles() 37 37 { 38 std::cout << "(Message temporaire) Résolution des héritages ..." << std::endl; 38 39 // Résolution des héritages pour le context actuel (Context::ResolveInheritance() résoud les héritages pour tous les contextes). 39 40 solveAllInheritance(); 40 41 41 42 // Initialisation du vecteur 'enabledFiles' contenant la liste des fichiers à sortir. 43 std::cout << "(Message temporaire) Initialisation du vecteur enabledFiles ..." << std::endl; 42 44 findEnabledFiles(); 43 45 44 46 // 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; 45 48 findAllEnabledFields(); 46 49 47 50 // 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; 48 52 solveAllGridRef(); 53 54 std::cout << "(Message temporaire) fin traitement sorties ..." << std::endl; 49 55 } 50 56 … … 59 65 void solveAllGridRef(void) 60 66 { 61 67 for (unsigned int i = 0; i < enabledFiles.size(); i++) 68 enabledFiles[i]->solveEFGridRef(); 62 69 } 63 70 -
XMLIO_V2/dev/dev_rv/src/XMLIO/attribut.hpp
r120 r122 85 85 86 86 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 <> 87 113 void Attribut<bool>::setFromString(const std::string& str) 88 114 { -
XMLIO_V2/dev/dev_rv/src/XMLIO/base_attribut.hpp
r120 r122 17 17 virtual ostream & print(ostream& o) const = 0 ; 18 18 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)) ; } 20 20 21 21 bool hasId(void) const { return (true); } -
XMLIO_V2/dev/dev_rv/src/XMLIO/c_interface.cpp
r120 r122 12 12 try 13 13 { 14 string file("/local/XMLIOSERVER_DEV/dev_rv/test/iodef_test.xml");14 //string file("/local/XMLIOSERVER_DEV/dev_rv/test/iodef_test.xml"); 15 15 //string file("/local/XMLIOSERVER_DEV/dev_rv/iodef_test.xml"); 16 string file("/local/XMLIOSERVER_DEV/dev_rv/test/iodef_simple_test.xml"); 16 17 17 18 ifstream istr( file.c_str() , ifstream::in ); … … 28 29 Context::SetCurrentContext("context1") ; 29 30 31 std::cout << " * ----------- <<<TOP>>> Début du traitement ----------- * " << std::endl; 30 32 // On crée une instance de traitement de données dans le format NetCDF4. 31 33 AbstractDataTreatment *dtreat = new NetCDF4DataTreatment(Context::GetObject("context1")); 32 34 33 35 // 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(); 35 40 36 41 // On écrit l'arborescence résultante du traitement sur la sortie. -
XMLIO_V2/dev/dev_rv/src/XMLIO/context.hpp
r120 r122 10 10 11 11 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) 13 13 {/* Ne rien faire de plus */} 14 14 15 15 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) 17 17 {/* Ne rien faire de plus */} 18 18 … … 20 20 { 21 21 os << NIndent << "<?xml version=\"1.0\"?>" << std::endl; 22 os << NIndent << "<" << Context::GetRootName() << ">" << std::endl;22 os << NIndent << "<" << Context::GetRootName() << ">" << std::endl; 23 23 24 24 Poco::HashMap<string, StrHashMap<Context> > &AllListContext = Context::GetAllListObject(); … … 59 59 60 60 // Changement de context pour les champs et groupes de champs. 61 FieldGroup::SetContext(id); CField::SetContext(id);61 FieldGroup::SetContext(id); CField::SetContext(id); 62 62 63 63 // Changement de context pour les fichiers et groupes de fichiers. 64 FileGroup::SetContext(id); CFile::SetContext(id);64 FileGroup::SetContext(id); CFile::SetContext(id); 65 65 66 66 // Changement de context pour les grilles et groupes de grilles. 67 GridGroup::SetContext(id); CGrid::SetContext(id);67 GridGroup::SetContext(id); CGrid::SetContext(id); 68 68 69 69 // 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); 71 74 } 72 75 … … 92 95 { WARNING("Le noeud de définition possÚde un identifiant, ce dernier ne sera pas pris en compte lors du traitement !"); } 93 96 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"]); 96 99 97 if (name.compare(FileDefinition::GetDefName()) == 0) // Parsing pour la définition des fichiers.98 { fileDef = CreateInstanceAndParse<FileDefinition >(_node, FileDefinition ::GetDefName().c_str()); continue; }99 100 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; } 102 103 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; } 105 115 106 116 WARNING("La définition est invalide, seuls les champs, grilles, axes et fichiers peuvent être définis !"); … … 116 126 117 127 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)); } 119 129 120 130 virtual void printChild(ostream& out) const 121 131 { 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; 126 137 } 127 138 … … 130 141 if (_parent != 0) return; 131 142 // 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(); 136 148 } 137 149 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); } 142 155 143 156 AbstractCalendar * getCalendar(void) const { return (this->ccalendar ); } … … 163 176 { 164 177 // 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 ; 167 181 168 182 // Désallocation dynamique de mémoire pour le calendrier associé au contexte courant si nécessaire. … … 178 192 AxisDefinition* axisDef; 179 193 GridDefinition* gridDef; 194 DomainDefinition* domainDef; 180 195 181 196 }; //class Context -
XMLIO_V2/dev/dev_rv/src/XMLIO/domain.hpp
r120 r122 31 31 32 32 // 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") ; 35 35 36 36 //domaine local en i 37 37 if ( ni.hasValue() && ibegin.hasValue()) 38 38 { 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 ; 41 41 } 42 42 else if (ni.hasValue() && iend.hasValue()) 43 43 { 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 ; 46 46 } 47 47 else if (ibegin.hasValue() && iend.hasValue()) 48 48 { 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 ; 51 51 } 52 else ERROR("domain local non défini 4") ;52 else throw XMLIOSERVER::XMLIOUndefinedValueException("domain local non défini 4") ; 53 53 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") ; 55 55 56 56 //domaine local en j 57 57 if ( nj.hasValue() && jbegin.hasValue()) 58 58 { 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 ; 61 61 } 62 62 else if (nj.hasValue() && jend.hasValue()) 63 63 { 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 ; 66 66 } 67 67 else if (jbegin.hasValue() && jend.hasValue()) 68 68 { 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 ; 71 71 } 72 else ERROR("domain local non défini 9") ;72 else throw XMLIOSERVER::XMLIOUndefinedValueException("domain local non défini 9") ; 73 73 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") ; 75 75 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 ; 77 77 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") ; 79 80 80 81 if (data_dim.hasValue()) 81 82 { 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)") ; 83 84 } 84 else ERROR("Dimension des donnée non définie") ;85 else throw XMLIOSERVER::XMLIOUndefinedValueException("Dimension des donnée non définie") ; 85 86 86 87 if (data_ni.hasValue()) 87 88 { 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") ; 89 90 } 90 91 else … … 98 99 if (data_nj.hasValue()) 99 100 { 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") ; 101 102 } 102 103 else data_nj=(int) nj ; … … 105 106 106 107 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. 108 109 mask->resize(shape(ni,nj)) ; 109 110 *mask=true ; … … 116 117 if (data_n_index.hasValue()) 117 118 { 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") ; 119 121 } 120 122 else data_n_index=data_i_index->extent(0) ; … … 125 127 { 126 128 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") ; 128 130 } 129 else ERROR("data_j_index non défini") ;131 else throw XMLIOSERVER::XMLIOUndefinedValueException("data_j_index non défini") ; 130 132 } 131 133 } 132 134 else 133 135 { 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") ; 135 138 } 136 cout<<"data_n_index.hasValue() "<<data_n_index.hasValue()<<endl ;139 //cout<<"data_n_index.hasValue() "<<data_n_index.hasValue()<<endl ; 137 140 if (!data_n_index.hasValue()) 138 141 { … … 141 144 int i ; 142 145 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 ; 144 147 145 148 data_i_index->resize(data_n_index) ; 146 149 147 150 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 ; 149 152 } 150 153 else // data_dim=2 … … 154 157 int count ; 155 158 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++) 161 164 { 162 165 (*data_i_index)(count)=i ; 163 cout<<count<<" "<<(*data_i_index)(count)<<endl ;166 // cout<<count<<" "<<(*data_i_index)(count)<<endl ; 164 167 (*data_j_index)(count)=j ; 165 cout<<count<<" "<<(*data_j_index)(count)<<endl ;168 //cout<<count<<" "<<(*data_j_index)(count)<<endl ; 166 169 count++ ; 167 170 } 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 ; 169 172 } 170 173 } -
XMLIO_V2/dev/dev_rv/src/XMLIO/field.hpp
r120 r122 18 18 {/* Ne rien faire de plus */} 19 19 20 static string GetName(void) { return ("field"); }20 static string GetName(void) { return ("field"); } 21 21 22 22 inline void SolveGridRef(void) ; 23 23 24 CGrid* getGrid(void) const { return (grid); }24 const CGrid* getGrid(void) const { return (grid); } 25 25 26 26 virtual CField* getReference(void) const -
XMLIO_V2/dev/dev_rv/src/XMLIO/field_gridrefsolver.hpp
r120 r122 9 9 CAxis* axis = NULL ; 10 10 11 11 if (domain_ref.hasValue()) 12 12 { 13 13 if (CDomain::HasObject(domain_ref)) domain = CDomain::GetObject(domain_ref) ; 14 else ERROR("Référence au domaineincorrecte") ;14 else throw XMLIOSERVER::XMLIOUndefinedValueException("Référence au domaine nommé \'"+ (string)domain_ref +"\' incorrecte") ; 15 15 } 16 16 … … 18 18 { 19 19 if (CAxis::HasObject(axis_ref)) axis = CAxis::GetObject(axis_ref) ; 20 else ERROR("Référence a l'axeincorrecte") ;20 else throw XMLIOSERVER::XMLIOUndefinedValueException("Référence à l'axe nommé \'"+ (string)axis_ref +"\' incorrecte") ; 21 21 } 22 22 23 23 if (grid_ref.hasValue()) 24 24 { 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"); 27 27 } 28 28 -
XMLIO_V2/dev/dev_rv/src/XMLIO/file.hpp
r120 r122 11 11 public: 12 12 13 CFile(void) : ObjectTemplate<CFile>(), FileAttribut(), vfieldGroup(NULL), enabledFields() 13 CFile(void) : ObjectTemplate<CFile>(), FileAttribut(), vfieldGroup(NULL), enabledFields(), output(NULL) 14 14 {/* 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) 16 16 {/* Ne rien faire de plus */} 17 17 … … 36 36 } 37 37 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 38 45 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 } 39 85 40 86 virtual bool hasChild(void) const { return (vfieldGroup != NULL); } 87 virtual void printChild(ostream& out) const { out << *vfieldGroup << std::endl; } 41 88 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) 50 90 { addAttributes(*_parent); if(vfieldGroup != NULL) vfieldGroup->resolveDescInheritance(); } 51 91 … … 65 105 getAllFields(enabledFields); 66 106 67 for ( it = enabledFields.begin() ; it <enabledFields.end(); it++ )107 for ( it = enabledFields.begin() ; it != enabledFields.end(); it++ ) 68 108 { 69 109 if ((*it)->enabled.hasValue()) // Si l'attribut 'enabled' est défini ... … … 88 128 { enabledFields.erase(it); continue; } 89 129 } 90 91 130 } 92 131 } 93 132 133 void solveEFGridRef(void) 134 { 135 for (unsigned int i = 0; i < enabledFields.size(); i++) 136 enabledFields[i]->SolveGridRef(); 137 } 138 94 139 virtual ~CFile(void) 95 { if(vfieldGroup != NULL) delete vfieldGroup; } 140 { 141 if(vfieldGroup != NULL) delete vfieldGroup; 142 if(output != NULL) delete output; 143 } 96 144 97 145 private : 98 146 99 147 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. 101 150 102 151 }; // class CFile -
XMLIO_V2/dev/dev_rv/src/XMLIO/grid.hpp
r120 r122 13 13 CGrid(void) : ObjectTemplate<CGrid>(), GridAttribut(), hasAxis(false), axis(NULL), domain(NULL) 14 14 { /* Ne rien faire de plus */ } 15 15 16 CGrid(const string& _id) : ObjectTemplate<CGrid>(_id), GridAttribut(), hasAxis(false), axis(NULL), domain(NULL) 16 17 { /* Ne rien faire de plus */ } 17 18 18 19 static string GetName(void) { return ("grid"); } 20 21 const CAxis* getRelAxis(void) const { return (axis); } 22 const CDomain* getRelDomain(void) const { return (domain); } 19 23 20 24 inline void solveReference(void) ; … … 24 28 inline void computeIndex(void); 25 29 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); 33 39 34 40 inline static CGrid* CreateObject(const CDomain* const a_domain, const CAxis* const a_axis); … … 77 83 void CGrid::solveReference(void) 78 84 { 85 79 86 static bool isReferenceSolved = false; 80 87 if (isReferenceSolved) return; … … 94 101 if (CDomain::HasObject(domain_ref)) 95 102 { 96 domain =CDomain::GetObject(domain_ref) ;103 domain = CDomain::GetObject(domain_ref) ; 97 104 domain->check() ; 98 105 } … … 115 122 void CGrid::computeIndex(void) 116 123 { 124 117 125 int ni = domain->ni ; 118 126 int nj = domain->nj ; … … 123 131 int data_jbegin = (data_dim == 2) ? (int)domain->data_jbegin : -1; 124 132 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 ; 128 136 int i, j, l, n ; 129 137 int count, indexCount ; … … 131 139 for(indexCount=0, l=0; l<size ; l++) 132 140 { 133 for(n=0 , indexCount=0; n<data_n_index; n++)141 for(n=0; n<data_n_index; n++) 134 142 { 135 143 if (data_dim == 1) … … 137 145 i = (data_i_index(n) + data_ibegin) % ni ; 138 146 j = (data_i_index(n) + data_ibegin) / ni ; 139 cout<<i<<" "<<j<<" "<<mask(i,j)<<endl ;147 //cout<<i<<" "<<j<<" "<<mask(i,j)<<endl ; 140 148 } 141 149 else … … 143 151 i = data_i_index(n) + data_ibegin ; 144 152 j = data_j_index(n) + data_jbegin ; 145 cout<<i<<" "<<j<<" "<<mask(i,j)<<endl ;153 //cout<<i<<" "<<j<<" "<<mask(i,j)<<endl ; 146 154 } 147 155 … … 157 165 for(count=0, indexCount=0, l=0; l<size; l++) 158 166 { 159 for(n=0; n<data_n_index; n++ )167 for(n=0; n<data_n_index; n++, count++) 160 168 { 161 169 if (data_dim == 1) … … 164 172 j = (data_i_index(n) + data_ibegin) / ni ; 165 173 } 166 else 174 else // (dat_dim == 2) 167 175 { 168 176 i = data_i_index(n) + data_ibegin ; … … 172 180 if (i>=0 && i<ni && j>=0 && j<nj && mask(i,j)) 173 181 { 174 storeIndex(indexCount) = n;182 storeIndex(indexCount) = count ; 175 183 out_l_index(indexCount) = l ; 176 184 out_i_index(indexCount) = i ; … … 178 186 indexCount++ ; 179 187 } 180 count++ ;181 188 } 182 189 } 183 190 191 /** Pour tests 192 184 193 cout << "Out of CGrid::ComputeIndex" << endl ; 194 195 cout << "storeIndex : " << endl ; 185 196 cout << storeIndex << endl ; 197 198 cout << "out_i_index : " << endl ; 186 199 cout << out_i_index << endl ; 200 201 cout << "out_j_index : " << endl ; 187 202 cout << out_j_index << endl ; 203 204 cout << "out_l_index : " << endl ; 188 205 cout << out_l_index << endl ; 206 207 **/ 208 189 209 } 190 210 -
XMLIO_V2/dev/dev_rv/src/XMLIO/group_template.hpp
r120 r122 30 30 } 31 31 32 virtual void resolveDescInheritance(const AttributRegistrar* _parent = 0)32 virtual void resolveDescInheritance(const AttributRegistrar* const _parent = 0) 33 33 { 34 34 const vector<T*>& childvect = childList.getVector(); … … 112 112 113 113 protected: 114 115 114 116 115 template <class W> void _parse (XMLNode& _node, bool _withAttr = true) -
XMLIO_V2/dev/dev_rv/src/XMLIO/logger.hpp
r120 r122 3 3 4 4 // 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 14 5 #include <csignal> 15 6 … … 19 10 #endif // __GNUC__ 20 11 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; 12 using std::string; 30 13 31 14 namespace XMLIOSERVER 32 15 { 33 class ILogger 16 class ILogger : public std::ostringstream 34 17 { 18 private : 19 20 ILogger() 21 { signal(SIGSEGV, SigHandler); } 22 23 static ILogger LOGGER; 24 35 25 public : 36 26 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); } 49 28 50 29 static void ShowBTrace(std::ostream& out = std::clog) … … 84 63 } 85 64 86 87 static Logger & GetConsoleLogger(void) {return (Logger::get("ConsoleLogger"));}88 89 65 ~ILogger(void) 90 { /* Ne rien faire de plus */}66 { std::cout << str() << std::endl; } 91 67 92 68 }; // class XMLIOLogger 93 69 94 70 // Initialisation de la classe de Logging 95 ILogger LOGGER;71 ILogger ILogger::LOGGER; 96 72 97 73 ///////////////////////////////////////////////////////////////////// … … 113 89 } // namespace XMLIOSERVER 114 90 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) 118 94 // A compléter. 119 95 -
XMLIO_V2/dev/dev_rv/src/XMLIO/object_template.hpp
r120 r122 42 42 43 43 string getName(void) const {return (T::GetName()); } 44 45 const T* getBaseObject(void) const { return (baseObject); } 44 46 45 47 virtual T* getReference(void) const { return (NULL); } -
XMLIO_V2/dev/dev_rv/src/XMLIO/xmlio.hpp
r120 r122 12 12 #include <iostream> 13 13 #include <fstream> 14 #include <sstream> 14 15 15 16 /// Entêtes Poco /// … … 34 35 35 36 /// Entêtes créés dans le cadre du projet XMLIOSERVER. /// 37 #include "logger.hpp" 36 38 #include "exception.hpp" 37 #include "logger.hpp"38 39 #include "container.hpp" 39 40 #include "abstract_object.hpp" … … 45 46 #include "calendar.hpp" 46 47 #include "calendar_utils.hpp" 48 49 // Gestion de l'écriture des données 50 #include "abstract_data_output.hpp" 47 51 48 52 #include "xml_node.hpp" … … 61 65 // Prise en charge des champs, fichiers, axes, domaines, grilles ... 62 66 #include "field.hpp" 63 #include "file.hpp"64 67 #include "axis.hpp" 65 68 #include "domain.hpp" 66 69 #include "grid.hpp" 70 #include "file.hpp" 67 71 68 72 #include "field_gridrefsolver.hpp" … … 71 75 #include "xml_parser.hpp" 72 76 77 78 // Gestion de l'écriture des données NetCDF 79 #include "NetCDF4_data_output.hpp" 80 81 // Traitement des données 73 82 #include "abstract_data_treatment.hpp" 74 83 #include "NetCDF4_data_treatment.hpp"
Note: See TracChangeset
for help on using the changeset viewer.