Changeset 120
- Timestamp:
- 09/08/10 15:02:31 (14 years ago)
- Location:
- XMLIO_V2/dev/dev_rv/src/XMLIO
- Files:
-
- 5 added
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
XMLIO_V2/dev/dev_rv/src/XMLIO/abstract_calendar.hpp
r119 r120 31 31 for(_d0.setMonth(1); _d0.getMonth() < d.getMonth(); _d0.setMonth(_d0.getMonth()+1)) 32 32 nbday += getMonthLength(_d0); 33 //std::cout << "nombre de jours : " << nbday << std::endl;34 33 return ((((nbday + d.getDay()) * getDayLength() + d.getHour()) 35 34 * getHourLength() + d.getMinute()) * getMinuteLength() + d.getSecond()); -
XMLIO_V2/dev/dev_rv/src/XMLIO/abstract_object.hpp
r112 r120 1 1 #ifndef __XMLIO_OBJECT__ 2 #define __XMLIO_OBJECT__ 3 4 // Classes utilisées issues de la STL 5 using std::pair; 6 using std::string; 7 using std::ostream; 8 using std::ostringstream; 9 10 // Classes XMLIOSERVER 11 using XMLIOSERVER::XMLIOException; 12 using XMLIOSERVER::XMLIOUndefinedValueException; 2 #define __XMLIO_OBJECT__ 13 3 14 4 namespace XMLIOSERVER 15 5 { 16 class AbstractObject 6 class AbstractObject 17 7 { 18 8 public : 19 9 10 const std::string& getId(void) const throw (XMLIOUndefinedValueException) 11 { 12 if (!hasId()) // Si l'identifiant de l'objet n'est pas défini. 13 throw XMLIOSERVER::XMLIOUndefinedValueException("Appel de la méthode AbstractObject::getId invalide."); 14 return (id); 15 } 16 17 bool hasId(void) const { return(IdDefined); } 18 void resetId(void) { IdDefined = false ;} 19 void setId(const std::string& _id) { id = _id ; IdDefined = true ;} 20 21 bool operator==(const AbstractObject& other) const 22 { 23 // Si l'un ou l'autre des objets n'a pas d'identifiant, les objets ne sont pas "égaux". 24 if(!this->hasId() || !other.hasId()) return false; 25 return (id.compare(other.id) == 0); 26 } 27 28 std::string printId(void) const 29 { if(hasId()) return (" id=\""+getId()+"\""); return (""); } 30 31 virtual ~AbstractObject(void) 32 {/* Ne rien faire de plus */} 33 34 protected : 35 20 36 AbstractObject(void) : IdDefined(false) 21 37 {/* Ne rien faire de plus */} 22 23 AbstractObject(const string& _id) : id(_id), IdDefined(true) 24 {/* Ne rien faire de plus */} 25 26 const string& getId(void) const throw (XMLIOUndefinedValueException) 27 { if (!IdDefined) throw XMLIOUndefinedValueException("Appel de la méthode AbstractObject::getId invalide."); return (id); } 28 29 bool hasId(void) const { return(IdDefined); } 30 void resetId(void) { IdDefined = false ;} 31 void setId(const string& _id) { id = _id ; IdDefined = true ;} 32 33 bool operator==(const AbstractObject& other) 34 { 35 // Si l'un ou l'autre des objets n'a pas d'identifiant, les objets ne sont pas "égaux". 36 if(!this->hasId() or !other.hasId()) return false; 37 return (id.compare(other.id) == 0); 38 } 39 40 string printId(void) const 41 { if(hasId()) return (" id=\""+getId()+"\""); return (""); } 42 43 virtual ~AbstractObject(void) 38 39 AbstractObject(const std::string& _id) : id(_id), IdDefined(true) 44 40 {/* Ne rien faire de plus */} 45 46 protected :47 41 48 49 42 private : 50 51 st ring id ;43 44 std::string id ; 52 45 bool IdDefined ; 53 46 54 47 };// class AbstractObject 55 48 56 49 }// namespace XMLIOSERVER 57 50 58 #endif // __XMLIO_OBJECT__ 51 #endif // __XMLIO_OBJECT__ -
XMLIO_V2/dev/dev_rv/src/XMLIO/attribut.hpp
r119 r120 7 7 using XMLIOSERVER::XMLIOUndefinedValueException; 8 8 using std::ostringstream; 9 using namespace blitz ; 9 10 10 11 namespace XMLIOSERVER 11 12 { 12 class IStringStream_alt13 {14 public :15 IStringStream_alt(const std::string& str) : iss(str)16 { /* Ne rien faire de plus */}17 18 istream& operator>> (std::string& s)19 {s.assign(this->iss.str()); return (this->iss);}20 istream& operator>> (int& s) { return (iss>>s); }21 istream& operator>> (bool& s)22 {23 if(!this->iss.str().compare(string(".TRUE."))) s = true;24 else s = false;25 return (this->iss);26 }27 28 private :29 istringstream iss;30 31 }; // class IStringStream_alt32 33 34 13 template <class Ctype> 35 14 class Attribut : public BaseAttribut 36 15 { 37 16 public : 38 39 17 operator Ctype() const 40 18 { 41 if (! hasValue) throw XMLIOUndefinedValueException("L'attribut \"" + this->getName() + "\" est invalide !");19 if (!_hasValue) throw XMLIOUndefinedValueException("L'attribut \"" + this->getName() + "\" est invalide !"); 42 20 return (value) ; 43 21 } 44 22 45 virtual bool _hasValue() const { return (hasValue); } 23 Ctype* operator ->() { return (&value) ; } 24 Ctype& operator *() { return (value) ; } 46 25 47 protected : 26 virtual bool hasValue() const { return (_hasValue); } 27 virtual const char * getType(void) const = 0; 48 28 49 Attribut(void) : hasValue(false) {} ;50 Attribut(const Ctype& value_) : hasValue(true), value(value_) {} ;29 Attribut(void) : _hasValue(false) {} ; 30 Attribut(const Ctype& value_) : _hasValue(true), value(value_) {} ; 51 31 52 Attribut(const Attribut& attr) : hasValue(attr.hasValue)53 { if ( hasValue) value=attr.value ; }32 Attribut(const Attribut& attr) : _hasValue(attr._hasValue) 33 { if (_hasValue) value = attr.value ; } 54 34 55 35 Attribut& operator = (const Attribut & attr) 56 36 { 57 hasValue=attr.hasValue ;58 if ( hasValue) value=attr.value;59 return *this;37 _hasValue = attr._hasValue ; 38 if (_hasValue) setValue(attr.value) ; 39 return (*this) ; 60 40 } 61 41 62 virtual const char * getType(void) const = 0; 63 64 virtual void setFromString(const std::string str) 42 virtual void setFromString(const std::string& str) 65 43 { 66 IStringStream_altiss(str); Ctype val;44 istringstream iss(str); Ctype val; 67 45 iss >> val; 68 46 this->setValue(val); … … 70 48 71 49 virtual void assignValue(const BaseAttribut* _ba) 72 { value = ((Attribut*)_ba) -> value; hasValue = true; }50 { value = ((Attribut*)_ba) -> value; _hasValue = true; } 73 51 74 52 virtual ostream& print(ostream & o) const 75 { if ( hasValue) o << " " << getName() << "=\"" << boolalpha << value << "\"" ; return o ; }53 { if (_hasValue) o << " " << getName() << "=\"" << boolalpha << value << "\"" ; return o ; } 76 54 77 55 virtual void setValue(const Ctype & value_) 78 { hasValue=true ; value=value_ ;}56 { _hasValue = true ; value = value_ ;} 79 57 80 58 virtual void getValue(Ctype & value_) const 81 59 { 82 if (! hasValue) throw XMLIOUndefinedValueException("L'attribut \"" + this->getName() + "\" est invalide !");83 value_ =value ;60 if (!_hasValue) throw XMLIOUndefinedValueException("L'attribut \"" + this->getName() + "\" est invalide !"); 61 value_ = value ; 84 62 } 85 63 86 64 private : 87 65 88 bool hasValue ;66 bool _hasValue ; 89 67 Ctype value ; 90 68 91 69 }; // class Attribut 70 71 #define SET_ARRAY_DIM(type,dim) \ 72 template<> \ 73 void Attribut<Array<type,dim> >::setValue (const Array<type,dim>& val) \ 74 { _hasValue = true ; value.resize(val.shape()); value = val ; } 75 76 #define SET_ARRAY_TYPE(type) \ 77 SET_ARRAY_DIM(type,1) \ 78 SET_ARRAY_DIM(type,2) \ 79 SET_ARRAY_DIM(type,3) \ 80 SET_ARRAY_DIM(type,4) 81 82 SET_ARRAY_TYPE(double) 83 SET_ARRAY_TYPE(int) 84 SET_ARRAY_TYPE(bool) 85 86 template <> 87 void Attribut<bool>::setFromString(const std::string& str) 88 { 89 istringstream iss(str) ; 90 bool val = (! iss.str().compare(string(".TRUE."))) ? true : false; 91 this->setValue(val); 92 } 93 94 template <> 95 void Attribut<string>::setFromString(const std::string& str) 96 { this->setValue(str); } 97 92 98 } // namespace XMLIOSERVER 93 99 94 100 #endif //__ATTRIBUT__ 95 96 -
XMLIO_V2/dev/dev_rv/src/XMLIO/attribut_registrar.hpp
r114 r120 45 45 for(unsigned int i = 0; i < _lattr.getVectorSize(); i++) 46 46 { 47 if(_lattr.getVector()[i]-> _hasValue() or !_pattr.getVector()[i]->_hasValue()) continue;47 if(_lattr.getVector()[i]->hasValue() or !_pattr.getVector()[i]->hasValue()) continue; 48 48 _lattr.getVector()[i]->assignValue(_pattr.getVector()[i]); 49 49 } -
XMLIO_V2/dev/dev_rv/src/XMLIO/axis_attribut.hpp
r110 r120 1 1 #ifndef __AXIS_ATTRIBUT__ 2 2 #define __AXIS_ATTRIBUT__ 3 4 using namespace blitz ; 3 5 4 6 namespace XMLIOSERVER … … 11 13 DECLARE_ATTR(description, string) ; 12 14 DECLARE_ATTR(unit, string) ; 13 DECLARE_ATTR(size_axis, int) ; 15 DECLARE_ATTR(size, int) ; 16 DECLARE_ATTR(value, Array(double,1)) ; 14 17 15 18 AxisAttribut(void) : AttributRegistrar() … … 23 26 RegisterAttribut(&description) ; 24 27 RegisterAttribut(&unit) ; 25 RegisterAttribut(&size_axis) ; 28 RegisterAttribut(&size) ; 29 RegisterAttribut(&value) ; 26 30 } 27 31 -
XMLIO_V2/dev/dev_rv/src/XMLIO/base_attribut.hpp
r114 r120 24 24 25 25 virtual void assignValue(const BaseAttribut*) = 0; 26 virtual void setFromString(const std::string str) = 0;27 virtual bool _hasValue() const = 0;26 virtual void setFromString(const std::string&) = 0; 27 virtual bool hasValue() const = 0; 28 28 29 29 #define SETTER_AND_GETTER(TYPE) \ … … 32 32 virtual void setValue(const Array<TYPE,2>& value) { error_set() ; }\ 33 33 virtual void setValue(const Array<TYPE,3>& value) { error_set() ; }\ 34 virtual void setValue(const Array<TYPE,4>& value) { error_set() ; }\ 34 35 virtual void getValue(TYPE & value) const { error_get() ; }\ 35 36 virtual void getValue(Array<TYPE,1>& value) const { error_get() ; }\ 36 37 virtual void getValue(Array<TYPE,2>& value) const { error_get() ; }\ 37 virtual void getValue(Array<TYPE,3>& 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 40 39 41 SETTER_AND_GETTER(int) -
XMLIO_V2/dev/dev_rv/src/XMLIO/c_interface.cpp
r119 r120 12 12 try 13 13 { 14 /*string file("/local/XMLIOSERVER_DEV/dev_rv/test/iodef_test.xml");14 string file("/local/XMLIOSERVER_DEV/dev_rv/test/iodef_test.xml"); 15 15 //string file("/local/XMLIOSERVER_DEV/dev_rv/iodef_test.xml"); 16 16 … … 23 23 24 24 // On résoud les héritages descendants ainsi que les héritages par référence. 25 Context::ResolveInheritance();*/25 //Context::ResolveInheritance(); // Plus nécessaire!! 26 26 27 // On se place dans le contexte 'context1'. 28 Context::SetCurrentContext("context1") ; 29 30 // On crée une instance de traitement de données dans le format NetCDF4. 31 AbstractDataTreatment *dtreat = new NetCDF4DataTreatment(Context::GetObject("context1")); 32 33 // Affichage de la liste des fichiers à sortir (par id). 34 dtreat->printEnabledFilesId(); 35 36 // On écrit l'arborescence résultante du traitement sur la sortie. 37 //Context::ShowTree(std::clog); 38 39 delete dtreat; 40 41 } 42 catch(const Exception &exc) 43 { // Pour tout type d'exceptions, on note les informations sur la sortie paramétrée. 44 ERROR(exc.displayText()); 45 // On retourne le code d'erreur en fin d'application pour traitements éventuels. 46 // return (exc.code()); 47 } 48 49 // return (0); 50 } 51 52 53 /* CODE TEST POUR CALENDRIER 27 54 AbstractCalendar* calendar = new GregorianCalendar(); 55 28 56 Date dd (*calendar, 2000, 05, 03, 00, 00, 00) ; 29 57 Date ddd(*calendar, 2030, 11, 02, 10, 33, 40) ; … … 61 89 62 90 delete calendar; 91 */ 63 92 64 //On écrit l'arborescence résultante du traitement sur la sortie.65 //Context::ShowTree(std::clog);66 67 }68 catch(const Exception &exc)69 { // Pour tout type d'exceptions, on note les informations sur la sortie paramétrée.70 ERROR(exc.displayText());71 // On retourne le code d'erreur en fin d'application pour traitements éventuels.72 // return (exc.code());73 }74 75 // return (0);76 } -
XMLIO_V2/dev/dev_rv/src/XMLIO/calendar.hpp
r119 r120 9 9 JulianCalendar() : AbstractCalendar("Julian") 10 10 {/* Ne rien faire de plus */} 11 JulianCalendar(const string& dateStr) : AbstractCalendar("Julian",dateStr)11 JulianCalendar(const string& _dateStr) : AbstractCalendar("Julian", _dateStr) 12 12 {/* Ne rien faire de plus */} 13 13 14 virtual int getYearTotalLength(const Date& d) const14 virtual int getYearTotalLength(const Date& _d) const 15 15 { // Retourne la durée d'une année en seconde. 16 if ( d.getYear()%4 == 0) return (366 * 86400);16 if (_d.getYear()%4 == 0) return (366 * 86400); 17 17 return (365 * 86400); 18 18 } 19 19 20 virtual int getMonthLength(const Date& d) const20 virtual int getMonthLength(const Date& _d) const 21 21 { // Retourne la durée du mois en jour. 22 if ( d.getMonth() == 2)23 { if ( d.getYear()%4 == 0) return 29; return 28; }24 return AbstractCalendar::getMonthLength(d);22 if (_d.getMonth() == 2) 23 { if (_d.getYear()%4 == 0) return 29; return 28; } 24 return (AbstractCalendar::getMonthLength(_d)); 25 25 } 26 26 … … 49 49 { // Traitement du cas particulier en Février. 50 50 if ((d.getYear() % 4 == 0) && (d.getYear() % 100 != 0 || d.getYear() % 400 == 0)) 51 return 29;52 return 28;51 return (29); 52 return (28); 53 53 } 54 return AbstractCalendar::getMonthLength(d);54 return (AbstractCalendar::getMonthLength(d)); 55 55 } 56 56 … … 82 82 83 83 virtual int getMonthLength(const Date& d) const 84 { if (d.getMonth() == 2) return (29); return AbstractCalendar::getMonthLength(d); }84 { if (d.getMonth() == 2) return (29); return (AbstractCalendar::getMonthLength(d)); } 85 85 86 86 virtual int getYearTotalLength(const Date& d) const { return (366 * 86400); } -
XMLIO_V2/dev/dev_rv/src/XMLIO/container.hpp
r114 r120 1 1 #ifndef __XMLIO_CONTAINER__ 2 2 #define __XMLIO_CONTAINER__ 3 4 // Classes utilisées issues de Poco5 using Poco::HashMap;6 using Poco::Hash;7 3 8 4 // Classes utilisées issues de la STL … … 12 8 using std::ostream; 13 9 14 // Classes XMLIOSERVER15 using XMLIOSERVER::XMLIOUndefinedValueException;16 17 10 namespace XMLIOSERVER 18 11 { 19 template<class Key, class Mapped, class HashFunc = Hash<Key> >12 template<class Key, class Mapped, class HashFunc = Poco::Hash<Key> > 20 13 class ExHashMap 21 : private HashMap<Key, Mapped*,Hash<Key> >14 : private Poco::HashMap<Key, Mapped*, Poco::Hash<Key> > 22 15 { 23 16 public : 24 25 ExHashMap() : HashMap<Key, Mapped*, Hash<Key> >(), _elemList()26 {/* Ne rien faire de plus */}27 17 28 18 Mapped* operator[] (const Key& kval) throw (XMLIOUndefinedValueException) 29 19 { 30 20 if(!hasMappedValue(kval)) 31 throw XMLIO UndefinedValueException("Appel de la méthode ExHashMap::operator["+kval+"] invalide.");21 throw XMLIOSERVER::XMLIOUndefinedValueException("Appel de la méthode ExHashMap::operator["+kval+"] invalide."); 32 22 return (find(kval)->second); 33 23 } … … 44 34 45 35 protected : 36 37 ExHashMap() : Poco::HashMap<Key, Mapped*, Poco::Hash<Key> >(), _elemList() 38 {/* Ne rien faire de plus */} 46 39 47 40 bool addValue(const Key& kval, Mapped* element) … … 77 70 template<class Mapped> 78 71 class StrHashMap 79 : public ExHashMap<string, Mapped, Hash<string> >72 : public ExHashMap<string, Mapped, Poco::Hash<string> > 80 73 { 81 74 public : 82 75 83 StrHashMap() : ExHashMap<string, Mapped, Hash<string> >()76 StrHashMap() : ExHashMap<string, Mapped, Poco::Hash<string> >() 84 77 {/* Ne rien faire de plus */} 85 78 86 79 bool addObject(Mapped* element) 87 { if(element->hasId()) return(addValue(element->getId(), element)); 80 { if(element->hasId()) return(addValue(element->getId(), element)); return(addValue(element)); } 88 81 89 82 bool removeObject(const string& kval) 90 83 { 91 if(!ExHashMap<string, Mapped, Hash<string> >::hasMappedValue(kval)) return (false);92 ExHashMap<string, Mapped, Hash<string> >::removeValue(kval); return (true);84 if(!ExHashMap<string, Mapped, Poco::Hash<string> >::hasMappedValue(kval)) return (false); 85 ExHashMap<string, Mapped, Poco::Hash<string> >::removeValue(kval); return (true); 93 86 } 94 87 -
XMLIO_V2/dev/dev_rv/src/XMLIO/context.hpp
r119 r120 22 22 os << NIndent << "<"<< Context::GetRootName() << ">" << std::endl; 23 23 24 HashMap<string, StrHashMap<Context> > &AllListContext = Context::GetAllListObject();25 for ( HashMap<string, StrHashMap<Context> >::Iterator it = AllListContext.begin(); it != AllListContext.end(); it++)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 26 // On sort chacun des contextes successivement. 27 27 { Context::SetCurrentContext((*it).first); os << *((*it).second)[(*it).first] << std::endl; } … … 32 32 static void FreeMemory(void) 33 33 { 34 HashMap<string, StrHashMap<Context> > &AllListContext = Context::GetAllListObject();35 for ( HashMap<string, StrHashMap<Context> >::Iterator it = AllListContext.begin(); it != AllListContext.end(); it++)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 36 { Context::SetCurrentContext((*it).first); delete ((*it).second)[(*it).first]; } 37 37 } 38 38 39 // Ne plus utiliser, disponible dans les classe treatment. 39 40 static void ResolveInheritance(void) 40 41 { 41 HashMap<string, StrHashMap<Context> > &AllListContext = Context::GetAllListObject();42 for ( HashMap<string, StrHashMap<Context> >::Iterator it = AllListContext.begin(); it != AllListContext.end(); it++)42 Poco::HashMap<string, StrHashMap<Context> > &AllListContext = Context::GetAllListObject(); 43 for (Poco::HashMap<string, StrHashMap<Context> >::Iterator it = AllListContext.begin(); it != AllListContext.end(); it++) 43 44 { 44 45 // Résolution des héritages descendants (cà d des héritages de groupes) pour chacun des contextes. … … 58 59 59 60 // Changement de context pour les champs et groupes de champs. 60 FieldGroup::SetContext(id); 61 CField::SetContext(id); 61 FieldGroup::SetContext(id); CField::SetContext(id); 62 62 63 63 // Changement de context pour les fichiers et groupes de fichiers. 64 FileGroup::SetContext(id); 65 CFile::SetContext(id); 64 FileGroup::SetContext(id); CFile::SetContext(id); 66 65 67 66 // Changement de context pour les grilles et groupes de grilles. 68 GridGroup::SetContext(id); 69 CGrid::SetContext(id); 67 GridGroup::SetContext(id); CGrid::SetContext(id); 70 68 71 69 // Changement de context pour les axes et groupes d'axes. 72 AxisGroup::SetContext(id); 73 CAxis::SetContext(id); 70 AxisGroup::SetContext(id); CAxis::SetContext(id); 74 71 } 75 72 … … 107 104 { gridDef = CreateInstanceAndParse<GridDefinition >(_node, GridDefinition ::GetDefName().c_str()); continue; } 108 105 109 WARNING("La définition est invalide, seul es les champs, grilles, axes et fichiers peuvent être définis !");106 WARNING("La définition est invalide, seuls les champs, grilles, axes et fichiers peuvent être définis !"); 110 107 111 108 } while (_node.goToNextElement()); … … 115 112 } 116 113 117 static string GetName(void) {return ("context"); }118 static string GetRootName(void) { return ("simulation"); }114 static string GetName(void) { return ("context"); } 115 static string GetRootName(void) { return ("simulation"); } 119 116 120 117 virtual bool hasChild(void) const … … 129 126 } 130 127 131 virtual void resolveDescInheritance(const AttributRegistrar* _parent = 0)128 virtual void resolveDescInheritance(const AttributRegistrar* const _parent = 0) 132 129 { 133 130 if (_parent != 0) return; … … 145 142 146 143 AbstractCalendar * getCalendar(void) const { return (this->ccalendar ); } 147 AbstractCalendar * setCalendar(const string& _calName, const string& dateStr)144 AbstractCalendar * setCalendar(const string& _calName, const string& _dateStr) 148 145 { 149 146 if (_calName.compare("D360") == 0) 150 return (ccalendar = new D360Calendar( dateStr));147 return (ccalendar = new D360Calendar(_dateStr)); 151 148 if (_calName.compare("AllLeap") == 0) 152 return (ccalendar = new AllLeapCalendar( dateStr));149 return (ccalendar = new AllLeapCalendar(_dateStr)); 153 150 if (_calName.compare("NoLeap") == 0) 154 return (ccalendar = new NoLeapCalendar( dateStr));151 return (ccalendar = new NoLeapCalendar(_dateStr)); 155 152 if (_calName.compare("Julian") == 0) 156 return (ccalendar = new JulianCalendar( dateStr));153 return (ccalendar = new JulianCalendar(_dateStr)); 157 154 if (_calName.compare("Gregorian") == 0) 158 return (ccalendar = new GregorianCalendar( dateStr));155 return (ccalendar = new GregorianCalendar(_dateStr)); 159 156 160 157 WARNING("L'identifiant "+_calName+" est inconnu, le calendrier grégorien sera choisi par défault pour le contexte "+getId()); 161 158 162 return (ccalendar = new GregorianCalendar( dateStr));159 return (ccalendar = new GregorianCalendar(_dateStr)); 163 160 } 164 161 … … 166 163 { 167 164 // Désallocation dynamique de mémoire pour chacun des groupes de définition si nécessaire. 168 if(fieldDef != NULL) delete fieldDef; 169 if(fileDef != NULL) delete fileDef; 170 if(axisDef != NULL) delete axisDef; 171 if(gridDef != NULL) delete gridDef; 165 if(fieldDef != NULL) delete fieldDef; if(fileDef != NULL) delete fileDef ; 166 if(axisDef != NULL) delete axisDef ; if(gridDef != NULL) delete gridDef ; 167 172 168 // Désallocation dynamique de mémoire pour le calendrier associé au contexte courant si nécessaire. 173 169 if(ccalendar != NULL) delete ccalendar; -
XMLIO_V2/dev/dev_rv/src/XMLIO/date.hpp
r119 r120 27 27 friend std::ostream& operator<<(std::ostream& out, const Date& d) 28 28 { 29 out << d.day << "/" << d.month << "/" << d.year << "-"30 << d.hour << ":" << d.minute << ":"<< d.second;29 out << d.day << '/' << d.month << '/' << d.year << '-' 30 << d.hour << ':' << d.minute << ':' << d.second; 31 31 return (out); 32 32 } … … 60 60 if (month == 0 ) { year--; month = 12; } 61 61 } 62 62 63 void setYear (int newyear) { year = newyear; } 63 64 -
XMLIO_V2/dev/dev_rv/src/XMLIO/declare_attribut.hpp
r108 r120 3 3 4 4 #include "attribut.hpp" 5 6 #define Array(x,y) Array<x,y> 5 7 6 8 #define DECLARE_ATTR(att_name,att_type) \ -
XMLIO_V2/dev/dev_rv/src/XMLIO/field.hpp
r114 r120 7 7 namespace XMLIOSERVER 8 8 { 9 class CGrid; // CGRID = CDOMAINE + CAXIS 10 9 11 class CField : public ObjectTemplate<CField>, public FieldAttribut 10 12 { 11 13 public: 12 14 13 CField(void) : ObjectTemplate<CField>(), FieldAttribut() 15 CField(void) : ObjectTemplate<CField>(), FieldAttribut(), grid(NULL) 14 16 {/* Ne rien faire de plus */} 15 CField(const string& _id) : ObjectTemplate<CField>(_id), FieldAttribut() 17 CField(const string& _id) : ObjectTemplate<CField>(_id), FieldAttribut(), grid(NULL) 16 18 {/* Ne rien faire de plus */} 17 19 18 20 static string GetName(void) {return ("field"); } 19 21 22 inline void SolveGridRef(void) ; 23 24 CGrid* getGrid(void) const { return (grid); } 25 20 26 virtual CField* getReference(void) const 21 27 { 22 if(!field_ref. _hasValue()) return (NULL);28 if(!field_ref.hasValue()) return (NULL); 23 29 if (!CField::HasObject(field_ref)) 24 30 { WARNING("Référence invalide sur l'objet "+GetName()+" nommé \""+((string)field_ref)+"\""); return (NULL);} 25 31 26 return ( &CField::GetObject(field_ref));32 return (CField::GetObject(field_ref)); 27 33 } 28 34 29 35 virtual ~CField(void) 30 36 { /* Ne rien faire de plus */ } 37 38 private : 39 40 CGrid* grid ; 31 41 32 42 }; // class CField -
XMLIO_V2/dev/dev_rv/src/XMLIO/field_attribut.hpp
r107 r120 19 19 DECLARE_ATTR(enabled, bool); 20 20 21 DECLARE_ATTR(domain_ref, string); 21 22 DECLARE_ATTR(axis_ref, string); 22 DECLARE_ATTR(grid_ref, string) ;23 DECLARE_ATTR(grid_ref, string) ; 23 24 DECLARE_ATTR(zoom_ref, string); 24 25 DECLARE_ATTR(field_ref, string); … … 41 42 RegisterAttribut(&enabled); 42 43 44 RegisterAttribut(&domain_ref); 43 45 RegisterAttribut(&axis_ref); 44 46 RegisterAttribut(&grid_ref); -
XMLIO_V2/dev/dev_rv/src/XMLIO/file.hpp
r114 r120 11 11 public: 12 12 13 CFile(void) : ObjectTemplate<CFile>(), FileAttribut(), vfieldGroup(NULL) 13 CFile(void) : ObjectTemplate<CFile>(), FileAttribut(), vfieldGroup(NULL), enabledFields() 14 14 {/* Ne rien faire de plus */} 15 CFile(const string& _id) : ObjectTemplate<CFile>(_id), FileAttribut(), vfieldGroup(NULL) 15 CFile(const string& _id) : ObjectTemplate<CFile>(_id), FileAttribut(), vfieldGroup(NULL), enabledFields() 16 16 {/* Ne rien faire de plus */} 17 17 … … 37 37 38 38 void getAllFields(std::vector<CField*>& _allF) const { if (vfieldGroup!=NULL) vfieldGroup->getAllChildren(_allF); } 39 39 40 virtual bool hasChild(void) const { return (vfieldGroup != NULL); } 41 40 42 virtual void printChild(ostream& out) const { out << *vfieldGroup << std::endl; } 41 43 /*{ // Sortie sans affichage des groupes. … … 44 46 out << *(allF[i]) << std::endl; 45 47 }*/ 48 46 49 virtual void resolveDescInheritance(const AttributRegistrar* _parent = 0) 47 50 { addAttributes(*_parent); if(vfieldGroup != NULL) vfieldGroup->resolveDescInheritance(); } … … 55 58 FieldGroup* getVirtualFieldGroup(void) { return (vfieldGroup); } 56 59 60 void findEnabledFields(int default_outputlevel = 5, int default_level = 1, bool default_enabled = true ) 61 { 62 const int _outputlevel = (output_level.hasValue()) ? (int)output_level : default_outputlevel; 63 std::vector<CField*>::iterator it; 64 65 getAllFields(enabledFields); 66 67 for ( it = enabledFields.begin() ; it < enabledFields.end(); it++ ) 68 { 69 if ((*it)->enabled.hasValue()) // Si l'attribut 'enabled' est défini ... 70 { 71 if (! ((*it)->enabled)) 72 { enabledFields.erase(it); continue; } 73 } 74 else // Si l'attribut 'enabled' n'est pas défini ... 75 { 76 if (!default_enabled) 77 { enabledFields.erase(it); continue; } 78 } 79 80 if ((*it)->level.hasValue()) // Si l'attribut 'level' est défini ... 81 { 82 if ((*it)->level > _outputlevel) 83 { enabledFields.erase(it); continue; } 84 } 85 else // Si l'attribut 'level' n'est pas défini ... 86 { 87 if (default_level > _outputlevel) 88 { enabledFields.erase(it); continue; } 89 } 90 91 } 92 } 93 57 94 virtual ~CFile(void) 58 95 { if(vfieldGroup != NULL) delete vfieldGroup; } … … 61 98 62 99 FieldGroup* vfieldGroup; // FieldGroup "virtuel" 100 std::vector<CField*> enabledFields; 63 101 64 102 }; // class CFile -
XMLIO_V2/dev/dev_rv/src/XMLIO/grid.hpp
r114 r120 7 7 namespace XMLIOSERVER 8 8 { 9 class CGrid : public ObjectTemplate<CGrid>, public GridAttribut9 class CGrid : public ObjectTemplate<CGrid>, public GridAttribut 10 10 { 11 11 public: 12 12 13 CGrid(void) : ObjectTemplate<CGrid>(), GridAttribut() 14 { /* Ne rien faire de plus */}15 CGrid(const string& _id) : ObjectTemplate<CGrid>(_id), GridAttribut() 16 { /* Ne rien faire de plus */}13 CGrid(void) : ObjectTemplate<CGrid>(), GridAttribut(), hasAxis(false), axis(NULL), domain(NULL) 14 { /* Ne rien faire de plus */ } 15 CGrid(const string& _id) : ObjectTemplate<CGrid>(_id), GridAttribut(), hasAxis(false), axis(NULL), domain(NULL) 16 { /* Ne rien faire de plus */ } 17 17 18 18 static string GetName(void) { return ("grid"); } 19 20 inline void solveReference(void) ; 21 inline void solveDomainRef(void) ; 22 inline void solveAxisRef(void) ; 23 24 inline void computeIndex(void); 25 26 inline void storeField(const Array<double,1>& field, Array<double,1>& stored); 27 inline void storeField(const Array<double,2>& field, Array<double,1>& stored); 28 inline void storeField(const Array<double,3>& field, Array<double,1>& stored); 29 inline void storeField(const double* const data, Array<double,1>& stored); 30 31 inline void outputField(const Array<double,1>& stored, Array<double,2>& outField); 32 inline void outputField(const Array<double,1>& stored, Array<double,3>& outField); 33 34 inline static CGrid* CreateObject(const CDomain* const a_domain, const CAxis* const a_axis); 35 inline static CGrid* CreateObject(const CDomain* const a_domain); 19 36 20 37 virtual ~CGrid(void) 21 38 { /* Ne rien faire de plus */ } 22 39 40 41 private: 42 43 bool hasAxis ; 44 45 CAxis* axis ; 46 CDomain* domain ; 47 48 Array<int,1> storeIndex ; 49 Array<int,1> out_i_index ; 50 Array<int,1> out_j_index ; 51 Array<int,1> out_l_index ; 52 23 53 }; // class CGrid 24 54 55 56 CGrid* CGrid::CreateObject(const CDomain* const a_domain, const CAxis* const a_axis) 57 { 58 string new_id = string("___") + a_domain->getId() + string("_") + a_axis->getId() + string("__") ; 59 CGrid* const grid = ObjectTemplate<CGrid>::CreateObject(new_id) ; 60 61 grid->domain_ref = a_domain->getId() ; 62 grid->axis_ref = a_axis->getId() ; 63 64 return (grid); 65 } 66 67 CGrid* CGrid::CreateObject(const CDomain* const a_domain) 68 { 69 string new_id = string("___") + a_domain->getId() + string("__") ; 70 CGrid* const grid = ObjectTemplate<CGrid>::CreateObject(new_id) ; 71 72 grid->domain_ref = a_domain->getId() ; 73 74 return (grid); 75 } 76 77 void CGrid::solveReference(void) 78 { 79 static bool isReferenceSolved = false; 80 if (isReferenceSolved) return; 81 82 // Résolution de chacune des références et indexation. 83 solveDomainRef() ; 84 solveAxisRef() ; 85 computeIndex() ; 86 87 isReferenceSolved = true ; 88 } 89 90 void CGrid::solveDomainRef(void) 91 { 92 if (domain_ref.hasValue()) 93 { 94 if (CDomain::HasObject(domain_ref)) 95 { 96 domain=CDomain::GetObject(domain_ref) ; 97 domain->check() ; 98 } 99 else ERROR("Référence au domaine incorrecte") ; 100 } 101 else ERROR("Domaine non défini") ; 102 } 103 104 void CGrid::solveAxisRef(void) 105 { 106 if (axis_ref.hasValue()) 107 { 108 hasAxis = true ; 109 if (CAxis::HasObject(axis_ref)) axis = CAxis::GetObject(axis_ref) ; 110 else ERROR("Référence a l'axe incorrecte") ; 111 } 112 else hasAxis = false ; // hasAxis est normalement déjà à false(?). 113 } 114 115 void CGrid::computeIndex(void) 116 { 117 int ni = domain->ni ; 118 int nj = domain->nj ; 119 int size = (hasAxis) ? (int)axis->size : 1 ; 120 int data_dim = domain->data_dim ; 121 int data_n_index = domain->data_n_index ; 122 int data_ibegin = domain->data_ibegin ; 123 int data_jbegin = (data_dim == 2) ? (int)domain->data_jbegin : -1; 124 125 Array<int,1>& data_i_index =* domain->data_i_index ; 126 Array<int,1>& data_j_index =* domain->data_j_index ; 127 Array<bool,2>& mask =* domain->mask ; 128 int i, j, l, n ; 129 int count, indexCount ; 130 131 for(indexCount=0, l=0; l<size ; l++) 132 { 133 for(n=0, indexCount=0; n<data_n_index; n++) 134 { 135 if (data_dim == 1) 136 { 137 i = (data_i_index(n) + data_ibegin) % ni ; 138 j = (data_i_index(n) + data_ibegin) / ni ; 139 cout<<i<<" "<<j<<" "<<mask(i,j)<<endl ; 140 } 141 else 142 { 143 i = data_i_index(n) + data_ibegin ; 144 j = data_j_index(n) + data_jbegin ; 145 cout<<i<<" "<<j<<" "<<mask(i,j)<<endl ; 146 } 147 148 if (i>=0 && i<ni && j>=0 && j<nj && mask(i,j) ) indexCount++ ; 149 } 150 } 151 152 storeIndex.resize(indexCount) ; 153 out_l_index.resize(indexCount) ; 154 out_i_index.resize(indexCount) ; 155 out_j_index.resize(indexCount) ; 156 157 for(count=0, indexCount=0, l=0; l<size; l++) 158 { 159 for(n=0; n<data_n_index; n++) 160 { 161 if (data_dim == 1) 162 { 163 i = (data_i_index(n) + data_ibegin) % ni ; 164 j = (data_i_index(n) + data_ibegin) / ni ; 165 } 166 else 167 { 168 i = data_i_index(n) + data_ibegin ; 169 j = data_j_index(n) + data_jbegin ; 170 } 171 172 if (i>=0 && i<ni && j>=0 && j<nj && mask(i,j)) 173 { 174 storeIndex(indexCount) = n ; 175 out_l_index(indexCount) = l ; 176 out_i_index(indexCount) = i ; 177 out_j_index(indexCount) = j ; 178 indexCount++ ; 179 } 180 count++ ; 181 } 182 } 183 184 cout << "Out of CGrid::ComputeIndex" << endl ; 185 cout << storeIndex << endl ; 186 cout << out_i_index << endl ; 187 cout << out_j_index << endl ; 188 cout << out_l_index << endl ; 189 } 190 191 void CGrid::storeField(const Array<double, 1>& field, Array<double, 1>& stored) 192 { 193 storeField(field.dataFirst(), stored) ; 194 //cout<<"Stored 1"<<stored<<endl ; 195 } 196 197 void CGrid::storeField(const Array<double, 2>& field, Array<double, 1>& stored) 198 { 199 storeField(field.dataFirst(), stored) ; 200 //cout<<"Stored 2"<<stored<<endl ; 201 } 202 203 void CGrid::storeField(const Array<double, 3>& field, Array<double, 1>& stored) 204 { 205 storeField(field.dataFirst(), stored) ; 206 //cout<<"Stored 3"<<stored<<endl ; 207 } 208 209 void CGrid::storeField(const double* const data, Array<double, 1>& stored) 210 { 211 int size = storeIndex.size() ; 212 //cout << "size " << size << endl ; 213 214 stored.resize(shape(size)) ; 215 //cout << "Stored " << stored << endl ; 216 217 for(int i = 0; i < size; i++) stored(i) = data[storeIndex(i)] ; 218 //cout << "Stored " << stored << endl ; 219 } 220 221 void CGrid::outputField(const Array<double, 1>& stored, Array<double, 2>& outField) 222 { 223 for(int n = 0; n < storeIndex.size(); n++) 224 outField(out_i_index(n), out_j_index(n)) = stored(n) ; 225 } 226 227 void CGrid::outputField(const Array<double, 1>& stored, Array<double, 3>& outField) 228 { 229 for(int n = 0; n < storeIndex.size(); n++) 230 outField(out_i_index(n), out_j_index(n), out_l_index(n)) = stored(n) ; 231 } 25 232 } // namespace XMLIOSERVER 26 233 234 27 235 DECLARE_GROUP(Grid) 28 236 237 238 29 239 #endif // __GRID__ 30 240 -
XMLIO_V2/dev/dev_rv/src/XMLIO/grid_attribut.hpp
r110 r120 10 10 DECLARE_ATTR(name, string) ; 11 11 DECLARE_ATTR(description, string) ; 12 DECLARE_ATTR(domain_ref, string) ; 13 DECLARE_ATTR(axis_ref, string) ; 12 14 13 15 GridAttribut(void) : AttributRegistrar() … … 20 22 RegisterAttribut(&name) ; 21 23 RegisterAttribut(&description) ; 24 RegisterAttribut(&domain_ref) ; 25 RegisterAttribut(&axis_ref) ; 22 26 } 23 27 -
XMLIO_V2/dev/dev_rv/src/XMLIO/group_template.hpp
r115 r120 41 41 // on complÚte les attributs des enfants. 42 42 childvect[i] -> resolveDescInheritance(this); 43 43 44 for(unsigned int i = 0; i < groupvect.size() ; i++) 44 45 // on complÚte les attributs des groupes enfants. … … 48 49 GroupTemplate<T, U>& createGroup(const string& _id) throw (XMLIOUndefinedValueException) 49 50 { 50 GroupTemplate<T, U> &obj = GroupTemplate<T, U>::CreateObject(_id);51 GroupTemplate<T, U> &obj = *GroupTemplate<T, U>::CreateObject(_id); 51 52 groupList.addObject(&obj); 52 53 … … 56 57 GroupTemplate<T, U>& createGroup(void) 57 58 { 58 GroupTemplate<T, U>& obj = GroupTemplate<T, U>::CreateObject();59 GroupTemplate<T, U>& obj = *(GroupTemplate<T, U>::CreateObject()); 59 60 groupList.addObject(&obj); 60 61 … … 73 74 T& createChild(const string& _id) throw (XMLIOUndefinedValueException) 74 75 { 75 T& obj = ObjectTemplate<T>::CreateObject(_id);76 T& obj = *ObjectTemplate<T>::CreateObject(_id); 76 77 childList.addObject(&obj); 77 78 return (obj); … … 80 81 T& createChild(void) 81 82 { 82 T& obj = ObjectTemplate<T>::CreateObject();83 T& obj = *ObjectTemplate<T>::CreateObject(); 83 84 childList.addObject(&obj); 84 85 return (obj); -
XMLIO_V2/dev/dev_rv/src/XMLIO/logger.hpp
r115 r120 48 48 } 49 49 50 51 50 static void ShowBTrace(std::ostream& out = std::clog) 52 51 { … … 94 93 95 94 // Initialisation de la classe de Logging 96 staticILogger LOGGER;95 ILogger LOGGER; 97 96 98 97 ///////////////////////////////////////////////////////////////////// 99 staticunsigned int Indent = 0;100 staticconst char* Increm = " ";98 unsigned int Indent = 0; 99 const char* Increm = " "; 101 100 102 101 std::ostream& NIndent(std::ostream& out) -
XMLIO_V2/dev/dev_rv/src/XMLIO/object_template.hpp
r115 r120 27 27 28 28 if (c.baseObject != NULL) 29 out << IncIndent << "<-- Reference resolved for the following "+ T::GetName() +" : \"" << c.baseObject->getId() << "\" -->" << DecEndl << std::endl; 29 out << IncIndent << "<-- Reference resolved for the following "+ T::GetName() + 30 " : \"" << c.baseObject->getId() << "\" -->" << DecEndl << std::endl; 30 31 31 32 if (c.hasChild()) … … 48 49 49 50 virtual void resolveDescInheritance(const AttributRegistrar* _parent = 0) { addAttributes(*_parent); } 50 virtual void resolveRefInheritance (void)51 virtual void resolveRefInheritance (void) 51 52 { 52 53 std::set<T*> sset; … … 76 77 } 77 78 78 static T &CreateObject(const string& _id) throw (XMLIOUndefinedValueException)79 static T* CreateObject(const string& _id) throw (XMLIOUndefinedValueException) 79 80 { 80 81 // Si l'identifiant est répertorié, on retourne l'élément existant. … … 88 89 } 89 90 90 static T &CreateObject(void)91 static T* CreateObject(void) 91 92 { 92 93 T* value = new T; 93 94 ObjectTemplate<T>::AllListObj[CurrContext].addObject(value); 94 return ( *value);95 return (value); 95 96 } 96 97 97 static T &GetObject(const string& _id) throw (XMLIOUndefinedValueException)98 { return ( *ObjectTemplate<T>::AllListObj[CurrContext][_id]); }98 static T* GetObject(const string& _id) throw (XMLIOUndefinedValueException) 99 { return (ObjectTemplate<T>::AllListObj[CurrContext][_id]); } 99 100 100 101 static bool HasObject(const string& _id) … … 105 106 106 107 static const StrHashMap<T>& GetCurrentListObject(void) { return (AllListObj[CurrContext]); } 107 static HashMap<string, StrHashMap<T> >& GetAllListObject(void) { return (AllListObj); }108 static Poco::HashMap<string, StrHashMap<T> >& GetAllListObject(void) { return (AllListObj); } 108 109 109 110 static void SetContext(const string& id){ ObjectTemplate<T>::CurrContext = id; } … … 134 135 if (V::HasObject(did)) 135 136 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!"); 136 instance_ptr = (V*) &V::CreateObject(did);137 instance_ptr = (V*)V::CreateObject(did); 137 138 instance_ptr->parse(_node, parseAttr); 138 139 } … … 144 145 145 146 static string CurrContext; 146 static HashMap<string, StrHashMap<T> > AllListObj;147 static Poco::HashMap<string, StrHashMap<T> > AllListObj; 147 148 148 149 };// class ObjectTemplate 149 150 150 151 template <class T> string ObjectTemplate<T>::CurrContext ; 151 template <class T> HashMap<string, StrHashMap<T> > ObjectTemplate<T>::AllListObj;152 template <class T> Poco::HashMap<string, StrHashMap<T> > ObjectTemplate<T>::AllListObj; 152 153 153 154 }// namespace XMLIOSERVER -
XMLIO_V2/dev/dev_rv/src/XMLIO/xml_node.hpp
r117 r120 2 2 #define __XMLIO_XML_NODE__ 3 3 4 // Entêtes Poco DOM5 #include <Poco/DOM/DOMParser.h>6 #include <Poco/DOM/Document.h>7 #include <Poco/DOM/Element.h>8 9 #include <Poco/DOM/NamedNodeMap.h>10 11 #include <Poco/DOM/AutoPtr.h>12 13 // Entêtes Poco SAX.14 #include <Poco/SAX/InputSource.h>15 16 // Utilisation de la STL.17 using std::string;18 19 using std::pair;20 using std::vector;21 22 using std::istream;23 using std::ostream;24 using std::ostringstream;25 using std::ifstream;26 27 // Utilisation de la biliothÚque POCO.28 using Poco::XML::DOMParser;29 using Poco::XML::InputSource;30 31 using Poco::XML::Document;32 using Poco::XML::Node;33 using Poco::XML::Element;34 35 using Poco::XML::NamedNodeMap;36 37 using Poco::HashMap;38 39 using Poco::XML::AutoPtr;40 4 41 5 namespace XMLIOSERVER … … 43 7 namespace XML 44 8 { 45 46 typedef HashMap<string, string> THashAttributes; 9 typedef Poco::HashMap<std::string, std::string> THashAttributes; 47 10 48 11 class XMLNode … … 50 13 public : 51 14 52 XMLNode(const string& _rootName) : rootName(_rootName) 53 { /* Ne rien faire de plus */} 54 55 static XMLNode CreateNode(istream& _istr, const string& _rootName) 15 static XMLNode CreateNode(std::istream& _istr, const std::string& _rootName) 56 16 { 57 17 XMLNode node(_rootName); 18 58 19 if (_istr.good()) 59 20 { // S'il est possible de lire le flux en entrée ... 60 InputSource src(_istr); 61 DOMParser parser; 21 22 Poco::XML::InputSource src(_istr); 23 Poco::XML::DOMParser parser; 62 24 63 25 node.pDoc = parser.parse(&src); 64 26 node.setCNode(node.pDoc->documentElement()); 65 if (node.getElementName().compare(_rootName) != 0) 27 if (node.getElementName().compare(_rootName) != 0) // << A passer en avertissement. 66 28 throw XMLParsingException("L'élément racine doit avoir pour valeur <" + _rootName + "> (\"" + node.getElementName() + "\" lue)"); 67 29 } … … 73 35 74 36 string getElementName(void) const 75 { string _str(this->getCNode()->nodeName()); return (_toLower(_str)); } 37 { 38 std::string _str(this->getCNode()->nodeName()); 39 return (_toLower(_str)); 40 } 76 41 77 42 bool goToNextElement(void) 78 43 { 79 Node* nextElement = this->getCNode()->nextSibling();44 Poco::XML::Node* nextElement = this->getCNode()->nextSibling(); 80 45 81 46 // On parcourt la liste des "siblings" jusqu'à trouver un élément quelconque. … … 92 57 bool goToChildElement(void) 93 58 { 94 Node* nextElement = this->getCNode()->firstChild();59 Poco::XML::Node* nextElement = this->getCNode()->firstChild(); 95 60 96 61 // On parcourt la liste des enfants jusqu'à trouver un élément quelconque. … … 98 63 { 99 64 for(; ; nextElement = nextElement->nextSibling()) 100 if (IsPtrNull(nextElement)) break;65 if (IsPtrNull(nextElement)) return (false); 101 66 else if (nextElement->nodeType() == 1) 102 67 {// Si l'un des noeuds est un élément... … … 104 69 return (true); 105 70 } 106 return (false);107 71 } 108 109 72 return (false); 110 73 } … … 118 81 } 119 82 120 bool getAttributes(THashAttributes& attributes) const83 bool getAttributes(THashAttributes& _attributes) const 121 84 { 122 85 if(!this->getCNode()->hasAttributes()) return (false); 123 AutoPtr<NamedNodeMap> map = this->getCNode()->attributes();86 Poco::XML::AutoPtr<Poco::XML::NamedNodeMap> map = this->getCNode()->attributes(); 124 87 125 88 for(unsigned int i = 0; i< map->length(); i++) 126 89 { // Suppression des espaces en début et fin de valeur d'attribut xml. 127 st ring _str(map->item(i)->nodeName());90 std::string _str(map->item(i)->nodeName()); 128 91 size_t d = map->item(i)->nodeValue().find_first_not_of(' '); 129 92 size_t f = map->item(i)->nodeValue().find_last_not_of (' '); 130 attributes[_toLower(_str)] = map->item(i)->nodeValue().substr(d,f-d+1); 93 94 _attributes[_toLower(_str)] = map->item(i)->nodeValue().substr(d,f-d+1); 131 95 } 132 96 return (true); … … 138 102 protected : 139 103 140 Node* getCNode(void) const { return (this->cNode); }141 void setCNode( Node* other) { this->cNode = other; }104 Poco::XML::Node * getCNode(void) const { return (this->cNode); } 105 void setCNode(Poco::XML::Node * _otherNode) { this->cNode = _otherNode; } 142 106 143 static bool IsPtrNull( Node* ptr) { return (ptr==NULL); }107 static bool IsPtrNull(const Poco::XML::Node * const _ptr) { return (_ptr == NULL); } 144 108 145 109 private : 146 110 147 const string& _toLower(string& _str) const 111 XMLNode(const std::string& _rootName) : rootName(_rootName) 112 { /* Ne rien faire de plus */} 113 114 const string& _toLower(std::string& _str) const 148 115 { 149 116 for (unsigned int i = 0; i < _str.size(); i++) … … 152 119 } 153 120 154 AutoPtr<Document> pDoc;155 Node* cNode;121 Poco::XML::AutoPtr<Poco::XML::Document> pDoc; 122 Poco::XML::Node* cNode; 156 123 157 124 string rootName; -
XMLIO_V2/dev/dev_rv/src/XMLIO/xml_parser.hpp
r114 r120 35 35 36 36 Context::SetCurrentContext(attributes["id"]); 37 Context& context = Context::CreateObject(attributes["id"]);37 Context& context = *Context::CreateObject(attributes["id"]); 38 38 39 39 context.parse(_node); -
XMLIO_V2/dev/dev_rv/src/XMLIO/xmlio.hpp
r118 r120 17 17 #include <Poco/HashMap.h> 18 18 #include <Poco/Hash.h> 19 20 // Entêtes Poco DOM 21 #include <Poco/DOM/DOMParser.h> 22 #include <Poco/DOM/Document.h> 23 #include <Poco/DOM/Element.h> 24 25 #include <Poco/DOM/NamedNodeMap.h> 26 27 #include <Poco/DOM/AutoPtr.h> 28 29 // Entêtes Poco SAX. 30 #include <Poco/SAX/InputSource.h> 19 31 20 32 /// Entête Blitz array /// … … 40 52 #include "grid_attribut.hpp" 41 53 #include "axis_attribut.hpp" 54 #include "domain_attribut.hpp" 42 55 #include "field_attribut.hpp" 43 56 #include "file_attribut.hpp" … … 46 59 #include "declare_group.hpp" 47 60 48 // Prise en charge des champs ...61 // Prise en charge des champs, fichiers, axes, domaines, grilles ... 49 62 #include "field.hpp" 50 // Prise en charge des fichiers ...51 63 #include "file.hpp" 52 // Prise en charge des axes ...53 64 #include "axis.hpp" 54 // Prise en charge des grilles ... 65 #include "domain.hpp" 55 66 #include "grid.hpp" 67 68 #include "field_gridrefsolver.hpp" 56 69 57 70 #include "context.hpp" 58 71 #include "xml_parser.hpp" 59 72 73 #include "abstract_data_treatment.hpp" 74 #include "NetCDF4_data_treatment.hpp" 75 60 76 #endif // __XMLIO__
Note: See TracChangeset
for help on using the changeset viewer.