- Timestamp:
- 10/07/10 10:29:38 (14 years ago)
- Location:
- XMLIO_V2/dev/dev_rv/src/XMLIO
- Files:
-
- 1 added
- 2 deleted
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
XMLIO_V2/dev/dev_rv/src/XMLIO/NetCDF4_data_output.hpp
r125 r126 10 10 public : 11 11 12 NetCDF4DataOutput(CFile* const _file) : AbstractDataOutput(_file), dataFile(NULL) 12 NetCDF4DataOutput(CFile* const _file) 13 : AbstractDataOutput(_file), dataFile(NULL) 13 14 { /* Ne rien faire de plus */ } 14 15 15 16 const NcFile* getDataFile(void) const { return (dataFile); } 17 18 void writeVarData(const string& id, const Array<float, 1>& vdata) 19 { 20 //if (!latVar->put(lats, NLAT)) 21 // return NC_ERR; 22 } 16 23 17 24 virtual ~NetCDF4DataOutput() … … 26 33 const std::set<const CAxis*> saxis = this->getRelFile()->getEnabledAxis(); 27 34 28 // std::cout << "Nombre de domaines disponibles pour le fichier : " << sdom.size() << std::endl;29 // std::cout << "Nombre d'axes disponibles pour le fichier : " << saxis.size() << std::endl;35 // std::cout << "Nombre de domaines disponibles pour le fichier : " << sdom.size() << std::endl; 36 // std::cout << "Nombre d'axes disponibles pour le fichier : " << saxis.size() << std::endl; 30 37 31 38 std::set<const CDomain*>::const_iterator itt; 39 std::set<const CAxis*>::const_iterator it; 40 32 41 for ( itt = sdom.begin() ; itt != sdom.end(); itt++ ) 33 42 { … … 39 48 } 40 49 41 std::set<const CAxis*>::const_iterator it;42 50 for ( it = saxis.begin() ; it != saxis.end(); it++ ) 43 51 { … … 54 62 std::string getTimeStamp(void) 55 63 { 56 time_t rawtime; 57 struct tm * timeinfo = NULL; 58 char buffer [100]; 59 60 time ( &rawtime ); 61 timeinfo = localtime ( &rawtime ); 62 63 strftime (buffer, 100, "%Y-%b-%d %H:%M:%S %Z", timeinfo); 64 65 return (string(buffer)); 66 } 64 const int buffer_size = 100; 65 time_t rawtime; 66 struct tm * timeinfo = NULL; 67 char buffer [buffer_size]; 68 69 time ( &rawtime ); 70 timeinfo = localtime ( &rawtime ); 71 strftime (buffer, buffer_size, "%Y-%b-%d %H:%M:%S %Z", timeinfo); 72 73 return (string(buffer)); 74 } 75 76 void writeCoords(const string& id, const Array<float, 1>& cdata) 77 { 78 NcVar *cVar = dataFile->get_var(id.c_str()); 79 80 if (!cVar->put(cdata.dataFirst(), cdata.size())) 81 throw XMLIOUndefinedValueException("Impossible d'écrire les valeurs de coordonnées "+ id +" !"); 82 } 83 84 protected : /* virtual */ 67 85 68 86 virtual void initFile(void) 69 87 { 70 string filename = getFileName();88 string filename = this->getFileName(); 71 89 72 90 // Création du fichier ou remplacement si celui-ci existe déjà . … … 150 168 151 169 hm["axis"] = "Z" ; 152 if ((*it)-> name.hasValue()) hm["standard_name"] = (*it)->name ;153 if ((*it)-> unit.hasValue()) hm["units"] = (*it)->unit;154 if ((*it)-> description.hasValue()) hm["long_name"] = (*it)->description;170 if ((*it)->standard_name.hasValue())hm["standard_name"] = (*it)->standard_name ; 171 if ((*it)->long_name.hasValue()) hm["long_name"] = (*it)->long_name ; 172 if ((*it)->unit.hasValue()) hm["units"] = (*it)->unit; 155 173 addStringAttributesToVar(othvar, hm); 156 174 hm.clear(); … … 160 178 virtual void setVars(void) 161 179 { 162 NcType tvar ;180 NcType tvar = ncFloat; 163 181 NcVar *var = NULL; 164 182 Poco::HashMap<string, string> hm; … … 167 185 168 186 std::vector<CField*>::const_iterator it; 187 169 188 for ( it = enabledFields.begin() ; it != enabledFields.end(); it++ ) 170 189 { … … 209 228 { 210 229 if (!(var = dataFile->add_var(fieldid.c_str(), tvar, 211 dataFile->get_dim("time"), dataFile->get_dim(l onid.c_str()), dataFile->get_dim(latid.c_str()))))230 dataFile->get_dim("time"), dataFile->get_dim(latid.c_str()), dataFile->get_dim(lonid.c_str())))) 212 231 throw XMLIOUndefinedValueException("Impossible d'ajouter le champ "+ field->getId() +" !"); 213 232 } … … 215 234 { 216 235 if (!(var = dataFile->add_var(fieldid.c_str(), tvar, 217 dataFile->get_dim("time"), dataFile->get_dim( lonid.c_str()), dataFile->get_dim(latid.c_str()),218 dataFile->get_dim( axisid.c_str()))))236 dataFile->get_dim("time"), dataFile->get_dim(axisid.c_str()), 237 dataFile->get_dim(latid.c_str()), dataFile->get_dim(lonid.c_str())))) 219 238 throw XMLIOUndefinedValueException("Impossible d'ajouter le champ "+ field->getId() +" !"); 220 239 } … … 225 244 { 226 245 if (!(var = dataFile->add_var(fieldid.c_str(), tvar, 227 dataFile->get_dim(l onid.c_str()), dataFile->get_dim(latid.c_str()))))246 dataFile->get_dim(latid.c_str()), dataFile->get_dim(lonid.c_str())))) 228 247 throw XMLIOUndefinedValueException("Impossible d'ajouter le champ "+ field->getId() +" !"); 229 248 } 230 249 else // 3D spatio sans temps 231 250 { 232 if (!(var = dataFile->add_var(fieldid.c_str(), tvar, 233 dataFile->get_dim(lonid.c_str()), dataFile->get_dim(latid.c_str()), 234 dataFile->get_dim(axisid.c_str())))) 235 throw XMLIOUndefinedValueException("Impossible d'ajouter le champ "+ field->getId() +" !"); 236 } 237 } 238 239 if (field->name.hasValue()) hm["standard_name"] = field->name ; 240 if (field->unit.hasValue()) hm["units"] = field->unit; 241 if (field->description.hasValue()) hm["long_name"] = field->description ; 251 if (!(var = dataFile->add_var(fieldid.c_str(), tvar, dataFile->get_dim(axisid.c_str()), 252 dataFile->get_dim(latid.c_str()), dataFile->get_dim(lonid.c_str())))) 253 throw XMLIOUndefinedValueException("Impossible d'ajouter le champ "+ field->getId() +" !"); 254 } 255 } 256 257 if (field->standard_name.hasValue())hm["standard_name"] = field->standard_name ; 258 if (field->long_name.hasValue()) hm["long_name"] = field->long_name ; 259 if (field->unit.hasValue()) hm["units"] = field->unit; 242 260 addStringAttributesToVar(var, hm); 243 261 hm.clear(); … … 245 263 } 246 264 247 virtual void writeCoords(const string& id, const Array<float, 1>& cdata)248 {249 //if (!latVar->put(lats, NLAT))250 // return NC_ERR;251 }252 253 virtual void writeVarData(const string& id, const Array<float, 1>& vdata)254 {255 //if (!latVar->put(lats, NLAT))256 // return NC_ERR;257 }258 259 265 private : 260 266 … … 262 268 { 263 269 Poco::HashMap<string, string>::ConstIterator it; 270 264 271 for ( it = attr.begin() ; it != attr.end(); it++ ) 265 272 if (!var->add_att((*it).first.c_str(), (*it).second.c_str())) -
XMLIO_V2/dev/dev_rv/src/XMLIO/abstract_calendar.hpp
r124 r126 57 57 { string value = getMonthName(_mi); value.resize(3); return (value); } 58 58 59 virtual ~AbstractCalendar( )60 { /* Ne rien faire de plus */}59 virtual ~AbstractCalendar(void) 60 { /* Ne rien faire de plus */ } 61 61 62 62 protected : 63 63 64 AbstractCalendar( )64 AbstractCalendar(void) 65 65 : AbstractObject(), initDate(*this), currentDate(initDate), tempo(Hour) 66 { /* Ne rien faire de plus */}66 { /* Ne rien faire de plus */ } 67 67 68 AbstractCalendar(const string& _id, int yr = 0, int mth = 1, int d = 1, int hr = 0, int min = 0 , int sec = 0) 68 AbstractCalendar(const string& _id, 69 int yr = 0, int mth = 1, int d = 1, int hr = 0, int min = 0 , int sec = 0) 69 70 : AbstractObject(_id), initDate(*this, yr, mth, d, hr, min, sec), currentDate(initDate), tempo(Hour) 70 { /* Ne rien faire de plus */}71 { /* Ne rien faire de plus */ } 71 72 72 73 AbstractCalendar(const string& _id, const string& dateStr) 73 74 : AbstractObject(_id), initDate(Date::FromString(dateStr, *this)), currentDate(initDate), tempo(Hour) 74 { /* Ne rien faire de plus */}75 { /* Ne rien faire de plus */ } 75 76 76 77 private : -
XMLIO_V2/dev/dev_rv/src/XMLIO/abstract_data_output.hpp
r125 r126 16 16 { 17 17 // Création du fichier de sortie. 18 initFile();18 this->initFile(); 19 19 // Définition des dimensions. 20 setDims();20 this->setDims(); 21 21 // Définition des coordonnées. 22 setCoords();22 this->setCoords(); 23 23 // Définitions des variables. 24 setVars();24 this->setVars(); 25 25 } 26 26 … … 32 32 AbstractDataOutput(CFile* const _file): file(_file) 33 33 { /* Ne rien faire de plus */ } 34 35 34 36 35 virtual void initFile (void) = 0; -
XMLIO_V2/dev/dev_rv/src/XMLIO/abstract_object.hpp
r120 r126 15 15 } 16 16 17 bool hasId(void) const { return(IdDefined); } 17 bool hasId(void) const { return (IdDefined); } 18 18 19 void resetId(void) { IdDefined = false ;} 19 void setId(const std::string& _id) { id = _id ; IdDefined = true ;} 20 21 void setId(const std::string& _id) 22 { id = _id ; IdDefined = true ; } 20 23 21 24 bool operator==(const AbstractObject& other) const … … 26 29 } 27 30 31 bool operator!=(const AbstractObject& other) const 32 { return (!(*this == other)); } 33 28 34 std::string printId(void) const 29 { if(hasId()) return (" id=\""+getId()+"\""); return (""); } 35 { 36 if(this->hasId()) 37 return (string(" id=\""+getId()+"\"")); 38 return (string("")); 39 } 30 40 31 41 virtual ~AbstractObject(void) 32 { /* Ne rien faire de plus */}42 { /* Ne rien faire de plus */ } 33 43 34 44 protected : 35 45 36 AbstractObject(void) : IdDefined(false) 37 {/* Ne rien faire de plus */} 46 AbstractObject(void) 47 : IdDefined(false) // Sans identifiant. 48 { /* Ne rien faire de plus */ } 38 49 39 AbstractObject(const std::string& _id) : id(_id), IdDefined(true) 40 {/* Ne rien faire de plus */} 50 AbstractObject(const std::string& _id) 51 : id(_id), IdDefined(true) 52 { /* Ne rien faire de plus */ } 53 54 AbstractObject(const AbstractObject& _ao) 55 : id(_ao.id), IdDefined(_ao.IdDefined) 56 { /* Ne rien faire de plus */ } 41 57 42 58 private : -
XMLIO_V2/dev/dev_rv/src/XMLIO/attribut.hpp
r122 r126 15 15 { 16 16 public : 17 18 Attribut(void) 19 : BaseAttribut(), _hasValue(false) 20 { /* Ne rien faire de plus */ } 21 22 Attribut(const Ctype& value_) 23 : BaseAttribut(), _hasValue(true), value(value_) 24 { /* Ne rien faire de plus */ } 25 26 Attribut(const Attribut& attr) 27 : BaseAttribut(attr), _hasValue(attr._hasValue) 28 { if (_hasValue) value = attr.value ; } 29 30 Attribut& operator = (const Attribut & attr) 31 { 32 _hasValue = attr._hasValue ; 33 if (_hasValue) this->setValue(attr.value) ; 34 return (*this) ; 35 } 36 17 37 operator Ctype() const 18 38 { … … 21 41 } 22 42 23 Ctype* operator ->( ) { return (&value); }24 Ctype& operator * () { return (value) ; }43 Ctype* operator ->(void) { return (&value); } 44 Ctype& operator * (void) { return (value) ; } 25 45 26 virtual bool hasValue() const { return (_hasValue); } 46 public : /* virtual */ 47 48 virtual bool hasValue(void) const { return (_hasValue); } 27 49 virtual const char * getType(void) const = 0; 28 29 Attribut(void) : _hasValue(false) {} ;30 Attribut(const Ctype& value_) : _hasValue(true), value(value_) {} ;31 32 Attribut(const Attribut& attr) : _hasValue(attr._hasValue)33 { if (_hasValue) value = attr.value ; }34 35 Attribut& operator = (const Attribut & attr)36 {37 _hasValue = attr._hasValue ;38 if (_hasValue) setValue(attr.value) ;39 return (*this) ;40 }41 50 42 51 virtual void setFromString(const std::string& str) … … 50 59 { value = ((Attribut*)_ba) -> value; _hasValue = true; } 51 60 52 virtual ostream& print( ostream & o) const53 { if (_hasValue) o << " " << getName() << "=\"" << boolalpha << value << "\"" ; return o; }61 virtual ostream& print(std::ostream & _out) const 62 { if (_hasValue) _out << " " << getName() << "=\"" << boolalpha << value << "\"" ; return (_out) ; } 54 63 55 64 virtual void setValue(const Ctype & value_) … … 62 71 } 63 72 73 virtual ~Attribut() 74 { /* Ne rien faire de plus */ } 75 64 76 private : 65 77 … … 69 81 }; // class Attribut 70 82 71 #define SET_ARRAY_DIM(type, dim)\83 #define SET_ARRAY_DIM(type, dim) \ 72 84 template<> \ 73 85 void Attribut<Array<type,dim> >::setValue (const Array<type,dim>& val) \ … … 88 100 { 89 101 if (_hasValue) o << " " << getName() << "=\"" << value(0); 90 for (int i = 1; i < value.size(); i++) { o << "," << value(i); } 102 /*for (int i = 1; i < value.size(); i++) 103 { o << "," << value(i); }*/ 104 o << value(0) << "..." << value(value.size()-1); 91 105 o << "\"" ; 92 106 return (o) ; … … 94 108 95 109 template <> 96 void Attribut<Array<double,1> >::setFromString(const std::string& str)110 void Attribut<Array<double,1> >::setFromString(const std::string& _str) 97 111 { 98 istringstream iss( str) ;99 char c = '\0'; double d = 0.;100 vector<double> vect;101 Array<double, 1> arr;112 istringstream iss(_str) ; 113 char c = '\0'; int size = 0; 114 double d = 0.,valsup = 0., valinf = 0.; 115 std::vector<double> vect; Array<double, 1> arr; 102 116 103 117 iss >> d; vect.push_back(d); 104 while(!iss.eof ()) { iss >> c >> d; vect.push_back(d); } 118 if (!iss.eof ()) 119 { 120 iss >> c; 121 switch (c) 122 { 123 case ',' : // Le tableau est généré valeur par valeur. 124 iss.unget(); 125 while(!iss.eof ()) 126 { // On récupÚre chacune des valeurs une par une jusqu'à ce que le buffer soit vide. 127 iss >> c >> d; 128 if (c != ',') 129 throw XMLIOUndefinedValueException("Le tableau de valeur est mal défini !"); 130 vect.push_back(d); 131 } 132 size = vect.size(); 133 break; 134 case '(' : // Le tableau est généré automatiquement. 135 if (!iss.eof ()) 136 { // on récupÚre la borne supérieure 137 valinf = d; 138 iss >> size >> c >> d; 139 if ((c != ')') || (size <= 0)) 140 throw XMLIOUndefinedValueException("Le tableau de valeur est mal défini !"); 141 valsup = d; 142 } 143 d = (valsup - valinf) / (double)(size - 1); 144 for (int j = 1; j <= size; j++) 145 vect.push_back(valinf + j * d); 146 break; 147 default : 148 throw XMLIOUndefinedValueException("Le tableau de valeur est mal défini !"); 149 } 150 } 105 151 106 arr.resize(vect.size()); 107 for (unsigned int i = 0; i < vect.size(); i++) arr(i) = vect[i]; 152 arr.resize(size); 153 for (int i = 0; i < size; i++) 154 arr(i) = vect[i]; 108 155 109 156 this->setValue(arr); … … 114 161 { 115 162 istringstream iss(str) ; 116 bool val = (! iss.str().compare(string(".TRUE."))) ? true : false;163 const bool val = (! iss.str().compare(string(".TRUE."))) ? true : false; 117 164 this->setValue(val); 118 165 } -
XMLIO_V2/dev/dev_rv/src/XMLIO/attribut_registrar.hpp
r124 r126 12 12 protected : 13 13 14 AttributRegistrar():attrList() 15 {/* Ne rien faire de plus */} 14 AttributRegistrar(void) 15 : attrList() 16 { /* Ne rien faire de plus */ } 16 17 17 void RegisterAttribut(BaseAttribut* attribut){ attrList.addObject(attribut); } 18 AttributRegistrar(const AttributRegistrar& _ar) 19 : attrList(_ar.attrList) 20 { /* Ne rien faire de plus */ } 21 22 void RegisterAttribut(BaseAttribut* const attribut){ attrList.addObject(attribut); } 23 18 24 const StrHashMap<BaseAttribut>& getAttributList(void) const { return (attrList); } 19 size_t getNbAttributes() const {return (attrList.getSize()); } 25 26 size_t getNbAttributes(void) const { return (attrList.getSize()); } 27 20 28 bool hasAttribut(const string& _id) const { return (attrList.hasMappedValue(_id)); } 29 30 const StrHashMap<BaseAttribut>& getAttrList(void) const { return (attrList); } 21 31 22 32 BaseAttribut* getAttribut(const string& _id) throw (XMLIOUndefinedValueException) { return (attrList[_id]); } … … 55 65 { 56 66 if (hasAttribut(att_name)) getAttribut(att_name)->setFromString(value); 57 else throw XMLIOUndefinedValueException("Impossible de trouver l'attribut nommé \"" + att_name +"\" dans la liste des attributs enregistrés !"); 67 else throw XMLIOUndefinedValueException("Impossible de trouver l'attribut nommé \"" 68 + att_name +"\" dans la liste des attributs enregistrés !"); 58 69 } 59 70 -
XMLIO_V2/dev/dev_rv/src/XMLIO/axis_attribut.hpp
r120 r126 10 10 public : 11 11 12 DECLARE_ATTR(name, string) ; 13 DECLARE_ATTR(description, string) ; 14 DECLARE_ATTR(unit, string) ; 15 DECLARE_ATTR(size, int) ; 16 DECLARE_ATTR(value, Array(double,1)) ; 12 DECLARE_ATTR(name , string) ; 13 DECLARE_ATTR(standard_name , string) ; 14 DECLARE_ATTR(long_name , string) ; 15 16 DECLARE_ATTR(unit , string) ; 17 DECLARE_ATTR(size , int) ; 18 DECLARE_ATTR(value , Array(double, 1)) ; 17 19 18 20 AxisAttribut(void) : AttributRegistrar() 19 { registerAllAttributes(); }21 { this->registerAllAttributes(); } 20 22 21 23 private : … … 24 26 { 25 27 RegisterAttribut(&name) ; 26 RegisterAttribut(&description) ; 28 RegisterAttribut(&standard_name) ; 29 RegisterAttribut(&long_name) ; 27 30 RegisterAttribut(&unit) ; 28 31 RegisterAttribut(&size) ; -
XMLIO_V2/dev/dev_rv/src/XMLIO/base_attribut.hpp
r122 r126 4 4 using std::ostream; 5 5 using namespace blitz ; 6 7 6 8 7 using XMLIOSERVER::XMLIOIncompatibleTypeException; … … 12 11 class BaseAttribut 13 12 { 14 p ublic:13 protected : 15 14 16 virtual string getName(void) const = 0 ;17 virtual ostream & print(ostream& o) const = 0 ;15 BaseAttribut(void) 16 { /* Ne rien faire de plus */ } 18 17 19 friend ostream& operator <<(ostream& o,const BaseAttribut& attr) { return (attr.print(o)) ; } 18 BaseAttribut(const BaseAttribut& _ba) 19 { /* Ne rien faire de plus */ } 20 21 public : 22 23 friend ostream& operator <<(ostream& _out,const BaseAttribut& _attr) 24 { return (_attr.print(_out)) ; } 20 25 21 26 bool hasId(void) const { return (true); } 22 27 28 public : /* virtual */ 29 23 30 virtual string getId(void) const { return (getName()); } ; 24 31 25 virtual void assignValue(const BaseAttribut*) = 0; 26 virtual void setFromString(const std::string&) = 0; 27 virtual bool hasValue() const = 0; 32 virtual bool hasValue (void) const = 0; 33 virtual string getName (void) const = 0; 34 virtual ostream & print (ostream& o) const = 0; 35 virtual void assignValue (const BaseAttribut*) = 0; 36 virtual void setFromString(const std::string&) = 0; 28 37 29 #define SETTER_AND_GETTER(TYPE) \30 virtual void setValue(const TYPE & value) {error_set() ; }\31 virtual void setValue(const Array<TYPE,1>& value) {error_set() ; }\32 virtual void setValue(const Array<TYPE,2>& value) {error_set() ; }\33 virtual void setValue(const Array<TYPE,3>& value) {error_set() ; }\34 virtual void setValue(const Array<TYPE,4>& value) {error_set() ; }\35 virtual void getValue(TYPE & value) const {error_get() ; }\36 virtual void getValue(Array<TYPE,1>& value) const {error_get() ; }\37 virtual void getValue(Array<TYPE,2>& value) const {error_get() ; }\38 virtual void getValue(Array<TYPE,3>& value) const {error_get() ; }\39 virtual void getValue(Array<TYPE,4>& value) const {error_get() ; }38 #define SETTER_AND_GETTER(TYPE) \ 39 virtual void setValue(const TYPE&) { BaseAttribut::error_set() ; }\ 40 virtual void setValue(const Array<TYPE,1>&) { BaseAttribut::error_set() ; }\ 41 virtual void setValue(const Array<TYPE,2>&) { BaseAttribut::error_set() ; }\ 42 virtual void setValue(const Array<TYPE,3>&) { BaseAttribut::error_set() ; }\ 43 virtual void setValue(const Array<TYPE,4>&) { BaseAttribut::error_set() ; }\ 44 virtual void getValue(TYPE&) const { BaseAttribut::error_get() ; }\ 45 virtual void getValue(Array<TYPE,1>&) const { BaseAttribut::error_get() ; }\ 46 virtual void getValue(Array<TYPE,2>&) const { BaseAttribut::error_get() ; }\ 47 virtual void getValue(Array<TYPE,3>&) const { BaseAttribut::error_get() ; }\ 48 virtual void getValue(Array<TYPE,4>&) const { BaseAttribut::error_get() ; } 40 49 41 50 SETTER_AND_GETTER(int) … … 43 52 SETTER_AND_GETTER(double) 44 53 SETTER_AND_GETTER(char) 45 SETTER_AND_GETTER(st ring)54 SETTER_AND_GETTER(std::string) 46 55 47 56 #undef SETTER_AND_GETTER 48 57 58 virtual ~BaseAttribut(void) 59 { /* Ne rien faire de plus */ } 60 61 public : /* static */ 62 49 63 static void error_set(void) 50 { throw XMLIOIncompatibleTypeException("BaseAttribut::set<type> > Setting value type is incompatible with attribut type"); } 64 { throw XMLIOIncompatibleTypeException 65 ("BaseAttribut::set<type> > Setting value type is incompatible with attribut type"); } 51 66 52 67 static void error_get(void) 53 { throw XMLIOIncompatibleTypeException("BaseAttribut::set<type> >Getting value type is incompatible with attribut type"); } 68 { throw XMLIOIncompatibleTypeException 69 ("BaseAttribut::set<type> >Getting value type is incompatible with attribut type"); } 54 70 55 71 }; //class BaseAttribut -
XMLIO_V2/dev/dev_rv/src/XMLIO/c_interface.cpp
r125 r126 15 15 static int called = 0; int i = 0; 16 16 for (T it = begin; it != end; it++, i++) 17 (*it) = i + called * 0. 1;17 (*it) = i + called * 0.01; 18 18 called++; 19 19 } … … 23 23 try 24 24 { 25 Array<double, 3> arr(100, 100, 20) ; // Les données(les arguments en fonction des dimensions).25 Array<double, 3> arr(100, 100, 20) ; // Initialisation des données (les arguments en fonction des dimensions). 26 26 string file("/local/XMLIOSERVER_DEV/dev_rv/test/iodef_simple_test.xml"); // Le fichier de définition. 27 27 ifstream istr( file.c_str() , ifstream::in ); … … 34 34 35 35 // On se place dans le contexte 'context1'. 36 Context::SetCurrentContext("context1" ) ;36 Context::SetCurrentContext("context1", true) ; 37 37 38 std::cout << " * ----------- Début du traitement ----------- * " << std::endl ;38 std::cout << " * ----------- Début du traitement ----------- * " << std::endl << std::endl; 39 39 40 40 { 41 41 // On crée une instance de traitement de données dans le format NetCDF4. 42 AbstractDataTreatment *dtreat = new NetCDF4DataTreatment();43 dtreat ->createDataOutput();42 DataTreatment dtreat; 43 dtreat.createDataOutput<NetCDF4DataOutput>(); 44 44 45 45 // Récupération du calendrier assossié au context courant et initialisation des delais d'écriture. 46 AbstractCalendar* calendar = dtreat ->getCurrentContext()->getCalendar();47 calendar->setTempo(1 *Hour);46 AbstractCalendar* calendar = dtreat.getCurrentContext()->getCalendar(); 47 calendar->setTempo(1 * Hour); 48 48 49 // Affichage de la date initiale (pour vérification).50 std::cout << *calendar<< std::endl;49 // Affichage de la date initiale (pour vérification). 50 std::cout << "Calendrier associé au contexte : " << *calendar << std::endl << std::endl; 51 51 52 52 for(int tcourant = 0, tfinal = 9; tcourant <= tfinal; tcourant++) … … 56 56 calendar->update(); 57 57 58 std::cout << "> Itération de calcul " << tcourant << ", " << *calendar << std::endl; 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; 59 61 60 62 // Mise à jour des données. … … 62 64 63 65 // Ecriture des données. 64 dtreat ->writeData<Array<double, 3> >("champ1", arr);66 dtreat.writeData<Array<double, 3> >("champ1", arr); 65 67 } 66 68 67 69 // On écrit l'arborescence résultante du traitement sur la sortie de log. 68 // Context::ShowTree(std::clog); 69 70 delete dtreat; 70 //Context::ShowTree(std::clog); 71 71 } 72 72 -
XMLIO_V2/dev/dev_rv/src/XMLIO/container.hpp
r120 r126 38 38 {/* Ne rien faire de plus */} 39 39 40 bool addValue(const Key& kval, Mapped* element)40 bool addValue(const Key& kval, Mapped* const element) 41 41 { 42 pair<typename ExHashMap::Iterator,bool> p = this->insert(make_pair (kval,element));42 std::pair<typename ExHashMap::Iterator, bool> p = this->insert(make_pair (kval,element)); 43 43 if(!p.second) return (false); 44 44 return (this->addValue(element)); 45 45 } 46 46 47 bool addValue(Mapped* element)47 bool addValue(Mapped* const element) 48 48 { this->_elemList.insert(this->_elemList.end(), element); return (true); } 49 49 -
XMLIO_V2/dev/dev_rv/src/XMLIO/context.hpp
r125 r126 16 16 fieldDef(NULL), fileDef(NULL), axisDef(NULL), gridDef(NULL), domainDef(NULL) 17 17 {/* Ne rien faire de plus */} 18 19 static void ShowTree(ostream& os = std::clog)20 {21 os << NIndent << "<?xml version=\"1.0\"?>" << std::endl;22 os << NIndent << "<" << Context::GetRootName() << ">" << std::endl;23 24 Poco::HashMap<string, StrHashMap<Context> > &AllListContext = Context::GetAllListObject();25 for (Poco::HashMap<string, StrHashMap<Context> >::Iterator it = AllListContext.begin(); it != AllListContext.end(); it++)26 // On sort chacun des contextes successivement.27 { Context::SetCurrentContext((*it).first); os << *((*it).second)[(*it).first] << std::endl; }28 29 os << NIndent << "</" << Context::GetRootName() << ">" << std::endl ;30 }31 32 static void FreeMemory(void)33 {34 Poco::HashMap<string, StrHashMap<Context> > &AllListContext = Context::GetAllListObject();35 for (Poco::HashMap<string, StrHashMap<Context> >::Iterator it = AllListContext.begin(); it != AllListContext.end(); it++)36 { Context::SetCurrentContext((*it).first); delete ((*it).second)[(*it).first]; }37 }38 39 // Ne plus utiliser, disponible dans les classe treatment.40 static void ResolveInheritance(void)41 {42 Poco::HashMap<string, StrHashMap<Context> > &AllListContext = Context::GetAllListObject();43 for (Poco::HashMap<string, StrHashMap<Context> >::Iterator it = AllListContext.begin(); it != AllListContext.end(); it++)44 {45 // Résolution des héritages descendants (cà d des héritages de groupes) pour chacun des contextes.46 Context::SetCurrentContext((*it).first);47 ((*it).second)[(*it).first]->resolveDescInheritance();48 49 // Résolution des héritages par référence au niveau des fichiers.50 const std::vector<CFile*>& allFiles = CFile::GetCurrentListObject().getVector();51 for (unsigned int i = 0; i < allFiles.size(); i++) allFiles[i]->resolveFieldRefInheritance();52 }53 }54 55 static Context* SwapContext(void)56 {57 if (Stid.size() == 0)58 {59 WARNING("SwapContext impossible car le pile des contextes est vides !");60 return (NULL);61 }62 string lastId = Stid.top (); Stid.pop ();63 return (Context::GetObject(lastId));64 }65 66 static Context* GetCurrentContext(void)67 { return (Context::GetObject(Context::GetCurrentContextId())); }68 69 static void SetCurrentContext(const string& id, bool withSwap = false)70 {71 if (withSwap) Stid.push (Context::GetCurrentContextId());72 73 // On modifie le context courrant pour tout les ObjectTemplate74 Context::SetContext(id);75 76 // Changement de context pour les champs et groupes de champs.77 FieldGroup::SetContext(id); CField::SetContext(id);78 79 // Changement de context pour les fichiers et groupes de fichiers.80 FileGroup::SetContext(id); CFile::SetContext(id);81 82 // Changement de context pour les grilles et groupes de grilles.83 GridGroup::SetContext(id); CGrid::SetContext(id);84 85 // Changement de context pour les axes et groupes d'axes.86 AxisGroup::SetContext(id); CAxis::SetContext(id);87 88 // Changement de context pour les domaines et groupes de domaines.89 DomainGroup::SetContext(id); CDomain::SetContext(id);90 }91 92 virtual void parse (XMLNode& _node)93 {94 THashAttributes attributes;95 96 /// PARSING POUR GESTION DES ENFANTS97 if (_node.getElementName().compare(Context::GetName()))98 WARNING("Le noeud est mal nommé mais sera traité comme un context !");99 100 if (!(_node.goToChildElement()))101 WARNING("Le context ne contient pas d'enfant !");102 else103 {104 do { // Parcours des contexts pour traitement.105 106 string name = _node.getElementName();107 attributes.clear();108 _node.getAttributes(attributes);109 110 if (attributes.end() != attributes.find("id"))111 { WARNING("Le noeud de définition possÚde un identifiant, ce dernier ne sera pas pris en compte lors du traitement !"); }112 113 if (name.compare(FieldDefinition::GetDefName()) == 0) // Parsing pour la définition des champs.114 { fieldDef = CreateInstanceAndParse<FieldDefinition >(_node, FieldDefinition::GetDefName().c_str()); continue; }115 116 if (name.compare(FileDefinition::GetDefName()) == 0) // Parsing pour la définition des fichiers.117 { fileDef = CreateInstanceAndParse<FileDefinition >(_node, FileDefinition ::GetDefName().c_str()); continue; }118 119 if (name.compare(AxisDefinition::GetDefName()) == 0) // Parsing pour la définition des axes.120 { axisDef = CreateInstanceAndParse<AxisDefinition >(_node, AxisDefinition ::GetDefName().c_str()); continue; }121 122 if (name.compare(GridDefinition::GetDefName()) == 0) // Parsing pour la définition des grilles.123 { gridDef = CreateInstanceAndParse<GridDefinition >(_node, GridDefinition ::GetDefName().c_str()); continue; }124 125 if (name.compare(DomainDefinition::GetDefName()) == 0) // Parsing pour la définition des domaines.126 { domainDef = CreateInstanceAndParse<DomainDefinition>(_node, DomainDefinition::GetDefName().c_str()); continue; }127 128 WARNING("La définition est invalide, seuls les champs, grilles, axes et fichiers peuvent être définis !");129 130 } while (_node.goToNextElement());131 132 _node.goToParentElement(); // Retour au parent133 }134 }135 136 static string GetRootName(void) { return ("simulation"); }137 static string GetName(void) { return ("context"); }138 static string GetDefName(void) { return (Context::GetName()); }139 140 141 virtual bool hasChild(void) const142 { return ((fieldDef != NULL) or (fileDef != NULL) or (axisDef != NULL) or (gridDef != NULL) or (domainDef != NULL)); }143 144 virtual void printChild(ostream& out) const145 {146 if(fieldDef != NULL) out << *(FieldGroup*) fieldDef << std::endl;147 if(fileDef != NULL) out << *(FileGroup*) fileDef << std::endl;148 if(axisDef != NULL) out << *(AxisDefinition*) axisDef << std::endl;149 if(gridDef != NULL) out << *(GridDefinition*) gridDef << std::endl;150 if(domainDef != NULL) out << *(DomainDefinition*) domainDef << std::endl;151 }152 153 virtual void resolveDescInheritance(const AttributRegistrar* const _parent = 0)154 {155 if (_parent != 0) return;156 // Résolution des héritages descendants pour chacun des groupes de définitions.157 if(fieldDef != NULL) fieldDef ->resolveDescInheritance();158 if(fileDef != NULL) fileDef ->resolveDescInheritance();159 if(axisDef != NULL) axisDef ->resolveDescInheritance();160 if(gridDef != NULL) gridDef ->resolveDescInheritance();161 if(domainDef != NULL) domainDef->resolveDescInheritance();162 }163 18 164 19 FieldDefinition * getFieldDefinition(void) const { return (this->fieldDef ); } … … 198 53 } 199 54 55 public : /* virtual */ 56 57 virtual void parse (XMLNode& _node) 58 { 59 THashAttributes attributes; 60 61 /// PARSING POUR GESTION DES ENFANTS 62 if (_node.getElementName().compare(Context::GetName())) 63 WARNING("Le noeud est mal nommé mais sera traité comme un context !"); 64 65 if (!(_node.goToChildElement())) 66 WARNING("Le context ne contient pas d'enfant !"); 67 else 68 { 69 do { // Parcours des contexts pour traitement. 70 71 string name = _node.getElementName(); 72 attributes.clear(); 73 _node.getAttributes(attributes); 74 75 if (attributes.end() != attributes.find("id")) 76 { WARNING("Le noeud de définition possÚde un identifiant, ce dernier ne sera pas pris en compte lors du traitement !"); } 77 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; } 92 93 WARNING("La définition est invalide, seuls les champs, grilles, axes et fichiers peuvent être définis !"); 94 95 } while (_node.goToNextElement()); 96 97 _node.goToParentElement(); // Retour au parent 98 } 99 } 100 101 virtual bool hasChild(void) const 102 { return ((fieldDef != NULL) or (fileDef != NULL) or (axisDef != NULL) or (gridDef != NULL) or (domainDef != NULL)); } 103 104 virtual void printChild(ostream& out) const 105 { 106 if(fieldDef != NULL) out << *(FieldGroup*) fieldDef << std::endl; 107 if(fileDef != NULL) out << *(FileGroup*) fileDef << std::endl; 108 if(axisDef != NULL) out << *(AxisDefinition*) axisDef << std::endl; 109 if(gridDef != NULL) out << *(GridDefinition*) gridDef << std::endl; 110 if(domainDef != NULL) out << *(DomainDefinition*) domainDef << std::endl; 111 } 112 113 virtual void resolveDescInheritance(const AttributRegistrar* const _parent = 0) 114 { 115 if (_parent != 0) return; 116 // Résolution des héritages descendants pour chacun des groupes de définitions. 117 if(fieldDef != NULL) fieldDef ->resolveDescInheritance(); 118 if(fileDef != NULL) fileDef ->resolveDescInheritance(); 119 if(axisDef != NULL) axisDef ->resolveDescInheritance(); 120 if(gridDef != NULL) gridDef ->resolveDescInheritance(); 121 if(domainDef != NULL) domainDef->resolveDescInheritance(); 122 } 123 124 public : /* static */ 125 126 static string GetRootName(void) { return ("simulation"); } 127 static string GetName(void) { return ("context"); } 128 static string GetDefName(void) { return (Context::GetName()); } 129 130 static void ShowTree(ostream& os = std::clog) 131 { 132 os << NIndent << "<?xml version=\"1.0\"?>" << std::endl; 133 os << NIndent << "<" << Context::GetRootName() << ">" << std::endl; 134 135 Poco::HashMap<string, StrHashMap<Context> > &AllListContext = Context::GetAllListObject(); 136 for (Poco::HashMap<string, StrHashMap<Context> >::Iterator it = AllListContext.begin(); it != AllListContext.end(); it++) 137 // On sort chacun des contextes successivement. 138 { 139 Context::SetCurrentContext((*it).first); 140 os << NIndent << std::endl; 141 os << *((*it).second)[(*it).first] << std::endl; 142 } 143 144 os << NIndent << std::endl; 145 os << NIndent << "</" << Context::GetRootName() << ">" << std::endl ; 146 } 147 148 static void FreeMemory(void) 149 { 150 Poco::HashMap<string, StrHashMap<Context> > &AllListContext = Context::GetAllListObject(); 151 for (Poco::HashMap<string, StrHashMap<Context> >::Iterator it = AllListContext.begin(); it != AllListContext.end(); it++) 152 { Context::SetCurrentContext((*it).first); delete ((*it).second)[(*it).first]; } 153 } 154 155 // Ne plus utiliser, disponible dans les classe treatment. 156 static void ResolveInheritance(void) 157 { 158 Poco::HashMap<string, StrHashMap<Context> > &AllListContext = Context::GetAllListObject(); 159 for (Poco::HashMap<string, StrHashMap<Context> >::Iterator it = AllListContext.begin(); it != AllListContext.end(); it++) 160 { 161 // Résolution des héritages descendants (cà d des héritages de groupes) pour chacun des contextes. 162 Context::SetCurrentContext((*it).first); 163 ((*it).second)[(*it).first]->resolveDescInheritance(); 164 165 // 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]->resolveFieldRefInheritance(); 168 } 169 } 170 171 static Context* SwapContext(void) 172 { 173 if (Stid.size() == 0) 174 { 175 WARNING("SwapContext impossible car le pile des contextes est vides !"); 176 return (NULL); 177 } 178 string lastId = Stid.top (); Stid.pop (); 179 return (Context::GetObject(lastId)); 180 } 181 182 static Context* GetCurrentContext(void) 183 { return (Context::GetObject(Context::GetCurrentContextId())); } 184 185 static void SetCurrentContext(const string& id, bool withSwap = false) 186 { 187 if (withSwap) Stid.push (Context::GetCurrentContextId()); 188 189 // On modifie le context courrant pour tout les ObjectTemplate 190 Context::SetContext(id); 191 192 // Changement de context pour les champs et groupes de champs. 193 FieldGroup::SetContext(id); CField::SetContext(id); 194 195 // Changement de context pour les fichiers et groupes de fichiers. 196 FileGroup::SetContext(id); CFile::SetContext(id); 197 198 // Changement de context pour les grilles et groupes de grilles. 199 GridGroup::SetContext(id); CGrid::SetContext(id); 200 201 // Changement de context pour les axes et groupes d'axes. 202 AxisGroup::SetContext(id); CAxis::SetContext(id); 203 204 // Changement de context pour les domaines et groupes de domaines. 205 DomainGroup::SetContext(id); CDomain::SetContext(id); 206 } 207 200 208 private: 201 209 202 210 static stack<string> Stid; 203 211 204 AbstractCalendar * ccalendar;205 206 FieldDefinition *fieldDef;207 FileDefinition *fileDef;208 AxisDefinition *axisDef;209 GridDefinition *gridDef;210 DomainDefinition * domainDef;212 AbstractCalendar * ccalendar; 213 214 FieldDefinition * fieldDef; 215 FileDefinition * fileDef; 216 AxisDefinition * axisDef; 217 GridDefinition * gridDef; 218 DomainDefinition * domainDef; 211 219 212 220 }; //class Context 213 221 214 //stack<string> Context::Stid();222 stack<string> Context::Stid; 215 223 216 224 }// namespace XMLIOSERVER -
XMLIO_V2/dev/dev_rv/src/XMLIO/declare_attribut.hpp
r120 r126 6 6 #define Array(x,y) Array<x,y> 7 7 8 #define DECLARE_ATTR(att_name, att_type)\9 class attr_##att_name : public Attribut<att_type> \8 #define DECLARE_ATTR(att_name, att_type) \ 9 class Attr_##att_name : public Attribut<att_type> \ 10 10 { \ 11 11 public: \ 12 virtual string getName(void) const { return #att_name ;} \ 13 virtual const char * getType(void) const { return #att_type ;} \ 14 attr_##att_name(void) : Attribut<att_type>() {} \ 15 attr_##att_name(const att_type& value_) : Attribut<att_type>(value_) {} \ 16 attr_##att_name(const attr_##att_name & att) : Attribut<att_type>(att) {} \ 17 } att_name 12 \ 13 virtual string getName(void) const { return (#att_name) ;} \ 14 virtual const char * getType(void) const { return (#att_type) ;} \ 15 \ 16 Attr_##att_name(void) : Attribut<att_type>() \ 17 { /* Ne rien faire de plus */ } \ 18 Attr_##att_name(const att_type& _value) : Attribut<att_type>(_value) \ 19 { /* Ne rien faire de plus */ } \ 20 Attr_##att_name(const Attr_##att_name & att) : Attribut<att_type>(att) \ 21 { /* Ne rien faire de plus */ } \ 22 \ 23 virtual ~Attr_##att_name() \ 24 { /* Ne rien faire de plus */ } \ 25 }; \ 26 \ 27 const Attr_##att_name& getAttr_##att_name(void) const { return (att_name); } \ 28 const Attr_##att_name& get_##att_name(void) const { return (att_name); } \ 29 \ 30 void setAttr##att_name(const Attr_##att_name& _newattr) { att_name = _newattr; } \ 31 void set_##att_name (const Attr_##att_name& _newattr) { att_name = _newattr; }\ 32 \ 33 void setAttr##att_name(const att_type& _newattr) { att_name.setValue(_newattr); }\ 34 void set_##att_name (const att_type& _newattr) { att_name.setValue(_newattr); }\ 35 Attr_##att_name att_name 18 36 19 37 #endif // __DECLARE_ATTRIBUT__ -
XMLIO_V2/dev/dev_rv/src/XMLIO/declare_group.hpp
r114 r126 2 2 #define __DECLARE_GROUP__ 3 3 4 #define DECLARE_GROUP(child_type) \ 5 namespace XMLIOSERVER \ 6 { \ 7 class child_type##Group : public GroupTemplate<C##child_type, child_type##Attribut>\ 8 {\ 9 public:\ 10 child_type##Group(void) : GroupTemplate<C##child_type, child_type##Attribut>(){}\ 11 child_type##Group(const string& _id) : GroupTemplate<C##child_type, child_type##Attribut>(_id) {}\ 12 void parse (XMLNode& _node, bool _withAttr = true) { _parse<child_type##Group>(_node, _withAttr); }\ 13 virtual ~child_type##Group(void){}\ 14 }; \ 15 typedef child_type##Group child_type##Definition; \ 4 #define DECLARE_GROUP(child_type) \ 5 namespace XMLIOSERVER \ 6 { \ 7 class child_type##Group \ 8 : public GroupTemplate<C##child_type, child_type##Attribut> \ 9 { \ 10 public: \ 11 \ 12 child_type##Group(void) \ 13 : GroupTemplate<C##child_type, child_type##Attribut>() \ 14 { /* Ne rien faire de plus */ } \ 15 \ 16 child_type##Group(const string& _id) \ 17 : GroupTemplate<C##child_type, child_type##Attribut>(_id) \ 18 { /* Ne rien faire de plus */ } \ 19 \ 20 void parse (XMLNode& _node, bool _withAttr = true) \ 21 { _parse<child_type##Group>(_node, _withAttr); } \ 22 \ 23 virtual ~child_type##Group(void){} \ 24 }; \ 25 \ 26 typedef child_type##Group child_type##Definition; \ 16 27 } 17 28 -
XMLIO_V2/dev/dev_rv/src/XMLIO/domain_attribut.hpp
r120 r126 10 10 public : 11 11 12 DECLARE_ATTR(name, string) ; 13 DECLARE_ATTR(description, string); 14 DECLARE_ATTR(ni_glo, int); 15 DECLARE_ATTR(nj_glo, int) ; 16 DECLARE_ATTR(ibegin, int) ; 17 DECLARE_ATTR(iend, int) ; 18 DECLARE_ATTR(ni, int) ; 19 DECLARE_ATTR(jbegin, int) ; 20 DECLARE_ATTR(jend, int) ; 21 DECLARE_ATTR(nj, int) ; 22 DECLARE_ATTR(mask, Array(bool, 2)) ; 12 DECLARE_ATTR(name , string) ; 13 DECLARE_ATTR(standard_name , string) ; 14 DECLARE_ATTR(long_name , string) ; 23 15 24 DECLARE_ATTR(data_dim, int) ; 25 DECLARE_ATTR(data_ni, int); 26 DECLARE_ATTR(data_nj, int) ; 27 DECLARE_ATTR(data_ibegin, int) ; 28 DECLARE_ATTR(data_jbegin, int) ; 29 DECLARE_ATTR(data_n_index, int) ; 30 DECLARE_ATTR(data_i_index,Array(int, 1)) ; 31 DECLARE_ATTR(data_j_index,Array(int, 1)) ; 16 DECLARE_ATTR(ni_glo , int) ; 17 DECLARE_ATTR(nj_glo , int) ; 18 DECLARE_ATTR(ibegin , int) ; 19 DECLARE_ATTR(iend , int) ; 20 DECLARE_ATTR(ni , int) ; 21 DECLARE_ATTR(jbegin , int) ; 22 DECLARE_ATTR(jend , int) ; 23 DECLARE_ATTR(nj , int) ; 24 DECLARE_ATTR(mask , Array(bool, 2)) ; 25 26 DECLARE_ATTR(data_dim , int) ; 27 DECLARE_ATTR(data_ni , int) ; 28 DECLARE_ATTR(data_nj , int) ; 29 DECLARE_ATTR(data_ibegin , int) ; 30 DECLARE_ATTR(data_jbegin , int) ; 31 DECLARE_ATTR(data_n_index , int) ; 32 DECLARE_ATTR(data_i_index , Array(int, 1)) ; 33 DECLARE_ATTR(data_j_index , Array(int, 1)) ; 32 34 33 35 DomainAttribut(void) : AttributRegistrar() 34 { registerAllAttributes(); }36 { this->registerAllAttributes(); } 35 37 36 38 private : … … 39 41 { 40 42 RegisterAttribut(&name) ; 41 RegisterAttribut(&description) ; 43 RegisterAttribut(&standard_name) ; 44 RegisterAttribut(&long_name) ; 42 45 RegisterAttribut(&ni_glo); 43 46 RegisterAttribut(&nj_glo) ; -
XMLIO_V2/dev/dev_rv/src/XMLIO/field_attribut.hpp
r124 r126 8 8 public : 9 9 10 DECLARE_ATTR(name, string) ; 11 DECLARE_ATTR(description, string) ; 12 DECLARE_ATTR(unit, string) ; 13 DECLARE_ATTR(operation, FieldOperation); 10 DECLARE_ATTR(name , string) ; 11 DECLARE_ATTR(standard_name, string) ; 12 DECLARE_ATTR(long_name , string) ; 14 13 15 DECLARE_ATTR(freq_op, Duration) ; 16 DECLARE_ATTR(level, int) ; 17 DECLARE_ATTR(prec, int) ; 14 DECLARE_ATTR(unit , string) ; 15 DECLARE_ATTR(operation , FieldOperation) ; 18 16 19 DECLARE_ATTR(enabled, bool); 17 DECLARE_ATTR(freq_op , Duration) ; 18 DECLARE_ATTR(level , int) ; 19 DECLARE_ATTR(prec , int) ; 20 20 21 DECLARE_ATTR(domain_ref, string); 22 DECLARE_ATTR(axis_ref, string); 23 DECLARE_ATTR(grid_ref, string) ; 24 DECLARE_ATTR(zoom_ref, string); 25 DECLARE_ATTR(field_ref, string); 21 DECLARE_ATTR(enabled , bool) ; 22 23 DECLARE_ATTR(domain_ref , string) ; 24 DECLARE_ATTR(axis_ref , string) ; 25 DECLARE_ATTR(grid_ref , string) ; 26 DECLARE_ATTR(zoom_ref , string) ; 27 DECLARE_ATTR(field_ref , string) ; 26 28 27 29 FieldAttribut(void) : AttributRegistrar() 28 { registerAllAttributes(); }30 { this->registerAllAttributes(); } 29 31 30 32 private : … … 33 35 { 34 36 RegisterAttribut(&name) ; 35 RegisterAttribut(&description) ; 37 RegisterAttribut(&standard_name) ; 38 RegisterAttribut(&long_name) ; 36 39 RegisterAttribut(&unit) ; 37 40 RegisterAttribut(&operation); … … 42 45 RegisterAttribut(&enabled); 43 46 44 RegisterAttribut(&domain_ref) ;45 RegisterAttribut(&axis_ref) ;46 RegisterAttribut(&grid_ref) ;47 RegisterAttribut(&zoom_ref) ;48 RegisterAttribut(&field_ref) ;47 RegisterAttribut(&domain_ref) ; 48 RegisterAttribut(&axis_ref) ; 49 RegisterAttribut(&grid_ref) ; 50 RegisterAttribut(&zoom_ref) ; 51 RegisterAttribut(&field_ref) ; 49 52 } 50 53 -
XMLIO_V2/dev/dev_rv/src/XMLIO/file_attribut.hpp
r123 r126 8 8 public : 9 9 10 DECLARE_ATTR(name , string) ;11 DECLARE_ATTR(description , string) ;12 DECLARE_ATTR(output_freq , Duration) ;10 DECLARE_ATTR(name , string) ; 11 DECLARE_ATTR(description , string) ; 12 DECLARE_ATTR(output_freq , Duration) ; 13 13 DECLARE_ATTR(output_level, int) ; 14 DECLARE_ATTR(enabled , bool);14 DECLARE_ATTR(enabled , bool); 15 15 16 16 FileAttribut(void) : AttributRegistrar() 17 { registerAllAttributes(); }17 { this->registerAllAttributes(); } 18 18 19 19 private : -
XMLIO_V2/dev/dev_rv/src/XMLIO/grid_attribut.hpp
r120 r126 8 8 public : 9 9 10 DECLARE_ATTR(name , string) ;10 DECLARE_ATTR(name , string) ; 11 11 DECLARE_ATTR(description, string) ; 12 DECLARE_ATTR(domain_ref , string) ;13 DECLARE_ATTR(axis_ref , string) ;12 DECLARE_ATTR(domain_ref , string) ; 13 DECLARE_ATTR(axis_ref , string) ; 14 14 15 15 GridAttribut(void) : AttributRegistrar() 16 { registerAllAttributes(); }16 { this->registerAllAttributes(); } 17 17 18 18 private : -
XMLIO_V2/dev/dev_rv/src/XMLIO/group_template.hpp
r122 r126 9 9 public: 10 10 11 GroupTemplate(void) : ObjectTemplate<GroupTemplate<T, U> >(), U(), childList(), groupList() 12 {/* Ne rien faire de plus */} 13 GroupTemplate(const string& _id) : ObjectTemplate<GroupTemplate<T, U> >(_id), U(), childList(), groupList() 14 {/* Ne rien faire de plus */} 11 GroupTemplate(void) 12 : ObjectTemplate<GroupTemplate<T, U> >(), U(), childList(), groupList() 13 { /* Ne rien faire de plus */ } 14 15 GroupTemplate(const string& _id) 16 : ObjectTemplate<GroupTemplate<T, U> >(_id), U(), childList(), groupList() 17 { /* Ne rien faire de plus */ } 15 18 16 19 /// Pour les groupes d'objets enfants /// 17 20 18 static string GetName(void) {return (T::GetName().append("_group")); } 19 static string GetDefName(void) {return (T::GetName().append("_definition")); } 21 GroupTemplate<T, U>& createGroup(const string& _id) 22 throw (XMLIOUndefinedValueException) 23 { 24 GroupTemplate<T, U> &obj = *GroupTemplate<T, U>::CreateObject(_id); 25 groupList.addObject(&obj); 26 27 return (obj); 28 } 29 30 GroupTemplate<T, U>& createGroup(void) 31 { 32 GroupTemplate<T, U>& obj = *(GroupTemplate<T, U>::CreateObject()); 33 groupList.addObject(&obj); 34 35 return (obj); 36 } 37 38 GroupTemplate<T, U>& getGroup(const string& _id) const 39 throw (XMLIOUndefinedValueException) 40 { return (*groupList[_id]); } 41 42 bool hasGroup(const string& _id) const { return (groupList.hasMappedValue(_id)); } 43 44 const StrHashMap<GroupTemplate<T, U>* >& getGroupList(void) const { return (groupList); } 45 46 size_t getNbGroup() const {return (groupList.getVectorSize()); } 47 48 /// Pour les objets enfants /// 49 50 T& createChild(const string& _id) 51 throw (XMLIOUndefinedValueException) 52 { 53 T& obj = *ObjectTemplate<T>::CreateObject(_id); 54 childList.addObject(&obj); 55 return (obj); 56 } 57 58 T& createChild(void) 59 { 60 T& obj = *ObjectTemplate<T>::CreateObject(); 61 childList.addObject(&obj); 62 return (obj); 63 } 64 65 T& getChild(const string& _id) const 66 throw (XMLIOUndefinedValueException) 67 { return (*childList[_id]); } 68 69 bool hasChild(const string& _id) const { return (childList.hasMappedValue(_id)); } 70 71 const StrHashMap<T*> & getCurrentListChild (void) const { return (childList); } 72 const std::vector<T*>& getCurrentVectorChild(void) const { return (childList.getVector()); } 73 74 size_t getNbChild() const {return (childList.getVectorSize()); } 75 76 void getAllChildren(std::vector<T*>& _allc ) const 77 { 78 const vector<GroupTemplate<T, U>*>& groupvect = groupList.getVector(); 79 _allc.insert (_allc.end(), getCurrentVectorChild().begin(), getCurrentVectorChild().end()); 80 81 for(unsigned int i = 0; i < groupvect.size() ; i++) 82 groupvect[i] -> getAllChildren(_allc); 83 } 84 85 public : /* static */ 86 87 static string GetName(void) { return (T::GetName().append("_group")); } 88 static string GetDefName(void) { return (T::GetName().append("_definition")); } 89 90 public : /* virtual */ 91 92 virtual ~GroupTemplate() 93 { 94 for (unsigned int i = 0; i < childList.getVector().size(); i++) 95 delete childList.getVector()[i]; 96 for (unsigned int i = 0; i < groupList.getVector().size(); i++) 97 delete groupList.getVector()[i]; 98 } 20 99 21 100 virtual bool hasChild(void) const { return ((getNbGroup() + getNbChild())>0); } … … 35 114 const vector<GroupTemplate<T, U>*>& groupvect = groupList.getVector(); 36 115 37 // On complÚte les propres attributs du groupe .38 if (_parent != NULL) AttributRegistrar::addAttributes(*_parent);116 // On complÚte les propres attributs du groupe avec ceux du parent. 117 if (_parent != NULL) AttributRegistrar::addAttributes(*_parent); 39 118 40 119 for(unsigned int i = 0; i < childvect.size() ; i++) … … 45 124 // on complÚte les attributs des groupes enfants. 46 125 groupvect[i] -> resolveDescInheritance(this); 47 }48 49 GroupTemplate<T, U>& createGroup(const string& _id) throw (XMLIOUndefinedValueException)50 {51 GroupTemplate<T, U> &obj = *GroupTemplate<T, U>::CreateObject(_id);52 groupList.addObject(&obj);53 54 return (obj);55 }56 57 GroupTemplate<T, U>& createGroup(void)58 {59 GroupTemplate<T, U>& obj = *(GroupTemplate<T, U>::CreateObject());60 groupList.addObject(&obj);61 62 return (obj);63 }64 65 GroupTemplate<T, U>& getGroup(const string& _id) throw (XMLIOUndefinedValueException) { return (*groupList[_id]); }66 bool hasGroup(const string _id) { return (groupList.hasMappedValue(_id)); }67 68 const StrHashMap<GroupTemplate<T, U>* >& getGroupList(void) const { return (groupList); }69 70 size_t getNbGroup() const {return (groupList.getVectorSize()); }71 72 /// Pour les objets enfants ///73 74 T& createChild(const string& _id) throw (XMLIOUndefinedValueException)75 {76 T& obj = *ObjectTemplate<T>::CreateObject(_id);77 childList.addObject(&obj);78 return (obj);79 }80 81 T& createChild(void)82 {83 T& obj = *ObjectTemplate<T>::CreateObject();84 childList.addObject(&obj);85 return (obj);86 }87 88 T& getChild(const string& _id) throw (XMLIOUndefinedValueException) { return (*childList[_id]); }89 bool hasChild(const string& _id) { return (childList.hasMappedValue(_id)); }90 91 const StrHashMap<T*>& getCurrentListChild(void) const { return (childList); }92 const vector<T*>& getCurrentVectorChild(void) const { return (childList.getVector()); }93 94 size_t getNbChild() const {return (childList.getVectorSize()); }95 96 void getAllChildren(std::vector<T*>& _allc )97 {98 const vector<GroupTemplate<T, U>*>& groupvect = groupList.getVector();99 _allc.insert (_allc.end(), getCurrentVectorChild().begin(), getCurrentVectorChild().end());100 101 for(unsigned int i = 0; i < groupvect.size() ; i++)102 groupvect[i] -> getAllChildren(_allc);103 }104 105 virtual ~GroupTemplate()106 {107 for (unsigned int i = 0; i < childList.getVector().size(); i++)108 delete childList.getVector()[i];109 for (unsigned int i = 0; i < groupList.getVector().size(); i++)110 delete groupList.getVector()[i];111 126 } 112 127 … … 158 173 {// Si l'identifiant est défini. 159 174 if (V::HasObject(attributes["id"])) 160 WARNING("Dans le context actuel, une instance de type "+V::GetName()+" nommée \""+attributes["id"]+"\" existe déjà , le second fera référence au premier par défaut !"); // TODO TODO 175 WARNING("Dans le context actuel, une instance de type "+V::GetName()+" nommée \""+attributes["id"] 176 +"\" existe déjà , le second fera référence au premier par défaut !"); // TODO TODO 161 177 instance_ptr = (V*)(&createGroup(attributes["id"])); 162 178 instance_ptr->parse(_node); … … 176 192 {// Si l'identifiant est défini. 177 193 if (V::HasObject(attributes["id"])) 178 WARNING("Dans le context actuel, une instance de type "+V::GetName()+" nommée \""+attributes["id"]+"\" existe déjà , le second fera référence au premier par défaut !"); // TODO TODO 194 WARNING("Dans le context actuel, une instance de type "+V::GetName()+" nommée \""+attributes["id"] 195 +"\" existe déjà , le second fera référence au premier par défaut !"); // TODO TODO 179 196 instance_ptr = (V*)(&createChild(attributes["id"])); 180 197 instance_ptr->parse(_node); -
XMLIO_V2/dev/dev_rv/src/XMLIO/object_template.hpp
r125 r126 27 27 28 28 if (c.baseObject != NULL) 29 out << IncIndent << "<-- Reference resolved for the following "+ T::GetName() + 30 " : \"" << c.baseObject->getId() << "\" -->" << DecEndl << std::endl; 29 out << IncIndent << "<-- Référence résolu sur l'instance de "<< T::GetName() 30 << " nommée \"" << c.baseObject->getId() << "\" -->" << DecEndl << std::endl; 31 32 if (c.isDefinition()) 33 { 34 out << NIndent << std::endl; 35 out << NIndent << "<!-- Groupe de définition dans le contexte \"" << ObjectTemplate<T>::GetCurrentContextId() << "\" courant -->" << std::endl; 36 } 31 37 32 38 if (c.hasChild()) 33 39 { 34 out << IncIndent << "<" << c.getName()<< c.printId() << ar << ">" << std::endl;40 out << IncIndent << "<" << c.getName() << c.printId() << ar << ">" << std::endl; 35 41 c.printChild(out); // << Ecriture des objets enfants ici. 42 if (c.hasId() && (c.getName().compare("context") == 0)) 43 out << NIndent << std::endl; 36 44 out << NIndent << "</" << c.getName() << ">" << DecEndl; 37 45 } 38 else out << IncIndent << "<" << c.getName() << c.printId() << ar << "/>" << DecEndl; 46 else 47 out << IncIndent << "<" << c.getName() << c.printId() << ar << "/>" << DecEndl; 39 48 40 49 return (out); 41 50 } 42 51 52 bool isDefinition(void) const 53 { 54 if (!this->hasId()) return (false); 55 return (this->getName().compare(this->getId()) == 0); 56 } 57 43 58 string getName(void) const 44 59 { 45 if ( hasId())60 if (this->hasId()) 46 61 if (T::GetDefName().compare(getId()) == 0) 47 return T::GetDefName();62 return (T::GetDefName()); 48 63 return (T::GetName()); 49 64 } … … 51 66 T* getBaseObject(void) const { return (baseObject); } 52 67 53 virtual T* getReference(void) const { return (NULL); }54 55 68 const vector<T*>& getVectRefObject(void) const { return (refObject); } 56 69 57 bool hasRefObject(void) { return (!refObject.empty()); }70 bool hasRefObject(void) const { return (!refObject.empty()); } 58 71 59 72 const T* addRefObject(T* obj) 60 73 { refObject.push_back (obj); return (obj); } 61 74 75 public : /* virtual */ 76 77 virtual T* getReference(void) const { return (NULL); } 62 78 virtual bool hasChild(void) const { return (false); } 63 virtual void printChild(ostream& out) const { out << NIndent << "<!-- No child -->" << std::endl; } 64 65 virtual void resolveDescInheritance(const AttributRegistrar* _parent = 0) { addAttributes(*_parent); } 79 80 virtual void printChild(ostream& out) const 81 { out << NIndent << "<!-- No child -->" << std::endl; } 82 83 virtual void resolveDescInheritance(const AttributRegistrar* _parent = 0) 84 { this->addAttributes(*_parent); } 85 66 86 virtual void resolveRefInheritance (void) 67 87 { … … 89 109 90 110 /// PARSING POUR GESION DES ENFANTS /// 91 // Rien à faire. 92 } 111 // Rien à faire ici. 112 } 113 114 virtual ~ObjectTemplate(void) 115 {/* Ne rien faire de plus */} 93 116 94 117 public : /* static */ … … 118 141 static bool HasObject(const string& _id) 119 142 { 120 if(ObjectTemplate<T>::AllListObj.find(CurrContext) == ObjectTemplate<T>::AllListObj.end()) return false; 143 if(ObjectTemplate<T>::AllListObj.find(CurrContext) == 144 ObjectTemplate<T>::AllListObj.end()) 145 return (false); 121 146 return (ObjectTemplate<T>::AllListObj[CurrContext].hasMappedValue(_id)); 122 147 } … … 125 150 static Poco::HashMap<string, StrHashMap<T> >& GetAllListObject(void) { return (AllListObj); } 126 151 127 static void SetContext(const string& id){ ObjectTemplate<T>::CurrContext = id; } 128 129 static string& GetCurrentContextId(void) { return (CurrContext); } 130 131 virtual ~ObjectTemplate(void) 132 {/* Ne rien faire de plus */} 152 static void SetContext(const string& id) { ObjectTemplate<T>::CurrContext = id; } 153 154 static string& GetCurrentContextId(void) { return (ObjectTemplate<T>::CurrContext); } 133 155 134 156 protected : 135 157 136 ObjectTemplate(void) : AbstractObject(), baseObject(NULL), refObject() 137 {/* Ne rien faire de plus */} 138 ObjectTemplate(const string& _id) : AbstractObject(_id), baseObject(NULL), refObject() 139 {/* Ne rien faire de plus */} 158 ObjectTemplate(void) 159 : AttributRegistrar(), AbstractObject(), baseObject(NULL), refObject() 160 { /* Ne rien faire de plus */ } 161 162 ObjectTemplate(const string& _id) 163 : AttributRegistrar(), AbstractObject(_id), baseObject(NULL), refObject() 164 { /* Ne rien faire de plus */ } 165 166 ObjectTemplate(const ObjectTemplate<T>& _ot, bool _withAttrList = true, bool _withId = true) 167 : AttributRegistrar(), AbstractObject(), baseObject(_ot.baseObject), refObject(_ot.refObject) 168 { 169 // Si requis, ajout de l'identifiant lors de la copie. 170 if (_ot.hasId() && _withId) this->setId(_ot.getId()); 171 // Si requis, ajout des attributs lors de la copie. 172 if (_withAttrList) this->addAttributes(_ot); 173 } 140 174 141 175 XML::XMLNode getNodeIncludedFile(const string& path, const string& _rootName) 142 176 { 143 177 ifstream istr( path.c_str() , ifstream::in ); 144 return XML::XMLNode::CreateNode(istr, _rootName);178 return (XML::XMLNode::CreateNode(istr, _rootName)); 145 179 } 146 180 … … 151 185 { 152 186 if (V::HasObject(did)) 153 WARNING("Le noeud nommé \""+ did +"\" existe déjà pour les instances de type "+V::GetName()+", le dernier défini complétera le premier dans le context actuel!"); 187 WARNING("Le noeud nommé \""+ did +"\" existe déjà pour les instances de type "+ 188 V::GetName()+", le dernier défini complétera le premier dans le context actuel!"); 154 189 instance_ptr = (V*)V::CreateObject(did); 155 190 instance_ptr->parse(_node, parseAttr); … … 159 194 160 195 private : 196 161 197 T* baseObject; 162 vector<T*> refObject; 198 std::vector<T*> refObject; 199 200 private : /* static */ 163 201 164 202 static string CurrContext; … … 167 205 };// class ObjectTemplate 168 206 207 // Initialisation des variables statiques de la classe ObjectTemplate. 169 208 template <class T> string ObjectTemplate<T>::CurrContext ; 170 209 template <class T> Poco::HashMap<string, StrHashMap<T> > ObjectTemplate<T>::AllListObj; -
XMLIO_V2/dev/dev_rv/src/XMLIO/xml_node.hpp
r120 r126 12 12 { 13 13 public : 14 15 static XMLNode CreateNode(std::istream& _istr, const std::string& _rootName)16 {17 XMLNode node(_rootName);18 19 if (_istr.good())20 { // S'il est possible de lire le flux en entrée ...21 22 Poco::XML::InputSource src(_istr);23 Poco::XML::DOMParser parser;24 25 node.pDoc = parser.parse(&src);26 node.setCNode(node.pDoc->documentElement());27 if (node.getElementName().compare(_rootName) != 0) // << A passer en avertissement.28 throw XMLParsingException("L'élément racine doit avoir pour valeur <" + _rootName + "> (\"" + node.getElementName() + "\" lue)");29 }30 else31 throw XMLIOStreamException("Impossible de lire le flux en entrée pour le parsing XML !");32 33 return (node);34 }35 14 36 15 string getElementName(void) const … … 97 76 } 98 77 78 THashAttributes getAttributes(void) const // Idem que précédemment mais avec copie. 79 { THashAttributes __attributes; this->getAttributes(__attributes); return (__attributes); } 80 99 81 ~XMLNode() 100 82 { /* Ne rien faire de plus */ } 83 84 public : /* static */ 85 86 static XMLNode CreateNode(std::istream& _istr, const std::string& _rootName) 87 { 88 XMLNode node(_rootName); 89 90 if (_istr.good()) 91 { // S'il est possible de lire le flux en entrée ... 92 93 Poco::XML::InputSource src(_istr); 94 Poco::XML::DOMParser parser; 95 96 node.pDoc = parser.parse(&src); 97 node.setCNode(node.pDoc->documentElement()); 98 if (node.getElementName().compare(_rootName) != 0) // << A passer en avertissement. 99 throw XMLParsingException("L'élément racine doit avoir pour valeur <" + _rootName + "> (\"" + node.getElementName() + "\" lue)"); 100 } 101 else 102 throw XMLIOStreamException("Impossible de lire le flux en entrée pour le parsing XML !"); 103 104 return (node); 105 } 101 106 102 107 protected : … … 104 109 Poco::XML::Node * getCNode(void) const { return (this->cNode); } 105 110 void setCNode(Poco::XML::Node * _otherNode) { this->cNode = _otherNode; } 111 112 protected : /* static */ 106 113 107 114 static bool IsPtrNull(const Poco::XML::Node * const _ptr) { return (_ptr == NULL); } … … 120 127 121 128 Poco::XML::AutoPtr<Poco::XML::Document> pDoc; 122 Poco::XML::Node* 129 Poco::XML::Node* cNode; 123 130 124 131 string rootName; -
XMLIO_V2/dev/dev_rv/src/XMLIO/xmlio.hpp
r125 r126 12 12 #include <stack> 13 13 14 // Flux.14 // Flux. 15 15 #include <iostream> 16 16 #include <fstream> … … 87 87 #include "NetCDF4_data_output.hpp" 88 88 89 // Traitement des données (abstract puis selon types de sortie) 90 #include "abstract_data_treatment.hpp" 91 #include "NetCDF4_data_treatment.hpp" 92 93 89 // Traitement des données. 90 #include "data_treatment.hpp" 94 91 95 92 #endif // __XMLIO__
Note: See TracChangeset
for help on using the changeset viewer.