Changeset 104


Ignore:
Timestamp:
06/07/10 18:34:17 (14 years ago)
Author:
hozdoba
Message:

Prise en charge de l'héritage descendant.
Travail sur les flux de sortie.
Correction de divers problÚmes.
Ajout d'une macro à BaseAttribut?.

Location:
XMLIO_V2/dev/dev_rv/src/XMLIO
Files:
17 edited

Legend:

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

    r98 r104  
    3838         bool hasValue ; 
    3939         Ctype value ; 
     40          
     41         virtual bool _hasValue() {return hasValue;} 
    4042 
    4143         virtual const char * getName(void) const = 0 ; 
     
    7476            return value ; 
    7577         } 
     78          
     79         virtual void assignValue(const BaseAttribut* _ba) 
     80         { value = ((Attribut*)_ba) -> value; hasValue = true; } 
    7681 
    7782         virtual ostream& print(ostream & o) const 
    78          { 
    79             o<<"Attribut : "<<getName()<<"  ---->" ; 
    80             if (hasValue) o<< boolalpha <<" value = "<< value ; 
    81             else o<< "/" ; 
    82             return o ; 
    83          } 
     83         { if (hasValue) o << " " << getName() << "=\"" << boolalpha << value << "\"" ; return o ; } 
    8484 
    8585         virtual void setValue(const Ctype & value_) 
    8686         { hasValue=true ; value=value_ ; } 
    87  
     87          
    8888         virtual void getValue(Ctype & value_) const 
    8989         { 
  • XMLIO_V2/dev/dev_rv/src/XMLIO/attribut_registrar.hpp

    r98 r104  
    3333            }          
    3434         } 
    35           
    36          friend ostream& operator<< (ostream& out, const AttributRegistrar& c)  
    37          { out << c.toString(); return (out);}    
    38                 
    39       protected : 
    40        
    41          string toString(void) const 
    42          { 
    43             ostringstream st("A réimplémenter"); 
    44             // A compléter 
    45             return (st.str()); 
    46          } 
    47           
     35                         
    4836      public : 
    4937          
     
    5139        {/* Ne rien faire de plus */} 
    5240         
    53       private : 
     41      protected : 
    5442         StrHashMap<BaseAttribut> attrList; 
    5543         
  • XMLIO_V2/dev/dev_rv/src/XMLIO/base_attribut.hpp

    r98 r104  
    66 
    77 
    8 using XMLIOSERVER::XMLIOIncompatibeTypeException; 
     8using XMLIOSERVER::XMLIOIncompatibleTypeException; 
    99 
    1010namespace XMLIOSERVER 
     
    1212   class BaseAttribut 
    1313   { 
    14      public: 
     14      public: 
    1515      
    16      virtual const char * getName(void) const = 0  ; 
    17          
    18      virtual ostream & print(ostream& o) const = 0  ; 
     16         virtual const char * getName(void) const = 0  ;         
     17         virtual ostream & print(ostream& o) const = 0  ; 
    1918      
    20      friend ostream& operator <<(ostream& o,const BaseAttribut& Attr) 
    21      {return Attr.print(o) ; } 
     19         friend ostream& operator <<(ostream& o,const BaseAttribut& Attr) 
     20         {return Attr.print(o) ; } 
     21          
     22         virtual void assignValue(const BaseAttribut*) = 0; 
    2223      
    23      virtual const char * getId(void) {return getName();} ; 
    24      bool hasId(void){return (true);} 
     24         virtual const char * getId(void) {return getName();} ; 
     25         bool hasId(void){return (true);} 
    2526 
    26      virtual void setFromString(const std::string str) = 0; 
     27         virtual void setFromString(const std::string str) = 0; 
     28      
     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 getValue(TYPE & value)         const  { error_get() ; }\ 
     35         virtual void getValue(Array<TYPE,1>& value) const  { error_get() ; }\ 
     36         virtual void getValue(Array<TYPE,2>& value) const  { error_get() ; }\ 
     37         virtual void getValue(Array<TYPE,3>& value) const  { error_get() ; } 
     38          
     39         SETTER_AND_GETTER(int) 
     40         SETTER_AND_GETTER(bool) 
     41         SETTER_AND_GETTER(double) 
     42         SETTER_AND_GETTER(char) 
     43         SETTER_AND_GETTER(string) 
    2744       
    28      virtual void setValue(const int & value)          { error_set() ; } 
    29      virtual void setValue(const Array<int,1>& value)  { error_set() ; } 
    30      virtual void setValue(const Array<int,2>& value)  { error_set() ; } 
    31      virtual void setValue(const Array<int,3>& value)  { error_set() ; } 
     45#undef SETTER_AND_GETTER 
     46 
     47          
     48         virtual bool _hasValue() = 0; 
     49 
     50         static void error_set(void) 
     51         { throw XMLIOIncompatibleTypeException("BaseAttribut::set<type> > Setting value type is incompatible with attribut type"); } 
     52 
     53         static void error_get(void) 
     54         { throw XMLIOIncompatibleTypeException("BaseAttribut::set<type> >Getting value type is incompatible with attribut type"); } 
    3255      
    33      virtual void setValue(const double & value)          { error_set() ; } 
    34      virtual void setValue(const Array<double,1>& value)  { error_set() ; } 
    35      virtual void setValue(const Array<double,2>& value)  { error_set() ; } 
    36      virtual void setValue(const Array<double,3>& value)  { error_set() ; } 
    37       
    38      virtual void setValue(const bool & value)          { error_set() ; } 
    39      virtual void setValue(const Array<bool,1>& value)  { error_set() ; } 
    40      virtual void setValue(const Array<bool,2>& value)  { error_set() ; } 
    41      virtual void setValue(const Array<bool,3>& value)  { error_set() ; } 
    42       
    43      virtual void setValue(const char * value)            { error_set() ; } 
    44      virtual void setValue(const string & value)          { error_set() ; } 
    45      virtual void setValue(const Array<string,1>& value)  { error_set() ; } 
    46      virtual void setValue(const Array<string,2>& value)  { error_set() ; } 
    47      virtual void setValue(const Array<string,3>& value)  { error_set() ; } 
    48       
    49      virtual void setValue(const char & value)          { error_set() ; } 
    50      virtual void setValue(const Array<char,1>& value)  { error_set() ; } 
    51      virtual void setValue(const Array<char,2>& value)  { error_set() ; } 
    52      virtual void setValue(const Array<char,3>& value)  { error_set() ; } 
    53  
    54  
    55      virtual void getValue(int & value) const        { error_get() ; } 
    56      virtual void getValue(Array<int,1>& value) const  { error_get() ; } 
    57      virtual void getValue(Array<int,2>& value) const  { error_get() ; } 
    58      virtual void getValue(Array<int,3>& value) const  { error_get() ; } 
    59       
    60      virtual void getValue(double & value) const          { error_get() ; } 
    61      virtual void getValue(Array<double,1>& value) const  { error_get() ; } 
    62      virtual void getValue(Array<double,2>& value) const  { error_get() ; } 
    63      virtual void getValue(Array<double,3>& value) const  { error_get() ; } 
    64       
    65      virtual void getValue(bool & value) const          { error_get() ; } 
    66      virtual void getValue(Array<bool,1>& value) const  { error_get() ; } 
    67      virtual void getValue(Array<bool,2>& value) const  { error_get() ; } 
    68      virtual void getValue(Array<bool,3>& value) const  { error_get() ; } 
    69       
    70      virtual void getValue(char * value) const            { error_get() ; } 
    71      virtual void getValue(string & value) const          { error_get() ; } 
    72      virtual void getValue(Array<string,1>& value) const  { error_get() ; } 
    73      virtual void getValue(Array<string,2>& value) const  { error_get() ; } 
    74      virtual void getValue(Array<string,3>& value) const  { error_get() ; } 
    75       
    76      virtual void getValue(char & value) const          { error_get() ; } 
    77      virtual void getValue(Array<char,1>& value) const  { error_get() ; } 
    78      virtual void getValue(Array<char,2>& value) const  { error_get() ; } 
    79      virtual void getValue(Array<char,3>& value) const  { error_get() ; } 
    80  
    81      static void error_set(void) 
    82      { 
    83         throw XMLIOIncompatibeTypeException("BaseAttribut::set<type> > Setting value type is incompatible with attribut type"); 
    84      } 
    85  
    86      static void error_get(void) 
    87      { 
    88         throw XMLIOIncompatibeTypeException("BaseAttribut::set<type> >Getting value type is incompatible with attribut type"); 
    89      } 
    9056   }; //class BaseAttribut 
    9157} // namespace XMLIOSERVER 
  • XMLIO_V2/dev/dev_rv/src/XMLIO/context.hpp

    r98 r104  
    99      public: 
    1010             
    11          Context(void) : ObjectTemplate<Context>() 
     11         Context(void) : ObjectTemplate<Context>(), fieldDef(NULL) 
    1212         {/* Ne rien faire de plus */}                
    13          Context(const string& _id) : ObjectTemplate<Context>(_id) 
     13         Context(const string& _id) : ObjectTemplate<Context>(_id), fieldDef(NULL) 
    1414         {/* Ne rien faire de plus */} 
    1515          
     
    2020            FieldGroup::SetContext(id); 
    2121            Field::SetContext(id); 
     22         } 
     23          
     24         friend ostream& operator<< (ostream& out, const Context& c)  
     25         {  
     26            out << "<" << c.getName()<< " id=\"" <<  c.getId() << "\">"; 
     27            if(c.fieldDef != NULL) out << std::endl << *(FieldGroup*)c.fieldDef << std::endl; 
     28            out << "</" << c.getName()<< ">"; 
     29            return (out); 
     30         }  
     31          
     32         void resolveDescInheritance(void) 
     33         { 
     34            // Résolution des héritages descendants pour chacun des groupes de définitions. 
     35            fieldDef->resolveDescInheritance(); 
    2236         } 
    2337          
     
    8094         } 
    8195          
    82          virtual const char* getName(void) const {return ("Context"); } 
     96         const char* getName(void) const {return ("Context"); } 
    8397          
    8498         FieldDefinition* getFieldDefinition(void) { return (this->fieldDef); } 
    8599                   
    86100         ~Context() 
    87          { delete fieldDef; } 
    88           
    89       protected: 
     101         { delete fieldDef; }       
     102 
    90103       
    91104      private: 
  • XMLIO_V2/dev/dev_rv/src/XMLIO/field.hpp

    r98 r104  
    1010   { 
    1111      public: 
     12       
    1213         Field(void) : ObjectTemplate<Field>(), FieldAttribut() 
    1314                        {/* Ne rien faire de plus */}                    
     
    1516         {/* Ne rien faire de plus */}   
    1617          
    17          void setAttributes(const THashAttributes& attr) 
     18         friend ostream& operator<< (ostream& out, const Field& c)  
    1819         { 
    19             for (THashAttributes::ConstIterator it = attr.begin(); it != attr.end(); it++) 
    20                if ((*it).first.compare(string("id"))) // Non prise en compte de l'identifiant lors de l'affectation des attributs. 
    21                   this->setSAttribut((*it).first, (*it).second); 
    22              
    23             return; 
     20            out << "<" << c.getName(); 
     21            if(c.hasId()) out << " id=\"" <<  c.getId() << "\""; 
     22            for(unsigned int i = 0; i < c.attrList.getVectorSize(); i++) out << *c.attrList.getVector()[i]; 
     23            out << "/>"; 
     24                            
     25            return (out); 
    2426         } 
    2527          
    26          virtual const char* getName(void) const {return ("Field"); }    
     28         void setAttributes(const THashAttributes& _attr) 
     29         { 
     30            for (THashAttributes::ConstIterator it = _attr.begin(); it != _attr.end(); it++) 
     31               if ((*it).first.compare(string("id"))) 
     32               // Non prise en compte de l'identifiant lors de l'affectation des attributs. 
     33                  this->setSAttribut((*it).first, (*it).second); 
     34         } 
     35          
     36         void addAttributes(const StrHashMap<BaseAttribut>& _pattr) 
     37         { 
     38            StrHashMap<BaseAttribut>& _lattr = getAttributList(); 
     39             
     40            //_pattr contient les attributs du parent, _lattr les attributs locaux. 
     41             
     42            for(unsigned int i = 0; i < _lattr.getVectorSize(); i++) 
     43            { 
     44               if(_lattr.getVector()[i]->_hasValue() or !_pattr.getVector()[i]->_hasValue()) continue; 
     45               _lattr.getVector()[i]->assignValue(_pattr.getVector()[i]); 
     46            } 
     47         } 
     48          
     49         const char* getName(void) const {return ("Field"); }    
    2750 
    2851                        void parse (XMLNode& _node) 
  • XMLIO_V2/dev/dev_rv/src/XMLIO/field_attribut.hpp

    r98 r104  
    1919         DECLARE_ATTR(level, int) ; 
    2020         DECLARE_ATTR(prec, int) ; 
    21           
    22          DECLARE_ATTR(src, string) ; // TEMPORAIRE, pour fieldgroup uniquement 
    23        
     21               
    2422         DECLARE_ATTR(enabled, bool); 
    2523       
     
    2927         DECLARE_ATTR(field_ref, string); 
    3028       
    31          FieldAttribut(void) 
     29         FieldAttribut(void) : AttributRegistrar() 
    3230         { registerAllAttributes(); } 
    3331                          
     32      private : 
     33       
    3434         void registerAllAttributes(void) 
    3535         { 
     
    3838            RegisterAttribut(&unit) ; 
    3939            RegisterAttribut(&operation); 
    40              
    41             RegisterAttribut(&src);// TEMPORAIRE, pour fieldgroup uniquement 
    4240       
    4341            RegisterAttribut(&freq_op) ; 
  • XMLIO_V2/dev/dev_rv/src/XMLIO/field_group.hpp

    r98 r104  
    1616         {/* Ne rien faire de plus */} 
    1717          
    18          void setAttributes(const THashAttributes& attr) 
     18         void setAttributes(const THashAttributes& _attr) 
    1919         { 
    20             for (THashAttributes::ConstIterator it = attr.begin(); it != attr.end(); it++) 
    21                if ((*it).first.compare(string("id"))) // Non prise en compte de l'identifiant lors de l'affectation des attributs. 
     20            for (THashAttributes::ConstIterator it = _attr.begin(); it != _attr.end(); it++) 
     21               if ((*it).first.compare(string("id"))!= 0 and (*it).first.compare(string("src"))!=0) 
     22               // (Au dessus) Non prise en compte de l'identifiant et de l'inclusion de fichiers externes lors de l'affectation des attributs. 
    2223                  this->setSAttribut((*it).first, (*it).second); 
    2324             
     
    2526         } 
    2627                  
    27          virtual const char* getName(void) const {return ("FieldGroup"); }   
     28         const char* getName(void) const {return ("FieldGroup"); }   
     29          
     30         friend ostream& operator<< (ostream& out, const FieldGroup& c)  
     31         {             
     32            out << "<" << c.getName(); 
     33            if(c.hasId()) out << " id=\"" <<  c.getId() << "\""; 
     34            for(unsigned int i = 0; i < c.attrList.getVectorSize(); i++) out << *c.attrList.getVector()[i]; 
     35            out << ">" << std::endl; 
     36             
     37            for(unsigned int i = 0; i < c.groupList.getVector().size() ; i++) 
     38               out << *((FieldGroup*)c.groupList.getVector()[i])  << std::endl; 
     39                
     40            for(unsigned int i = 0; i < c.childList.getVector().size() ; i++) 
     41               out << *(c.childList.getVector()[i]) << std::endl; 
     42                
     43            out << "</" << c.getName()<< ">"; 
     44            return (out); 
     45         }  
     46                           
     47         void addAttributes(const StrHashMap<BaseAttribut>& _pattr) 
     48         {           
     49            StrHashMap<BaseAttribut>& _lattr = getAttributList(); 
     50             
     51            //_pattr contient les attributs du parent, _lattr les attributs locaux. 
     52             
     53            for(unsigned int i = 0; i < _lattr.getVectorSize(); i++) 
     54            { 
     55               if(_lattr.getVector()[i]->_hasValue() or !_pattr.getVector()[i]->_hasValue()) continue; 
     56               _lattr.getVector()[i]->assignValue(_pattr.getVector()[i]); 
     57            } 
     58         } 
     59          
     60         void resolveDescInheritance(StrHashMap<BaseAttribut>* _pattr = 0) 
     61         { 
     62            const vector<Field*>&  childvect = childList.getVector(); 
     63            const vector<GroupTemplate<Field, FieldAttribut>*>& groupvect = groupList.getVector(); 
     64             
     65            // On complÚte les propres attributs du groupe. 
     66            if (_pattr!= NULL) addAttributes(*_pattr); 
     67             
     68            for(unsigned int i = 0; i < childvect.size() ; i++) 
     69            // on complÚte les attributs des champs enfants 
     70               childvect[i] -> addAttributes(this->attrList); 
     71                
     72            for(unsigned int i = 0; i < groupvect.size() ; i++) 
     73            // on complÚte les attributs des groupes de champs enfants 
     74               ((FieldGroup*)groupvect[i]) -> resolveDescInheritance(&this->attrList); 
     75         } 
    2876          
    2977         void parse (XMLNode& _node) 
     
    3179            string name = _node.getElementName();             
    3280            THashAttributes attributes; 
    33              
     81 
    3482            /// PARSING GESTION DES ATTRIBUTS /// 
    3583            _node.getAttributes(attributes);   
    3684            this->setAttributes(attributes); 
     85             
     86            if (attributes.end() != attributes.find("src")) 
     87            { // Si une demande d'inclusion de fichier est trouvé. 
     88               XMLNode _node_inc = getNodeIncludedFile(attributes["src"], name); 
     89               parse (_node_inc); 
     90            } 
     91             
    3792            attributes.clear(); 
    3893                
     
    58113                        if (FieldGroup::HasObject(attributes["id"])) 
    59114                           WARNING("Dans le context actuel, un groupe de champ du même nom existe déjà, le second fera référence au premier par défaut !"); // TODO TODO 
    60                         fgroup =(FieldGroup*)&createGroup(attributes["id"]); 
     115                        fgroup = (FieldGroup*)(&createGroup(attributes["id"])); 
    61116                        fgroup->parse(_node); 
    62117                     } 
    63118                     else 
    64119                     {// Si l'identifiant n'est pas défini. 
    65                         fgroup = (FieldGroup*)&createGroup(); 
     120                        fgroup = (FieldGroup*)(&createGroup()); 
    66121                        fgroup->parse(_node); 
    67122                     } 
     
    79134                        if (Field::HasObject(attributes["id"])) 
    80135                           WARNING("Dans le context actuel, un champ du même nom existe déjà, le second fera référence au premier par défaut !");  // TODO TODO 
    81                         field =(Field*)&createChild(attributes["id"]); 
     136                        field = (Field*)(&createChild(attributes["id"])); 
    82137                        field->parse(_node); 
    83138                     } 
    84139                     else 
    85140                     {// Si l'identifiant n'est pas défini. 
    86                         field = (Field*)&createChild(); 
     141                        field = (Field*)(&createChild()); 
    87142                        field->parse(_node); 
    88143                     }          
     
    102157          
    103158         virtual ~FieldGroup(void)  
    104          {/* Ne rien faire de plus */}    
    105           
     159         {/* Ne rien faire de plus */ } 
     160                  
    106161   }; // class FieldGroup 
    107162      
  • XMLIO_V2/dev/dev_rv/src/XMLIO/main.cpp

    r98 r104  
     1 
     2// g++ -Wall -std=c++0x -g  -o ../../bin/XMLIOServer -I/local/tools/svn/external/include/ -L/local/tools/svn/external/lib main.cpp main_cpp.cpp -lPOCO_XML -lPOCO_Foundation -lpthread 
    13 
    24extern "C" void main_c_(void) ; 
  • XMLIO_V2/dev/dev_rv/src/XMLIO/main_cpp.cpp

    r98 r104  
    1111        try 
    1212        { 
    13                 XMLParser::CLASS_TEST();             
    14                 // Code à executer ici 
     13      string file("/local/testsuite/iodef_test.xml"); 
     14      ifstream istr( file.c_str() , ifstream::in ); 
     15       
     16      // On commence la lecture du flux de donnée xml qui doit posséder pour racine un unique noeud nommé "simulation". 
     17      XMLNode node = XMLNode::CreateNode(istr, "simulation"); 
     18      // On parse le fichier xml noeud par noeud (ie on construit dynamiquement notre arbre d'objets). 
     19      XMLParser::Parse(node);  
     20      // On résoud les héritages descendants ainsi que les héritages par référence. 
     21      XMLParser::ResolveInheritance(); 
     22       
     23      // On poursuit le traitement ... 
     24       
     25      // On écrit l'arborescence resultante du traitement sur la sortie. 
     26      XMLParser::ShowTree(std::clog); 
     27       
     28      /*std::clog << "Nombre de Contexts listés : " << Context::GetCurrentListObject().getSize() << " contre 1 attendus."<< std::endl; 
     29      std::clog << "Nombre de FieldGroups listés : " << FieldGroup::GetCurrentListObject().getSize() << " contre 5 attendus."<< std::endl; 
     30      std::clog << "Description du champs votkeavt : " << Field::GetObject("votkeavt").axis_ref << " contre \"Vertical Eddy Diffusivity\" attendus."<< std::endl;*/ 
     31 
    1532        } 
    1633        catch(const XMLIOException &exc) 
     
    1835                ERROR(exc.displayText());  
    1936                // On retourne le code d'erreur en fin d'application pour traitements éventuels. 
    20 //              return (exc.code()); 
     37      //        return (exc.code()); 
    2138        } 
    2239       
  • XMLIO_V2/dev/dev_rv/src/XMLIO/xmlio_container.hpp

    r98 r104  
    3434         bool hasMappedValue(const Key& kval) {return (find(kval) != this->end());} 
    3535           
    36          const vector<Mapped*> getVector(void) { return (this->_elemList); }          
     36         const vector<Mapped*>& getVector(void) const { return (this->_elemList); }          
    3737 
    3838         size_t getVectorSize(void) const {return (this->_elemList.size());} 
  • XMLIO_V2/dev/dev_rv/src/XMLIO/xmlio_exception.hpp

    r98 r104  
    6565   }; //class XMLParsingException 
    6666    
    67    class XMLIOIncompatibeTypeException : public XMLIOException 
     67   class XMLIOIncompatibleTypeException : public XMLIOException 
    6868   { 
    6969      public : 
    70          XMLIOIncompatibeTypeException(const std::string& _msg): XMLIOException(_msg, 1003) {} 
     70         XMLIOIncompatibleTypeException(const std::string& _msg): XMLIOException(_msg, 1003) {} 
    7171         const char* name(void) const throw() { return ("XMLIO>XMLIOIncompatibeTypeException"); } 
    7272             
  • XMLIO_V2/dev/dev_rv/src/XMLIO/xmlio_group_template.hpp

    r98 r104  
    1414         {/* Ne rien faire de plus */}             
    1515       
    16          virtual const char* getName(void) const {return ("GroupTemplate"); } 
    17                   
    1816         /// Pour les groupes d'objets enfants /// 
    1917          
     
    2422               
    2523            return (GroupTemplate<T, U>::GetObject(_id)); 
     24         } 
     25          
     26         XML::XMLNode getNodeIncludedFile(const string& path, const string& _rootName) 
     27         { 
     28            ifstream istr( path.c_str() , ifstream::in ); 
     29            return XML::XMLNode::CreateNode(istr, _rootName); 
    2630         } 
    2731          
     
    7579      protected: 
    7680       
    77       private: 
    7881         StrHashMap<T> childList; 
    7982         StrHashMap<GroupTemplate<T, U> > groupList; 
  • XMLIO_V2/dev/dev_rv/src/XMLIO/xmlio_logger.hpp

    r98 r104  
    5252   static ILogger LOGGER("xmlio.log"); 
    5353 
    54 #define   ERROR(MSG)   (ILogger::GetConsoleLogger().error(MSG)) 
    55 #define   WARNING(MSG)   (ILogger::GetConsoleLogger().warning(MSG)) 
    56 #define   INFO(MSG)   (ILogger::GetConsoleLogger().information(MSG)) 
    57 // A compléter. 
    58  
    59  
    60  
    6154/************* POUR MEMOIRE ********************** 
    6255#include <stdio.h>  
     
    9184}; // namespace XMLIOSERVER 
    9285 
     86#define   ERROR(MSG)   (XMLIOSERVER::ILogger::GetConsoleLogger().error(MSG)) 
     87#define   WARNING(MSG) (XMLIOSERVER::ILogger::GetConsoleLogger().warning(MSG)) 
     88#define   INFO(MSG)    (XMLIOSERVER::ILogger::GetConsoleLogger().information(MSG)) 
     89// A compléter. 
     90 
    9391#endif // __XMLIO_LOGGER__   
  • XMLIO_V2/dev/dev_rv/src/XMLIO/xmlio_object.hpp

    r98 r104  
    2424         {/* Ne rien faire de plus */}       
    2525    
    26          const string& getId(void) throw (XMLIOUndefinedValueException) 
     26         const string& getId(void) const throw (XMLIOUndefinedValueException) 
    2727         { if (!IdDefined) throw XMLIOUndefinedValueException("Appel de la méthode AbstractObject::getId invalide."); return (id); }    
    2828          
     
    3838         } 
    3939          
    40          friend ostream& operator<< (ostream& out, const AbstractObject& c)  
    41          { out << c.toString(); return (out);}    
    42           
    4340         virtual ~AbstractObject(void) 
    4441         {/* Ne rien faire de plus */} 
    4542       
    4643      protected : 
    47        
    48          virtual string toString(void) const 
    49          { 
    50             ostringstream st("["); 
    51             st << "[" << this->getName(); 
    52             if (hasId()) st << " id=\"" <<  id << "\""; 
    53             st << "]" ; 
    54             return (st.str()); 
    55          } 
    56           
    57          virtual const char* getName(void) const {return ("AbstractObject"); } 
     44 
    5845             
    5946      private : 
  • XMLIO_V2/dev/dev_rv/src/XMLIO/xmlio_object_template.hpp

    r98 r104  
    3838         { return (*ObjectTemplate<T>::AllListObj[CurrContext][_id]); } 
    3939          
    40          static bool HasObject(const string _id)// << Bug 
    41          { return (ObjectTemplate<T>::AllListObj[CurrContext].hasMappedValue(_id)); } 
     40         static bool HasObject(const string _id) 
     41         { 
     42            if(ObjectTemplate<T>::AllListObj.find(CurrContext) == ObjectTemplate<T>::AllListObj.end()) return false; 
     43            return (ObjectTemplate<T>::AllListObj[CurrContext].hasMappedValue(_id)); 
     44         } 
    4245          
    4346         static const StrHashMap<T>& GetCurrentListObject(void) { return (AllListObj[CurrContext]); } 
     
    4750          
    4851         static string& GetCurrentContextId(void) { return (CurrContext); }  
    49           
    50          virtual const char* getName(void) const {return ("ObjectTemplate"); } 
    5152          
    5253         virtual ~ObjectTemplate(void) 
  • XMLIO_V2/dev/dev_rv/src/XMLIO/xmlio_xml_node.hpp

    r98 r104  
    5858            { /* Ne rien faire de plus */}           
    5959 
    60             static XMLNode& CreateNode(XMLNode& node, istream& _istr, const string& _rootName = string("simulation")) 
     60            static XMLNode CreateNode(istream& _istr, const string& _rootName = string("simulation")) 
    6161            { 
     62               XMLNode node(_rootName); 
    6263               if ((_istr.good())) 
    6364               { // S'il est possible de lire le flux en entrée ... 
     
    6970                  node.pDoc = parser.parse(&src); 
    7071                  if (!(node.pDoc->documentElement()->nodeName().compare(_rootName))) 
    71                   { 
    72                      node.setCNode(node.pDoc->documentElement()); 
    73                      node.goToChildElement(); 
    74                   } 
     72                  { node.setCNode(node.pDoc->documentElement()); } 
    7573                  else 
    7674                  { 
  • XMLIO_V2/dev/dev_rv/src/XMLIO/xmlio_xml_parser.hpp

    r98 r104  
    11#ifndef __XMLIO_XML_PARSER__ 
    22#define __XMLIO_XML_PARSER__  
     3 
     4#include <stdlib.h> 
    35 
    46// Utilisation de la STL 
     
    1820            { 
    1921               THashAttributes attributes; 
     22                
     23               _node.goToChildElement(); // On se place sur le premier élément enfant du noeud racine. 
     24               atexit (&XMLParser::FreeMemory); // Pour supprimer la mémoire liée à l'allocation dynamique en fin d'exécution du programme.   
     25 
    2026                               
    2127               do {                 
     
    3642                   
    3743               } while (_node.goToNextElement());                
    38             }  
     44            } 
     45             
     46            static void ResolveInheritance(void) 
     47            { 
     48               HashMap<string, StrHashMap<Context> > &AllListContext = Context::GetAllListObject(); 
     49                
     50               for (HashMap<string, StrHashMap<Context> >::Iterator it = AllListContext.begin(); it != AllListContext.end(); it++) 
     51               { 
     52                  string& id = (*it).first; 
     53                  StrHashMap<Context>& sc = (*it).second; 
     54                   
     55                  // Résolution des héritages des descendands (càd des héritages de groupes) pour chacun des contextes. 
     56                  sc[id]->resolveDescInheritance(); 
     57               }                
     58            } 
     59             
     60            static void ShowTree(ostream& os = std::clog) 
     61            { 
     62               clog <<  "<?xml version=\"1.0\"?>" << std::endl << "<Simulation>" << std::endl; 
     63               HashMap<string, StrHashMap<Context> > &AllListContext = Context::GetAllListObject(); 
     64                
     65               for (HashMap<string, StrHashMap<Context> >::Iterator it = AllListContext.begin(); it != AllListContext.end(); it++) 
     66               { 
     67                  string& id = (*it).first; 
     68                  StrHashMap<Context>& sc = (*it).second; 
     69                   
     70                  // On sort chacun des contextes successivement. 
     71                  clog << *sc[id] << std::endl; 
     72               }  
     73               clog << "</Simulation>" << std::endl  ; 
     74            } 
    3975             
    4076            static void FreeMemory(void) 
     
    4682                  string& id = (*it).first; 
    4783                  StrHashMap<Context>& sc = (*it).second; 
    48                   // BUG AllListContext contient une StrHashMap<Context> liée à l'identifiant "" d'où la vérification ci-dessous. 
    49                   if (id.size()>0) delete sc[id]; 
     84                  delete sc[id]; 
    5085               } 
    51             } 
    52              
    53             static bool CLASS_TEST(const string& file = string("/local/testsuite/iodef_test.xml"), ostream& log = std::clog) 
    54             { 
    55                ifstream istr( file.c_str() , ifstream::in ); 
    56                XMLNode node("simulation"); 
    57                XMLNode::CreateNode(node, istr, "simulation"); 
    58                XMLParser::Parse(node); 
    59                log << "Nombre de Contexts listés : " << Context::GetCurrentListObject().getSize() << " contre 1 attendus."<< std::endl; 
    60                log << "Nombre de FieldGroups listés : " << FieldGroup::GetCurrentListObject().getSize() << " contre 5 attendus."<< std::endl; 
    61                log << "Description du champs votkeavt : " << Field::GetObject("votkeavt").description << " contre \"Vertical Eddy Diffusivity\" attendus."<< std::endl; 
    62                 
    63                log << "Test  XMLParser ... ok !" << std::endl; 
    64                 
    65                FreeMemory(); // Pour supprimer la mémoire liée à l'allocation dynamique. 
    66                 
    67                return (true); 
    6886            } 
    6987                  
Note: See TracChangeset for help on using the changeset viewer.