Changeset 95


Ignore:
Timestamp:
06/04/10 12:02:47 (14 years ago)
Author:
hozdoba
Message:
 
Location:
XMLIO_V2/dev/dev_rv
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • XMLIO_V2/dev/dev_rv/attribut_registrar.hpp

    r88 r95  
    1313         {/* Ne rien faire de plus */} 
    1414       
    15          void RegisterAttribut(BaseAttribut* attribut){ attrList.addPtrObject(attribut); }          
    16          StrHashMap<BaseAttribut*>& getAttributList(void) { return (attrList); }          
     15         void RegisterAttribut(BaseAttribut* attribut){ attrList.addObject(attribut); }          
     16         StrHashMap<BaseAttribut>& getAttributList(void) { return (attrList); }          
    1717         size_t getNbAttributes() const {return (attrList.getSize()); } 
    1818         bool hasAttribut(const string _id) { return (attrList.hasMappedValue(_id)); } 
     
    2929            { 
    3030               ostringstream oss; 
    31                oss << "CAttributRegistrar::setAttribut<ValueType>, could not find <<"<<att_name<<">> attribut in registred list" <<">>"; 
     31               oss << "CAttributRegistrar::setAttribut<ValueType>, could not find <<" << att_name <<">> attribut in registred list" <<">>"; 
    3232               throw XMLIOUndefinedValueException(oss.str()); 
    33             } 
    34            
     33            }          
    3534         } 
    36                
    37          ostream & PrintAttribut(ostream& o) {o << "A réimplémenter"; return o ;} 
     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          
     48      public : 
    3849          
    3950        ~AttributRegistrar(void) 
     
    4152         
    4253      private : 
    43          StrHashMap<BaseAttribut*> attrList; 
     54         StrHashMap<BaseAttribut> attrList; 
    4455         
    4556   }; // class AttributRegistrar   
  • XMLIO_V2/dev/dev_rv/context.hpp

    r94 r95  
    5555                  } 
    5656                  else if (name.compare("file_definition") == 0) 
    57                   { // Parsing pour la définition des fichiers. 
     57                  { // Parsing pour la définition des fichiers.                   
     58                     INFO("Le parsing des définitions de fichiers n'est pas encore implémenté"); 
    5859                  }  
    5960                  else if (name.compare("axis_definition") == 0) 
    6061                  { // Parsing pour la définition des axes. 
     62                     INFO("Le parsing des définitions d'axes n'est pas encore implémenté"); 
    6163                  } 
    6264                  else if (name.compare("grid_definition") == 0) 
    6365                  { // Parsing pour la définition des grilles. 
     66                     INFO("Le parsing des définitions de grilles n'est pas encore implémenté"); 
    6467                  }  
    6568                  else 
     
    7578            return; 
    7679         } 
    77           
    78          void registerAllAttributes(void) 
    79          { /* Ne rien faire de plus */ } 
    8080          
    8181         virtual const char* getName(void) const {return ("Context"); } 
  • XMLIO_V2/dev/dev_rv/field.hpp

    r91 r95  
    33 
    44using XMLIOSERVER::XML::XMLNode; 
     5using XMLIOSERVER::XML::THashAttributes; 
    56 
    67namespace XMLIOSERVER 
    78{ 
    8    class Field : public ObjectTemplate<Field> 
     9   class Field : public ObjectTemplate<Field>, public FieldAttribut 
    910   { 
    1011      public: 
    11          Field(void) : ObjectTemplate<Field>() 
     12         Field(void) : ObjectTemplate<Field>(), FieldAttribut() 
    1213                        {/* Ne rien faire de plus */}                    
    13                         Field(const string& _id) : ObjectTemplate<Field>(_id) 
     14                        Field(const string& _id) : ObjectTemplate<Field>(_id), FieldAttribut() 
    1415         {/* Ne rien faire de plus */}   
     16          
     17         void setAttributes(const THashAttributes& attr) 
     18         { 
     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; 
     24         } 
    1525          
    1626         virtual const char* getName(void) const {return ("Field"); }    
     
    1828                        void parse (XMLNode& _node) 
    1929                        { 
     30            string name = _node.getElementName();             
     31            THashAttributes attributes; 
     32             
    2033            /// PARSING GESTION DES ATTRIBUTS /// 
    21             // A compléter. 
     34            _node.getAttributes(attributes);   
     35            this->setAttributes(attributes); 
     36            attributes.clear(); 
    2237             
    2338            /// PARSING POUR GESION DES ENFANTS 
  • XMLIO_V2/dev/dev_rv/field_attribut.hpp

    r91 r95  
    1919         DECLARE_ATTR(level, int) ; 
    2020         DECLARE_ATTR(prec, int) ; 
     21          
     22         DECLARE_ATTR(src, string) ; // TEMPORAIRE, pour fieldgroup uniquement 
    2123       
    2224         DECLARE_ATTR(enabled, bool); 
     
    2830       
    2931         FieldAttribut(void) 
    30          { /* Ne rien faire de plus */ } 
    31                   
    32          // TODO Peut-être définir un constructeur par copie au lieu de registerAllAttributes (éventuellement) 
    33           
    34          virtual void registerAllAttributes(void) 
     32         { registerAllAttributes(); } 
     33                          
     34         void registerAllAttributes(void) 
    3535         { 
    3636            RegisterAttribut(&name) ; 
     
    3838            RegisterAttribut(&unit) ; 
    3939            RegisterAttribut(&operation); 
     40             
     41            RegisterAttribut(&src);// TEMPORAIRE, pour fieldgroup uniquement 
    4042       
    4143            RegisterAttribut(&freq_op) ; 
  • XMLIO_V2/dev/dev_rv/field_group.hpp

    r94 r95  
    3131            string name = _node.getElementName();             
    3232            THashAttributes attributes; 
    33             std::cout << "Traitement de " << name << std::endl; 
    3433             
    3534            /// PARSING GESTION DES ATTRIBUTS /// 
     
    5251                  if (name.compare("field_group") == 0) 
    5352                  { // Parsing pour les groupes de champs 
     53                   
     54                     FieldGroup* fgroup = NULL; 
    5455                         
    5556                     if (attributes.end() != attributes.find("id")) 
     
    5758                        if (FieldGroup::HasObject(attributes["id"])) 
    5859                           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 
    59                         FieldGroup* fgroup =(FieldGroup*)&createGroup(attributes["id"]); 
     60                        fgroup =(FieldGroup*)&createGroup(attributes["id"]); 
    6061                        fgroup->parse(_node); 
    6162                     } 
    62                      /*else 
    63                         this->createGroup();*/ 
    64  
     63                     else 
     64                     {// Si l'identifiant n'est pas défini. 
     65                        fgroup = (FieldGroup*)&createGroup(); 
     66                        fgroup->parse(_node); 
     67                     } 
    6568                         
    6669                     continue; 
     
    7073                  { // Parsing pour les champs 
    7174                   
     75                     Field* field = NULL; 
     76                   
    7277                     if (attributes.end() != attributes.find("id")) 
     78                     {// Si l'identifiant est défini. 
    7379                        if (Field::HasObject(attributes["id"])) 
    74                            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                 
     80                           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"]); 
     82                        field->parse(_node); 
     83                     } 
     84                     else 
     85                     {// Si l'identifiant n'est pas défini. 
     86                        field = (Field*)&createChild(); 
     87                        field->parse(_node); 
     88                     }          
     89                     
     90                     continue; 
    7591                  }  
    7692                  else 
  • XMLIO_V2/dev/dev_rv/xmlio.hpp

    r94 r95  
    2424#include "xmlio_logger.hpp" 
    2525#include "xmlio_container.hpp" 
    26  
    27 // Concernant les attributs ... 
    28  
    2926#include "xmlio_object.hpp" 
    3027#include "xmlio_xml_node.hpp" 
  • XMLIO_V2/dev/dev_rv/xmlio_c_interface.cpp

    r88 r95  
    22{ // Début du code C 
    33 
    4    using namespace XMLIOSERVER; 
    5    using namespace XMLIOSERVER::XML; 
    6    using namespace std; 
     4   //using namespace XMLIOSERVER; 
     5   //using namespace XMLIOSERVER::XML; 
     6   //using namespace std; 
    77    
    88   typedef void *XMLIOhandle; 
  • XMLIO_V2/dev/dev_rv/xmlio_container.hpp

    r91 r95  
    1919   template<class Key, class Mapped, class HashFunc = Hash<Key> > 
    2020      class ExHashMap 
    21          : private HashMap<Key, Mapped, Hash<Key> > 
     21         : private HashMap<Key, Mapped*, Hash<Key> > 
    2222   { 
    2323      public : 
    24          ExHashMap() :  HashMap<Key, Mapped, Hash<Key> >(), _elemList() 
     24         ExHashMap() :  HashMap<Key, Mapped*, Hash<Key> >(), _elemList() 
    2525         {/* Ne rien faire de plus */} 
    2626                
    27          Mapped& operator[] (const Key& kval) throw (XMLIOUndefinedValueException) 
     27         Mapped* operator[] (const Key& kval) throw (XMLIOUndefinedValueException) 
    2828         {  
    2929            if(!hasMappedValue(kval)) 
     
    4444      protected : 
    4545       
    46          bool addValue(const Key& kval, Mapped& element) 
     46         bool addValue(const Key& kval, Mapped* element) 
    4747         { 
    4848            pair<typename ExHashMap::Iterator,bool> p = this->insert(make_pair (kval,element)); 
     
    5151         } 
    5252          
    53          bool addValue(Mapped& element) 
    54          {   this->_elemList.insert(this->_elemList.end(), &element);   return (true);   }    
     53         bool addValue(Mapped* element) 
     54         {   this->_elemList.insert(this->_elemList.end(), element);   return (true);   }    
    5555          
    5656          
    57          void removeValue(const Key& kval) 
    58          { Mapped& element = find(kval)->second; removeValue(element); this->erase(kval);  } 
     57         void removeValue(const Key& kval) // Non testé 
     58         { Mapped* element = find(kval)->second; removeValue(element); this->erase(kval); } 
    5959          
    60          void removeValue(const Mapped& element) 
     60         void removeValue(const Mapped* element) // Non testé 
    6161         { 
    6262            for (int i = 0; i < this->_elemList.size(); i++)              
    63                if (*this->_elemList[i] == element ) this->_elemList.erase(this->_elemList.begin()+i); 
     63               if (*this->_elemList[i] == element ) 
     64                  this->_elemList.erase(this->_elemList.begin()+i); 
     65                   
     66            delete element; 
    6467         } 
    6568          
     
    8083         {/* Ne rien faire de plus */}    
    8184          
    82          bool addObject(Mapped& element) 
    83          { if(element.hasId()) return(addValue(element.getId(), element));   return(addValue(element)); } 
    84           
    85          bool addPtrObject(Mapped element) 
     85         bool addObject(Mapped* element) 
    8686         { if(element->hasId()) return(addValue(element->getId(), element));   return(addValue(element)); } 
    87           
     87                   
    8888         bool removeObject(const string& kval) 
    8989         {  
  • XMLIO_V2/dev/dev_rv/xmlio_group_template.hpp

    r94 r95  
    2020         GroupTemplate<T, U>& createGroup(const string _id) throw (XMLIOUndefinedValueException)  
    2121         { 
    22             GroupTemplate<T, U>::CreateObject(_id); 
    23            // groupList.addPtrObject(&obj);// Foireux 
     22            GroupTemplate<T, U> &obj = GroupTemplate<T, U>::CreateObject(_id); 
     23            groupList.addObject(&obj); 
    2424               
    2525            return (GroupTemplate<T, U>::GetObject(_id)); 
     
    2929         { 
    3030            GroupTemplate<T, U>& obj = GroupTemplate<T, U>::CreateObject(); 
    31             //groupList.addPtrObject(&obj); // Foireux  
     31            groupList.addObject(&obj); 
    3232                      
    3333            return (obj); 
     
    4646         { 
    4747            T& obj = ObjectTemplate<T>::CreateObject(_id); 
    48             childList.addPtrObject(&obj); 
     48            childList.addObject(&obj); 
    4949            return (obj); 
    5050         } 
     
    5353         { 
    5454            T& obj = ObjectTemplate<T>::CreateObject(); 
    55             childList.addPtrObject(&obj);             
     55            childList.addObject(&obj);             
    5656            return (obj); 
    5757         }          
     
    7171       
    7272      private: 
    73          StrHashMap<T*> childList; 
    74          StrHashMap<GroupTemplate<T, U>* > groupList; 
     73         StrHashMap<T> childList; 
     74         StrHashMap<GroupTemplate<T, U> > groupList; 
    7575 
    7676   }; // class GroupTemplate 
  • XMLIO_V2/dev/dev_rv/xmlio_logger.hpp

    r94 r95  
    33 
    44// Entête Poco logging 
    5 #include "Poco/Logger.h" 
    6 #include "Poco/PatternFormatter.h" 
    7 #include "Poco/FormattingChannel.h" 
    8 #include "Poco/ConsoleChannel.h" 
    9 #include "Poco/FileChannel.h" 
    10 #include "Poco/Message.h" 
     5#include <Poco/Logger.h> 
     6#include <Poco/PatternFormatter.h> 
     7#include <Poco/FormattingChannel.h> 
     8#include <Poco/ConsoleChannel.h> 
     9#include <Poco/FileChannel.h> 
     10#include <Poco/Message.h> 
    1111 
    1212// Classes utilisées issues de Poco 
     
    5353#define   ERROR(MSG)   (ILogger::GetConsoleLogger().error(MSG)) 
    5454#define   WARNING(MSG)   (ILogger::GetConsoleLogger().warning(MSG)) 
     55#define   INFO(MSG)   (ILogger::GetConsoleLogger().information(MSG)) 
    5556// A compléter. 
    5657 
  • XMLIO_V2/dev/dev_rv/xmlio_object_template.hpp

    r94 r95  
    2222               return (ObjectTemplate<T>::GetObject(_id)); 
    2323                               
    24             // Ajout d'un nouvel objet si l'identifiant n'est pas répertorié. 
    25             T identified_object(_id); 
    26              
    27             ObjectTemplate<T>::AllListObj[CurrContext].addObject(identified_object); 
    28             ObjectTemplate<T>::GetObject(_id).registerAllAttributes(); 
     24            // Ajout d'un nouvel objet si l'identifiant n'est pas répertorié.            
     25            ObjectTemplate<T>::AllListObj[CurrContext].addObject(new T(_id)); 
    2926             
    3027            return (ObjectTemplate<T>::GetObject(_id)); 
     
    3330         static T& CreateObject(void) 
    3431         { 
    35             ObjectTemplate<T>::AllListObj[CurrContext].addObject(*(new T)); //<< Perte mémoire ici 
    36             return (*(ObjectTemplate<T>::AllListObj[CurrContext].getVector()[ObjectTemplate<T>::AllListObj[CurrContext].getVectorSize()-1])); 
     32            T* value = new T; 
     33            ObjectTemplate<T>::AllListObj[CurrContext].addObject(value); //<< Perte mémoire ici 
     34            return (*value); 
    3735         } 
    3836          
    3937         static T& GetObject(const string _id) throw (XMLIOUndefinedValueException) 
    40          { return (ObjectTemplate<T>::AllListObj[CurrContext][_id]); } 
     38         { return (*ObjectTemplate<T>::AllListObj[CurrContext][_id]); } 
    4139          
    4240         static bool HasObject(const string _id) 
     
    4745         static void SetContext(const string& id) 
    4846         { ObjectTemplate<T>::CurrContext = id; }  
     47          
     48         static string& GetCurrentContextId(void) { return (CurrContext); }  
    4949          
    5050         virtual const char* getName(void) const {return ("ObjectTemplate"); } 
  • XMLIO_V2/dev/dev_rv/xmlio_xml_parser.hpp

    r94 r95  
    4343               XMLNode node = XMLNode::CreateNode(istr); 
    4444               XMLParser::Parse(node); 
    45                log << "Nombre de contexts listés : " << Context::GetCurrentListObject().getSize() << " contre 2 attendus."<< std::endl; 
    46                log << "Nombre de contexts listés : " << FieldGroup::GetCurrentListObject().getSize() << " contre 1 attendus."<< std::endl; 
     45               log << "Nombre de Contexts listés : " << Context::GetCurrentListObject().getSize() << " contre 2 attendus."<< std::endl; 
     46               log << "Nombre de FieldGroups listés : " << FieldGroup::GetCurrentListObject().getSize() << " contre 5 attendus."<< std::endl; 
     47               log << "Description du champs votkeavt : " << Field::GetObject("votkeavt").description << " contre \"Vertical Eddy Diffusivity\" attendus."<< std::endl; 
     48                
    4749               log << "Test  XMLParser ... ok !" << std::endl; 
    4850               return (true); 
Note: See TracChangeset for help on using the changeset viewer.