- Timestamp:
- 10/13/10 15:25:55 (14 years ago)
- Location:
- XMLIO_V2/dev/dev_rv/src/XMLIO
- Files:
-
- 1 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
XMLIO_V2/dev/dev_rv/src/XMLIO/NetCDF4_data_output.hpp
r130 r131 54 54 for ( it = saxis.begin() ; it != saxis.end(); it++ ) 55 55 { 56 string axisid = ((*it)->name.hasValue()) ? (string)(*it)->name : (*it)->getId(); 57 dims[axisid] = (*it)->size; 56 string axisid = ((*it)->name.hasValue()) ? 57 (string)(*it)->name : (*it)->getId(); 58 dims[axisid] = (*it)->size; 58 59 } 59 60 … … 62 63 63 64 std::string getFileName(void) 64 { return ((getRelFile()->name.hasValue()) ? string(getRelFile()->name): getRelFile()->name.getId()); } 65 { 66 return ((getRelFile()->name.hasValue()) ? 67 string(getRelFile()->name): getRelFile()->name.getId()); 68 } 65 69 66 70 std::string getTimeStamp(void) … … 111 115 hm ["title"] = "Time"; 112 116 hm ["long_name"] = "Time axis"; 113 hm ["units"] = string("seconds since ").append(ccal->getInitDate().toString()); //"seconds since 1979-01-01 00:00:00"114 hm ["calendar"] = ccal->getType(); //"360d"115 hm ["time_origin"] = ccal->getInitDate().toString(); //" 1979-JAN-01 00:00:00" ;117 hm ["units"] = string("seconds since ").append(ccal->getInitDate().toString()); 118 hm ["calendar"] = ccal->getType(); 119 hm ["time_origin"] = ccal->getInitDate().toString(); 116 120 this->addStringAttributesToVar_str(oVar, hm); 117 121 hm.clear(); … … 263 267 NcType tvar = ncFloat; 264 268 NcVar *var = NULL; 269 265 270 Poco::HashMap<string, string> hm; 266 271 Poco::HashMap<string, float> hmf; 272 267 273 bool lonlat = false, wtime = true; 274 268 275 const std::vector<CField*>& enabledFields = getRelFile()->getEnabledFields(); 269 276 const std::set<const CDomain*> sdom = this->getRelFile()->getEnabledDomains(); … … 280 287 //Duration * const ffope = field->freq_op.getValue(); 281 288 282 string fieldid = (field->name.hasValue()) ? (string)field->name : bfield->getId(); 283 string domid = (rdom ->name.hasValue()) ? (string)rdom ->name : rdom ->getId(); 284 string axisid = (raxis->name.hasValue()) ? (string)raxis->name : raxis ->getId(); 289 string fieldid = (field->name.hasValue()) ? 290 (string)field->name : bfield->getId(); 291 string domid = (rdom ->name.hasValue()) ? 292 (string)rdom ->name : rdom ->getId(); 293 string axisid = (raxis->name.hasValue()) ? 294 (string)raxis->name : raxis ->getId(); 285 295 286 296 string lonid = (sdom.size() == 1)? string("lon") … … 305 315 { 306 316 if (!(var = dataFile->add_var(fieldid.c_str(), tvar, 307 dataFile->get_dim(TimeName), dataFile->get_dim(latid.c_str()), dataFile->get_dim(lonid.c_str())))) 317 dataFile->get_dim(TimeName), 318 dataFile->get_dim(latid.c_str()), 319 dataFile->get_dim(lonid.c_str())))) 308 320 throw XMLIOUndefinedValueException("Impossible d'ajouter le champ "+ field->getId() +" !"); 309 321 } … … 311 323 { 312 324 if (!(var = dataFile->add_var(fieldid.c_str(), tvar, 313 dataFile->get_dim(TimeName), dataFile->get_dim(axisid.c_str()), 314 dataFile->get_dim(latid.c_str()), dataFile->get_dim(lonid.c_str())))) 325 dataFile->get_dim(TimeName), 326 dataFile->get_dim(axisid.c_str()), 327 dataFile->get_dim(latid.c_str()), 328 dataFile->get_dim(lonid.c_str())))) 315 329 throw XMLIOUndefinedValueException("Impossible d'ajouter le champ "+ field->getId() +" !"); 316 330 } … … 321 335 { 322 336 if (!(var = dataFile->add_var(fieldid.c_str(), tvar, 323 dataFile->get_dim(latid.c_str()), dataFile->get_dim(lonid.c_str())))) 337 dataFile->get_dim(latid.c_str()), 338 dataFile->get_dim(lonid.c_str())))) 324 339 throw XMLIOUndefinedValueException("Impossible d'ajouter le champ "+ field->getId() +" !"); 325 340 } 326 341 else // 3D spatio sans temps 327 342 { 328 if (!(var = dataFile->add_var(fieldid.c_str(), tvar, dataFile->get_dim(axisid.c_str()), 329 dataFile->get_dim(latid.c_str()), dataFile->get_dim(lonid.c_str())))) 343 if (!(var = dataFile->add_var(fieldid.c_str(), tvar, 344 dataFile->get_dim(axisid.c_str()), 345 dataFile->get_dim(latid.c_str()), 346 dataFile->get_dim(lonid.c_str())))) 330 347 throw XMLIOUndefinedValueException("Impossible d'ajouter le champ "+ field->getId() +" !"); 331 348 } … … 361 378 for ( it = attr.begin() ; it != attr.end(); it++ ) 362 379 if (!var->add_att((*it).first.c_str(), (*it).second)) 363 throw XMLIOUndefinedValueException("Impossible d'ajouter l'attribut' "+ (*it).first +" Ã la variable "+ var->name() +" !"); 380 throw XMLIOUndefinedValueException 381 ("Impossible d'ajouter l'attribut' "+ (*it).first +" Ã la variable "+ var->name() +" !"); 364 382 } 365 383 … … 370 388 for ( it = attr.begin() ; it != attr.end(); it++ ) 371 389 if (!var->add_att((*it).first.c_str(), (*it).second.c_str())) 372 throw XMLIOUndefinedValueException("Impossible d'ajouter l'attribut' "+ (*it).first +" Ã la variable "+ var->name() +" !"); 390 throw XMLIOUndefinedValueException 391 ("Impossible d'ajouter l'attribut' "+ (*it).first +" Ã la variable "+ var->name() +" !"); 373 392 } 374 393 -
XMLIO_V2/dev/dev_rv/src/XMLIO/abstract_calendar.hpp
r130 r131 20 20 } 21 21 22 virtual string getType(void) const { return (string(this->getId())); }23 24 22 const Date& getInitDate(void) const { return(initDate); } 25 23 Date& getCurrentDate(void) { return(currentDate); } … … 38 36 return (NoLeapMonthLength[d.getMonth()-1]); 39 37 } 38 39 virtual string getType(void) const { return (string(this->getId())); } 40 40 41 41 virtual int getYearTotalLength(const Date& d) const { return (365 * 86400); } // Retourne la durée d'une année en seconde. … … 77 77 78 78 AbstractCalendar(const string& _id, 79 int yr = 0, int mth = 1, int d = 1, int hr = 0, int min = 0 , int sec = 0) 79 int yr = 0, int mth = 1, int d = 1, 80 int hr = 0, int min = 0, int sec = 0) 80 81 : AbstractObject(_id), 81 82 initDate(*this, yr, mth, d, hr, min, sec), currentDate(initDate), timestep(Hour) -
XMLIO_V2/dev/dev_rv/src/XMLIO/c_interface.cpp
r128 r131 1 #include " xmlio.hpp"1 #include "c_interface.hpp" 2 2 3 using namespace XMLIOSERVER; 4 using namespace XMLIOSERVER::XML; 3 /* ********************************************************** */ 4 /* CONVERSION FUNCTION */ 5 /* ********************************************************** */ 5 6 6 using namespace std; 7 static inline std::string stringXtoStd(XString _str) 8 { 9 char * const temp = new char[_str.len+1](); 10 memset(temp, '\0', _str.len+1); 11 memcpy(temp, _str.str, _str.len); 12 std::string _retstr(temp); 13 size_t d = _retstr.find_first_not_of(' '); 14 size_t f = _retstr.find_last_not_of (' '); 7 15 8 extern "C" void main_c_(void) ; 9 10 // Cette fonction remplit un tableau à N dimensions de valeurs de type T (T = double ou float) de la maniÚre suivante : 11 // 0.0 1.0 2.0 3.0, puis 0.1 1.1 2.1 3.1 ... au second appel de la fonction, etc. 12 template <class T> 13 static void updateDataTest(T begin, T end) 14 { 15 static int called = 0; int i = 0; 16 for (T it = begin; it != end; it++, i++) 17 (*it) = i + called * 0.01; 18 called++; 16 delete[] temp; 17 return (_retstr.substr(d, f-d+1)); 19 18 } 20 19 21 void main_c_ (void)20 static inline XString stringXtoStd(const std::string& _str) 22 21 { 23 try 24 { 25 Array<double, 3> arr(100, 100, 20) ; // Initialisation des données (les arguments en fonction des dimensions). 26 string file("/local/XMLIOSERVER_DEV/dev_rv/test/iodef_simple_test.xml"); // Le fichier de définition. 27 ifstream istr( file.c_str() , ifstream::in ); 22 XString _retstr = {new char[_str.size()](), _str.size()}; 23 memcpy(_retstr.str, _str.c_str(), _str.size()); 24 return (_retstr); 25 } 28 26 29 // On commence la lecture du flux de donnée xml qui doit posséder pour racine un unique noeud nommé "simulation". 30 XMLNode node = XMLNode::CreateNode(istr, Context::GetRootName()); 27 /* ********************************************************** */ 28 /* HANDLE INTERFACE */ 29 /* ********************************************************** */ 31 30 32 // On parse le fichier xml noeud par noeud (ie on construit dynamiquement notre arbre d'objets). 31 void xios_handle_create_(XHandle * _ret, const XDType * const _dtype, const XString * const _id) 32 { 33 try { 34 switch(*_dtype) 35 { 36 /*ECONTEXT, 37 EAXIS, EDOMAIN, EFIELD, EFILE, EGRID, 38 GAXIS, GDOMAIN, GFIELD, GFILE, GGRID*/ 39 case (ECONTEXT): 40 //if (Context::) 41 break; 42 43 default : 44 break; 45 }; 46 } catch(const Exception &exc) 47 { ERROR(exc.displayText()); } 48 } 49 50 void xios_handle_verify_(XBool * _ret, const XHandle * const _hd) 51 { 52 try { 53 54 } catch(const Exception &exc) 55 { ERROR(exc.displayText()); } 56 } 57 58 void xios_handle_getType_(XDType * _ret, const XHandle * const _hd) 59 { 60 try { 61 62 } catch(const Exception &exc) 63 { ERROR(exc.displayText()); } 64 } 65 66 void xios_handle_isType_(XBool * _ret, const XHandle * const _hd, const XDType * const _dtype) 67 { 68 try { 69 70 } catch(const Exception &exc) 71 { ERROR(exc.displayText()); } 72 } 73 74 void xios_handle_isId_(XBool * _ret, const XHandle * const _hd, const XString * const _id) 75 { 76 try { 77 78 } catch(const Exception &exc) 79 { ERROR(exc.displayText()); } 80 } 81 82 void xios_handle_isGroup_(XBool * _ret, const XHandle * const _hd) 83 { 84 try { 85 86 } catch(const Exception &exc) 87 { ERROR(exc.displayText()); } 88 } 89 90 void xios_handle_isElement_(XBool * _ret, const XHandle * const _hd) 91 { 92 try { 93 94 } catch(const Exception &exc) 95 { ERROR(exc.displayText()); } 96 } 97 98 /* ********************************************************** */ 99 /* XML INTERFACE */ 100 /* ********************************************************** */ 101 102 void xios_xml_parse_file_(XString _filename) 103 { 104 try { 105 std::string __filename = stringXtoStd(_filename); 106 std::ifstream __istr( __filename.c_str() , std::ifstream::in ); 107 108 // On commence la lecture du flux de donnée xml. 109 XMLNode node = XMLNode::CreateNode(__istr, Context::GetRootName()); 110 111 // On parse le fichier xml noeud par noeud 112 // (ie on construit dynamiquement notre arbre d'objets). 33 113 XMLParser::Parse(node); 34 114 35 // On se place dans le contexte 'context1'. 36 Context::SetCurrentContext("context1", true) ; 37 38 std::cout << " * ----------- Début du traitement ----------- * " << std::endl << std::endl; 39 40 { 41 // On crée une instance de traitement de données dans le format NetCDF4. 42 DataTreatment dtreat; 43 dtreat.createDataOutput<NetCDF4DataOutput>(); 44 45 // Récupération du calendrier assossié au context courant et initialisation des delais d'écriture. 46 AbstractCalendar* calendar = dtreat.getCurrentContext()->getCalendar(); 47 calendar->setTimeStep(1 * Hour); 48 49 // Affichage de la date initiale (pour vérification). 50 std::cout << "Calendrier associé au contexte : " << *calendar << std::endl << std::endl; 51 52 for(int tcourant = 0, tfinal = 9; tcourant <= tfinal; tcourant++) 53 { /***************************** BOUCLE DE CALCUL *****************************/ 54 55 // Mise à jour de la date. 56 calendar->update(); 57 58 // Affichage des informations temporelles sur l'itération actuelle. 59 std::cout << "> Itération de calcul effectuée à la date t" << tcourant << " = " << calendar->getCurrentDate() 60 << " (soit aprÚs " << (Time)calendar->getCurrentDate() << " sec.)." << std::endl; 61 62 // Mise à jour des données. 63 updateDataTest<Array<double, 3>::iterator>(arr.begin(), arr.end()); 64 65 // Ecriture des données. 66 dtreat.writeData<Array<double, 3> >("champ1", arr); 67 } 68 69 // Ecriture des avertissements obtenus jusqu'à présent. 70 std::cout << std::endl; ILogger::Flush(std::cout); 71 72 /*std::cout << " * ----------- Affichage de l'arborescence ----------- * " << std::endl << std::endl; 73 74 // On écrit l'arborescence résultante du traitement sur la sortie de log. 75 Context::ShowTree(std::clog); 76 std::cout << std::endl;*/ 77 } 78 79 } 80 catch(const Exception &exc) 81 { // Pour tout type d'exceptions, on note les informations sur la sortie paramétrée. 82 ERROR(exc.displayText()); 83 // On retourne le code d'erreur en fin d'application pour traitements éventuels. 84 // return (exc.code()); 85 } 86 87 // return (0); 115 } catch(const Exception &exc) 116 { ERROR(exc.displayText()); } 88 117 } 89 118 119 void xios_xml_parse_string_(XString _xmlcontent) 120 { 121 try { 122 std::string __xmlcontent = stringXtoStd(_xmlcontent); 123 std::istringstream __istr(__xmlcontent); 90 124 125 // On commence la lecture du flux de donnée xml. 126 XMLNode node = XMLNode::CreateNode(__istr, Context::GetRootName()); 127 128 // On parse le fichier xml noeud par noeud 129 // (ie on construit dynamiquement notre arbre d'objets). 130 XMLParser::Parse(node); 131 132 } catch(const Exception &exc) 133 { ERROR(exc.displayText()); } 134 } 135 136 /* ********************************************************** */ 137 /* MAIN ENTRY */ 138 /* ********************************************************** */ 139 140 void main_c_(void) // voué à disparaître 141 { /* Ne rien faire de plus */ } -
XMLIO_V2/dev/dev_rv/src/XMLIO/calendar.hpp
r130 r131 8 8 public : 9 9 10 JulianCalendar() : AbstractCalendar("Julian") 11 {/* Ne rien faire de plus */} 12 JulianCalendar(const string& _dateStr) : AbstractCalendar("Julian", _dateStr) 13 {/* Ne rien faire de plus */} 10 JulianCalendar(void) 11 : AbstractCalendar("Julian") 12 { /* Ne rien faire de plus */ } 13 14 JulianCalendar(const string& _dateStr) 15 : AbstractCalendar("Julian", _dateStr) 16 { /* Ne rien faire de plus */ } 14 17 15 18 public : /* virtual */ … … 17 20 virtual int getYearTotalLength(const Date& _d) const 18 21 { // Retourne la durée d'une année en seconde. 19 if (_d.getYear()%4 == 0) return (366 * 86400); 22 if (_d.getYear()%4 == 0) 23 return (366 * 86400); 20 24 return (365 * 86400); 21 25 } … … 24 28 { // Retourne la durée du mois en jour. 25 29 if (_d.getMonth() == 2) 26 { if (_d.getYear()%4 == 0) return 29; return 28; } 30 { 31 if (_d.getYear()%4 == 0) 32 return 29; 33 return 28; 34 } 27 35 return (AbstractCalendar::getMonthLength(_d)); 28 36 } … … 30 38 virtual string getType(void) const { return (string("julian")); } 31 39 32 virtual ~JulianCalendar( )40 virtual ~JulianCalendar(void) 33 41 {/* Ne rien faire de plus */} 34 42 … … 39 47 public : 40 48 41 GregorianCalendar() : AbstractCalendar("Gregorian") 49 GregorianCalendar(void) 50 : AbstractCalendar("Gregorian") 42 51 {/* Ne rien faire de plus */} 43 GregorianCalendar(const string& dateStr) : AbstractCalendar("Gregorian", dateStr) 52 53 GregorianCalendar(const string& dateStr) 54 : AbstractCalendar("Gregorian", dateStr) 44 55 {/* Ne rien faire de plus */} 45 56 … … 67 78 virtual string getType(void) const { return (string("gregorian")); } 68 79 69 virtual ~GregorianCalendar( )80 virtual ~GregorianCalendar(void) 70 81 {/* Ne rien faire de plus */} 71 82 … … 76 87 public : 77 88 78 NoLeapCalendar() : AbstractCalendar("NoLeap") 79 {/* Ne rien faire de plus */} 80 NoLeapCalendar(const string& dateStr) : AbstractCalendar("NoLeap", dateStr) 89 NoLeapCalendar(void) 90 : AbstractCalendar("NoLeap") 81 91 {/* Ne rien faire de plus */} 82 92 83 virtual string getType(void) const { return (string("noleap")); } 93 NoLeapCalendar(const string& dateStr) 94 : AbstractCalendar("NoLeap", dateStr) 95 {/* Ne rien faire de plus */} 84 96 85 virtual ~NoLeapCalendar() 97 public : /* virtual */ 98 99 virtual string getType(void) const 100 { return (string("noleap")); } 101 102 virtual ~NoLeapCalendar(void) 86 103 {/* Ne rien faire de plus */} 87 104 … … 92 109 public : 93 110 94 AllLeapCalendar() : AbstractCalendar("AllLeap") 111 AllLeapCalendar(void) 112 : AbstractCalendar("AllLeap") 95 113 {/* Ne rien faire de plus */} 96 AllLeapCalendar(const string& dateStr) : AbstractCalendar("AllLeap", dateStr) 114 115 AllLeapCalendar(const string& dateStr) 116 : AbstractCalendar("AllLeap", dateStr) 97 117 {/* Ne rien faire de plus */} 98 118 … … 100 120 101 121 virtual int getMonthLength(const Date& d) const 102 { if (d.getMonth() == 2) return (29); return (AbstractCalendar::getMonthLength(d)); } 122 { 123 if (d.getMonth() == 2) 124 return (29); 125 return (AbstractCalendar::getMonthLength(d)); 126 } 103 127 104 virtual int getYearTotalLength(const Date& d) const { return (366 * 86400); } 128 virtual int getYearTotalLength(const Date& d) const 129 { return (366 * 86400); } 105 130 106 virtual string getType(void) const { return (string("allleap")); } 131 virtual string getType(void) const 132 { return (string("allleap")); } 107 133 108 virtual ~AllLeapCalendar( )134 virtual ~AllLeapCalendar(void) 109 135 {/* Ne rien faire de plus */} 110 136 … … 115 141 public : 116 142 117 D360Calendar() : AbstractCalendar("D360") 143 D360Calendar(void) 144 : AbstractCalendar("D360") 118 145 {/* Ne rien faire de plus */} 119 D360Calendar(const string& dateStr) : AbstractCalendar("D360", dateStr) 146 147 D360Calendar(const string& dateStr) 148 : AbstractCalendar("D360", dateStr) 120 149 {/* Ne rien faire de plus */} 121 150 122 151 public : /* virtual */ 123 152 124 virtual int getYearTotalLength(const Date& d) const { return (360 * 86400); }125 virtual int getMonthLength(const Date& d) const { return (30); }153 virtual int getYearTotalLength(const Date& d) const 154 { return (360 * 86400); } 126 155 127 virtual string getType(void) const { return (string("360d")); } 156 virtual int getMonthLength(const Date& d) const 157 { return (30); } 128 158 129 virtual ~D360Calendar() 159 virtual string getType(void) const 160 { return (string("360d")); } 161 162 virtual ~D360Calendar(void) 130 163 {/* Ne rien faire de plus */} 131 164 -
XMLIO_V2/dev/dev_rv/src/XMLIO/container.hpp
r126 r131 16 16 public : 17 17 18 Mapped* operator[] (const Key& kval) throw (XMLIOUndefinedValueException) 18 Mapped* operator[] (const Key& kval) 19 throw (XMLIOUndefinedValueException) 19 20 { 20 21 if(!hasMappedValue(kval)) 21 throw XMLIOSERVER::XMLIOUndefinedValueException("Appel de la méthode ExHashMap::operator["+kval+"] invalide."); 22 throw XMLIOSERVER::XMLIOUndefinedValueException 23 ("Appel de la méthode ExHashMap::operator["+kval+"] invalide."); 22 24 return (find(kval)->second); 23 25 } 24 26 25 bool hasMappedValue(const Key& kval) const {return (find(kval) != this->end());} 27 bool hasMappedValue(const Key& kval) const 28 { return (find(kval) != this->end()); } 26 29 27 const vector<Mapped*>& getVector(void) const { return (this->_elemList); } 30 const vector<Mapped*>& getVector(void) const 31 { return (this->_elemList); } 28 32 29 size_t getVectorSize(void) const {return (this->_elemList.size());}30 size_t getSize(void) const {return (this->size());}33 size_t getVectorSize(void) const 34 { return (this->_elemList.size()); } 31 35 32 virtual ~ExHashMap() 36 size_t getSize(void) const 37 { return (this->size()); } 38 39 public : /* virtual */ 40 41 virtual ~ExHashMap(void) 33 42 {/* Ne rien faire de plus */} 34 43 35 44 protected : 36 45 37 ExHashMap() : Poco::HashMap<Key, Mapped*, Poco::Hash<Key> >(), _elemList() 46 ExHashMap(void) 47 : Poco::HashMap<Key, Mapped*, Poco::Hash<Key> >(), _elemList() 38 48 {/* Ne rien faire de plus */} 39 49 … … 46 56 47 57 bool addValue(Mapped* const element) 48 { this->_elemList.insert(this->_elemList.end(), element); return (true); } 49 58 { 59 this->_elemList.insert(this->_elemList.end(), element); 60 return (true); 61 } 50 62 51 63 void removeValue(const Key& kval) // Non testé 52 { Mapped* element = find(kval)->second; removeValue(element); this->erase(kval); } 64 { 65 Mapped* element = find(kval)->second; 66 this->removeValue(element); 67 this->erase(kval); 68 } 53 69 54 70 void removeValue(const Mapped* element) // Non testé … … 62 78 63 79 private : 64 vector<Mapped*> _elemList; 80 81 std::vector<Mapped*> _elemList; 65 82 66 83 }; // class ExHashMap … … 74 91 public : 75 92 76 StrHashMap() : ExHashMap<string, Mapped, Poco::Hash<string> >() 93 StrHashMap(void) 94 : ExHashMap<string, Mapped, Poco::Hash<string> >() 77 95 {/* Ne rien faire de plus */} 78 96 79 97 bool addObject(Mapped* element) 80 { if(element->hasId()) return(addValue(element->getId(), element)); return(addValue(element)); } 98 { 99 if(element->hasId()) 100 return(addValue(element->getId(), element)); 101 return(addValue(element)); 102 } 81 103 82 104 bool removeObject(const string& kval) … … 86 108 } 87 109 88 virtual ~StrHashMap() 110 public : /* virtual */ 111 112 virtual ~StrHashMap(void) 89 113 {/* Ne rien faire de plus */} 90 114 -
XMLIO_V2/dev/dev_rv/src/XMLIO/context.hpp
r128 r131 9 9 public: 10 10 11 Context(void) : ObjectTemplate<Context>(), ccalendar(NULL), 12 fieldDef(NULL), fileDef(NULL), axisDef(NULL), gridDef(NULL), domainDef(NULL) 11 Context(void) 12 : ObjectTemplate<Context>(), ccalendar(NULL), 13 fieldDef(NULL), fileDef(NULL), axisDef(NULL), gridDef(NULL), domainDef(NULL) 13 14 {/* Ne rien faire de plus */} 14 15 15 Context(const string& _id) : ObjectTemplate<Context>(_id), ccalendar(NULL), 16 fieldDef(NULL), fileDef(NULL), axisDef(NULL), gridDef(NULL), domainDef(NULL) 16 Context(const string& _id) 17 : ObjectTemplate<Context>(_id), ccalendar(NULL), 18 fieldDef(NULL), fileDef(NULL), axisDef(NULL), gridDef(NULL), domainDef(NULL) 17 19 {/* Ne rien faire de plus */} 18 20 19 FieldDefinition * getFieldDefinition (void)const { return (this->fieldDef ); }20 FileDefinition * getFileDefinition (void)const { return (this->fileDef ); }21 AxisDefinition * getAxisDefinition (void)const { return (this->axisDef ); }22 GridDefinition * getGridDefinition (void)const { return (this->gridDef ); }21 FieldDefinition * getFieldDefinition (void) const { return (this->fieldDef ); } 22 FileDefinition * getFileDefinition (void) const { return (this->fileDef ); } 23 AxisDefinition * getAxisDefinition (void) const { return (this->axisDef ); } 24 GridDefinition * getGridDefinition (void) const { return (this->gridDef ); } 23 25 DomainDefinition * getDomainDefinition(void) const { return (this->domainDef); } 24 26 25 27 AbstractCalendar * getCalendar(void) const { return (this->ccalendar ); } 28 26 29 AbstractCalendar * setCalendar(const string& _calName, const string& _dateStr) 27 30 { … … 42 45 } 43 46 44 ~Context( )47 ~Context(void) 45 48 { 46 49 // Désallocation dynamique de mémoire pour chacun des groupes de définition si nécessaire. … … 76 79 { WARNING("Le noeud de définition possÚde un identifiant, ce dernier ne sera pas pris en compte lors du traitement !"); } 77 80 78 if (name.compare(FieldDefinition::GetDefName()) == 0) // Parsing pour la définition des champs. 79 { fieldDef = CreateInstanceAndParse<FieldDefinition >(_node, FieldDefinition::GetDefName().c_str()); continue; } 80 81 if (name.compare(FileDefinition::GetDefName()) == 0) // Parsing pour la définition des fichiers. 82 { fileDef = CreateInstanceAndParse<FileDefinition >(_node, FileDefinition ::GetDefName().c_str()); continue; } 83 84 if (name.compare(AxisDefinition::GetDefName()) == 0) // Parsing pour la définition des axes. 85 { axisDef = CreateInstanceAndParse<AxisDefinition >(_node, AxisDefinition ::GetDefName().c_str()); continue; } 86 87 if (name.compare(GridDefinition::GetDefName()) == 0) // Parsing pour la définition des grilles. 88 { gridDef = CreateInstanceAndParse<GridDefinition >(_node, GridDefinition ::GetDefName().c_str()); continue; } 89 90 if (name.compare(DomainDefinition::GetDefName()) == 0) // Parsing pour la définition des domaines. 91 { domainDef = CreateInstanceAndParse<DomainDefinition>(_node, DomainDefinition::GetDefName().c_str()); continue; } 81 if (name.compare(FieldDefinition::GetDefName()) == 0) 82 // Parsing pour la définition des champs. 83 { fieldDef = CreateInstanceAndParse<FieldDefinition > 84 (_node, FieldDefinition::GetDefName().c_str()); continue; } 85 86 if (name.compare(FileDefinition::GetDefName()) == 0) 87 // Parsing pour la définition des fichiers. 88 { fileDef = CreateInstanceAndParse<FileDefinition > 89 (_node, FileDefinition ::GetDefName().c_str()); continue; } 90 91 if (name.compare(AxisDefinition::GetDefName()) == 0) 92 // Parsing pour la définition des axes. 93 { axisDef = CreateInstanceAndParse<AxisDefinition > 94 (_node, AxisDefinition ::GetDefName().c_str()); continue; } 95 96 if (name.compare(GridDefinition::GetDefName()) == 0) 97 // Parsing pour la définition des grilles. 98 { gridDef = CreateInstanceAndParse<GridDefinition > 99 (_node, GridDefinition ::GetDefName().c_str()); continue; } 100 101 if (name.compare(DomainDefinition::GetDefName()) == 0) 102 // Parsing pour la définition des domaines. 103 { domainDef = CreateInstanceAndParse<DomainDefinition> 104 (_node, DomainDefinition::GetDefName().c_str()); continue; } 92 105 93 106 WARNING("La définition est invalide, seuls les champs, grilles, axes et fichiers peuvent être définis !"); … … 134 147 135 148 Poco::HashMap<string, StrHashMap<Context> > &AllListContext = Context::GetAllListObject(); 136 for (Poco::HashMap<string, StrHashMap<Context> >::Iterator it = AllListContext.begin(); it != AllListContext.end(); it++) 149 Poco::HashMap<string, StrHashMap<Context> >::Iterator it; 150 151 for (it = AllListContext.begin(); it != AllListContext.end(); it++) 137 152 // On sort chacun des contextes successivement. 138 153 { … … 149 164 { 150 165 Poco::HashMap<string, StrHashMap<Context> > &AllListContext = Context::GetAllListObject(); 151 for (Poco::HashMap<string, StrHashMap<Context> >::Iterator it = AllListContext.begin(); it != AllListContext.end(); it++) 166 Poco::HashMap<string, StrHashMap<Context> >::Iterator it; 167 168 for (it = AllListContext.begin(); it != AllListContext.end(); it++) 152 169 { Context::SetCurrentContext((*it).first); delete ((*it).second)[(*it).first]; } 153 170 } … … 157 174 { 158 175 Poco::HashMap<string, StrHashMap<Context> > &AllListContext = Context::GetAllListObject(); 159 for (Poco::HashMap<string, StrHashMap<Context> >::Iterator it = AllListContext.begin(); it != AllListContext.end(); it++) 176 Poco::HashMap<string, StrHashMap<Context> >::Iterator it; 177 178 for ( it = AllListContext.begin(); it != AllListContext.end(); it++) 160 179 { 161 180 // Résolution des héritages descendants (cà d des héritages de groupes) pour chacun des contextes. … … 164 183 165 184 // Résolution des héritages par référence au niveau des fichiers. 166 const std::vector<CFile*>& allFiles = CFile::GetCurrentListObject().getVector(); 167 for (unsigned int i = 0; i < allFiles.size(); i++) allFiles[i]->solveFieldRefInheritance(); 185 const std::vector<CFile*>& allFiles = 186 CFile::GetCurrentListObject().getVector(); 187 188 for (unsigned int i = 0; i < allFiles.size(); i++) 189 allFiles[i]->solveFieldRefInheritance(); 168 190 } 169 191 } … … 180 202 } 181 203 204 static const std::stack<string>& GetStackContextId(void) 205 { return (Context::Stid); } 206 182 207 static Context* GetCurrentContext(void) 183 208 { return (Context::GetObject(Context::GetCurrentContextId())); } … … 208 233 private: 209 234 210 static st ack<string> Stid;235 static std::stack<string> Stid; 211 236 212 237 AbstractCalendar * ccalendar; … … 220 245 }; //class Context 221 246 222 st ack<string> Context::Stid;247 std::stack<string> Context::Stid; 223 248 224 249 }// namespace XMLIOSERVER -
XMLIO_V2/dev/dev_rv/src/XMLIO/data_treatment.hpp
r130 r131 8 8 public : 9 9 10 DataTreatment(Context* const _ctxt = Context::GetCurrentContext(),10 DataTreatment(Context* const _ctxt = Context::GetCurrentContext(), 11 11 const AbstractCalendar& cal = *Context::GetCurrentContext()->getCalendar()) 12 12 : enabledFiles(), currentContext(_ctxt) -
XMLIO_V2/dev/dev_rv/src/XMLIO/date.hpp
r130 r131 9 9 10 10 Date(const AbstractCalendar& cal, 11 int yr = 0, int mth = 1, int d = 1, int hr = 0, int min = 0 , int sec = 0) 11 int yr = 0, int mth = 1, int d = 1, 12 int hr = 0, int min = 0, int sec = 0) 12 13 : relCalendar(cal) 13 14 , year(yr), month(mth), day(d), hour(hr), minute(min), second(sec) … … 17 18 } 18 19 19 Date(const Date& d) : relCalendar(d.getRelCalendar()) 20 , year(d.year), month(d.month), day(d.day), hour(d.hour), minute(d.minute), second(d.second) 20 Date(const Date& d) 21 : relCalendar(d.getRelCalendar()), 22 year(d.year), month(d.month) , day(d.day), 23 hour(d.hour), minute(d.minute), second(d.second) 21 24 { 22 25 if(!this->checkDate()) … … 27 30 { 28 31 // relCalendar = d.getRelCalendar(); << inutile si fonction bien utilisée 29 year = d.year; month = d.month; day= d.day;32 year = d.year; month = d.month ; day = d.day; 30 33 hour = d.hour; minute = d.minute; second = d.second; 31 34 return (*this); 32 35 } 33 36 34 operator Time(void); // Retourne le nombre de secondes écoulées depuis la date initiale définie dans le calendrier.35 bool checkDate(void); // Vérifie la validité de la date.37 inline operator Time(void); // Retourne le nombre de secondes écoulées depuis la date initiale définie dans le calendrier. 38 inline bool checkDate(void); // Vérifie la validité de la date. 36 39 37 40 std::string toString(void) const -
XMLIO_V2/dev/dev_rv/src/XMLIO/declare_attribut.hpp
r128 r131 11 11 public: \ 12 12 \ 13 virtual st ringgetName(void) const { return (#att_name) ;} \13 virtual std::string getName(void) const { return (#att_name) ;} \ 14 14 virtual const char * getType(void) const { return (#att_type) ;} \ 15 15 \ -
XMLIO_V2/dev/dev_rv/src/XMLIO/duration.hpp
r130 r131 70 70 bool isNone(void) const 71 71 { 72 if ((year ==0) && (month ==0) && (day ==0) &&73 (hour ==0) && (minute==0) && (second==0))72 if ((year == 0) && (month == 0) && (day == 0) && 73 (hour == 0) && (minute == 0) && (second == 0)) 74 74 return (true); 75 75 return (false); … … 81 81 { 82 82 const struct _duration& own = *this; 83 std::ostringstream oss; oss << own; return (oss.str()); 83 std::ostringstream oss; oss << own; 84 return (oss.str()); 84 85 } 85 86 -
XMLIO_V2/dev/dev_rv/src/XMLIO/exception.hpp
r115 r131 14 14 public : 15 15 16 XMLIOException(int _code): Exception(_code) 17 { /* Ne rien faire de plus */ } 18 XMLIOException(const std::string& _msg, int _code): Exception(_msg, _code) 19 { /* Ne rien faire de plus */ } 20 XMLIOException(const std::string& _msg, const std::string& _arg, int _code): Exception(_msg, _arg, _code) 21 { /* Ne rien faire de plus */ } 22 XMLIOException(const std::string& _msg, const Poco::Exception& _exc, int _code): Exception(_msg, _exc, _code) 16 XMLIOException(int _code) 17 : Exception(_code) 23 18 { /* Ne rien faire de plus */ } 24 19 20 XMLIOException(const std::string& _msg, int _code) 21 : Exception(_msg, _code) 22 { /* Ne rien faire de plus */ } 25 23 26 XMLIOException(const XMLIOException& _exc): Exception(_exc) 24 XMLIOException(const std::string& _msg, const std::string& _arg, int _code) 25 : Exception(_msg, _arg, _code) 26 { /* Ne rien faire de plus */ } 27 28 XMLIOException(const std::string& _msg, const Poco::Exception& _exc, int _code) 29 : Exception(_msg, _exc, _code) 30 { /* Ne rien faire de plus */ } 31 32 XMLIOException(const XMLIOException& _exc) 33 : Exception(_exc) 27 34 { /* Ne rien faire de plus */ } 28 35 … … 44 51 { 45 52 public : 46 XMLIOUndefinedValueException(const std::string& _msg): XMLIOException(_msg, 1001) {} 47 const char* name(void) const throw() { return ("XMLIO>UndefinedValueException"); } 53 XMLIOUndefinedValueException(const std::string& _msg) 54 : XMLIOException(_msg, 1001) 55 { /* Ne rien faire de plus */ } 56 57 const char* name(void) const throw() 58 { return ("XMLIO>UndefinedValueException"); } 48 59 49 60 }; //class XMLIOUndefinedException … … 52 63 { 53 64 public : 54 XMLIOStreamException(const std::string& _msg): XMLIOException(_msg, 1002) {} 55 const char* name(void) const throw() { return ("XMLIO>StreamException"); } 65 XMLIOStreamException(const std::string& _msg) 66 : XMLIOException(_msg, 1002) 67 { /* Ne rien faire de plus */ } 68 69 const char* name(void) const throw() 70 { return ("XMLIO>StreamException"); } 56 71 57 72 }; //class XMLIOStreamException … … 60 75 { 61 76 public : 62 XMLParsingException(const std::string& _msg): XMLIOException(_msg, 1003) {} 63 const char* name(void) const throw() { return ("XMLIO>XMLParsingException"); } 77 XMLParsingException(const std::string& _msg) 78 : XMLIOException(_msg, 1003) 79 { /* Ne rien faire de plus */ } 80 81 const char* name(void) const throw() 82 { return ("XMLIO>XMLParsingException"); } 64 83 65 84 }; //class XMLParsingException … … 68 87 { 69 88 public : 70 XMLIOIncompatibleTypeException(const std::string& _msg): XMLIOException(_msg, 1003) {} 71 const char* name(void) const throw() { return ("XMLIO>XMLIOIncompatibeTypeException"); } 89 XMLIOIncompatibleTypeException(const std::string& _msg) 90 : XMLIOException(_msg, 1003) 91 { /* Ne rien faire de plus */ } 92 93 const char* name(void) const throw() 94 { return ("XMLIO>XMLIOIncompatibeTypeException"); } 72 95 73 96 }; //class XMLIOIncompatibleTypeException -
XMLIO_V2/dev/dev_rv/src/XMLIO/field.hpp
r130 r131 14 14 public: 15 15 16 CField(void) : ObjectTemplate<CField>(), FieldAttribut(), lastStored(NULL), grid(NULL), file(NULL) 17 {/* Ne rien faire de plus */} 18 CField(const string& _id) : ObjectTemplate<CField>(_id), FieldAttribut(), lastStored(NULL), grid(NULL), file(NULL) 19 {/* Ne rien faire de plus */} 16 CField(void) 17 : ObjectTemplate<CField>(), FieldAttribut(), 18 lastStored(NULL), grid(NULL), file(NULL) 19 { /* Ne rien faire de plus */ } 20 21 CField(const string& _id) 22 : ObjectTemplate<CField>(_id), FieldAttribut(), 23 lastStored(NULL), grid(NULL), file(NULL) 24 { /* Ne rien faire de plus */ } 20 25 21 26 inline void solveGridRef(void) ; 22 27 23 const CGrid* getGrid(void) const { return (grid); } 28 const CGrid* getGrid (void) const { return (grid); } 29 const CFile* getRelFile(void) const { return (file); } 24 30 const Array<double, 1>& getData(void) const { return (data); } 31 void setRelFile(CFile* const _file) { file = _file; } 25 32 26 33 void initLastStoredDate(const Date& _newlastStored) 27 { if(lastStored == NULL) lastStored = new Date(_newlastStored); }; 34 { 35 if(lastStored == NULL) 36 lastStored = new Date(_newlastStored); 37 }; 28 38 29 39 bool isStorable(const Date& currDate) … … 44 54 void solveOperation(void) 45 55 { 46 FieldOperation* fope = this->operation.getValue();47 Duration * ffope = this->freq_op.getValue();56 FieldOperation* const fope = this->operation.getValue(); 57 Duration * const ffope = this->freq_op.getValue(); 48 58 49 59 if (fope != NULL) … … 58 68 } 59 69 60 // Si la fréquence d'opération n'est pas définie, on l'initialise à 0s.61 // Une fréquence à 0s signifie que l'opération se fera à chaque écriture de données depuis la simulation.62 70 if (ffope == NULL) 63 71 this->freq_op.setValue(NoneDu); 64 65 72 this->operation.getValue()->setFreqOp(this->freq_op); 66 73 } 67 68 const CFile* getRelFile(void) const { return (file); }69 void setRelFile(CFile* _file) { file = _file; }70 74 71 75 public: /* virtual */ … … 85 89 public: /* static */ 86 90 87 static string GetName (void) { return ("field"); }88 static string GetDefName(void) 91 static string GetName (void) { return ("field"); } 92 static string GetDefName(void) { return (CField::GetName()); } 89 93 90 94 private : 91 95 92 96 Date* lastStored; 93 94 97 CGrid* grid ; 95 98 CFile* file; 96 97 Array<double, 1> data; 99 Array<double, 1> data; 98 100 99 101 }; // class CField … … 110 112 { 111 113 if (!_ori->hasId()) 112 throw (new XMLIOUndefinedValueException("Impossible de créer une référence à un élément sans identifiant !")); 114 throw (new XMLIOUndefinedValueException 115 ("Impossible de créer une référence à un élément sans identifiant !")); 113 116 114 117 CField& obj = *ObjectTemplate<CField>::CreateObject(); -
XMLIO_V2/dev/dev_rv/src/XMLIO/main.f90
r127 r131 1 PROGRAM main 1 ! --------------------------------------------------- ! 2 ! ------------- XMLIO SERVER MAIN TEST ------------- ! 3 ! --------------------------------------------------- ! 4 5 MODULE XML 6 INTERFACE 7 8 SUBROUTINE xios_xml_Parse_File(filename) 9 CHARACTER*(*), INTENT(IN) :: filename 10 END SUBROUTINE xios_xml_Parse_File 11 12 SUBROUTINE xios_xml_Parse_String(xmlcontent) 13 CHARACTER*(*), INTENT(IN) :: xmlcontent 14 END SUBROUTINE xios_xml_Parse_String 15 16 END INTERFACE 17 END MODULE XML 18 19 PROGRAM MAIN 20 USE XML 2 21 IMPLICIT NONE 3 22 4 C ALL main_c23 CHARACTER(LEN = 100):: filename 5 24 6 END PROGRAM main 25 filename = "/local/XMLIOSERVER_DEV/dev_rv/test/iodef_simple_test.xml" 26 27 CALL xios_xml_Parse_File(filename) 28 29 END PROGRAM MAIN -
XMLIO_V2/dev/dev_rv/src/XMLIO/xmlio.hpp
r128 r131 5 5 #include <utility> 6 6 #include <string> 7 #include <cstring> 7 8 #include <cmath> 8 9
Note: See TracChangeset
for help on using the changeset viewer.