Ignore:
Timestamp:
06/17/10 16:44:31 (14 years ago)
Author:
hozdoba
Message:

Commit intermédiaire ...
Remontée de plusieurs fonctionnalités dans l'arbre des héritages.
Amélioration de la lisibilité du code.
etc.

File:
1 edited

Legend:

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

    r106 r107  
    33 
    44namespace XMLIOSERVER 
    5 {    
     5{ 
    66   class FileGroup : public GroupTemplate<CFile, FileAttribut> 
    77   { 
    88      public: 
    9        
     9 
    1010         FileGroup(void) : GroupTemplate<CFile, FileAttribut>() 
    11          {/* Ne rien faire de plus */}                
     11         {/* Ne rien faire de plus */} 
    1212         FileGroup(const string& _id) : GroupTemplate<CFile, FileAttribut>(_id) 
    1313         {/* Ne rien faire de plus */} 
    14                           
    15          const char* getName(void) const {return ("File_Group"); }   
    16           
    17           
    18          /// TODO A remonter dans l'arbre des héritages 
    19          friend ostream& operator<< (ostream& out, const FileGroup& c)  
    20          {    
    21             const AttributRegistrar &ar = c; 
    22             out << IncIndent << "<" << c.getName() << c.printId() << ar << ">" << std::endl;             
    23              
    24             // Ecriture des sous-groupes. 
    25             for(unsigned int i = 0; i < c.groupList.getVector().size() ; i++) 
    26                out << *((FileGroup*)c.groupList.getVector()[i])  << std::endl; 
    27                 
    28             // Ecriture des enfants. 
    29             for(unsigned int i = 0; i < c.childList.getVector().size() ; i++) 
    30                out << *((CFile*)c.childList.getVector()[i]) << std::endl; 
    31                 
    32             out << NIndent << "</" << c.getName()<< ">" << DecEndl; 
    33              
    34             return (out); 
    35          }    
    36           
    37          /// TODO A remonter dans l'arbre des héritages    
    38          void resolveDescInheritance(const AttributRegistrar* _parent = 0) 
     14 
     15         void parse (XMLNode& _node, bool _withAttr = true) 
    3916         { 
    40             const vector<CFile*>&  childvect = childList.getVector(); 
    41             const vector<GroupTemplate<CFile, FileAttribut>*>& groupvect = groupList.getVector(); 
    42              
    43             // On complÚte les propres attributs du groupe. 
    44             if (_parent!= NULL) addAttributes(*_parent); 
    45              
    46             for(unsigned int i = 0; i < childvect.size() ; i++) 
    47             { // on complÚte les attributs des champs enfants. 
    48                childvect[i] -> addAttributes(*this); 
    49                if (childvect[i]->hasVirtualFieldGroup()) 
    50                   childvect[i]->getVirtualFieldGroup()-> resolveDescInheritance(); 
    51             } 
    52                 
    53             for(unsigned int i = 0; i < groupvect.size() ; i++) 
    54             // on complÚte les attributs des groupes de champs enfants. 
    55                ((FileGroup*)groupvect[i]) -> resolveDescInheritance(this); 
    56          } 
    57           
    58          void parse (XMLNode& _node) 
    59          { 
    60             string name = _node.getElementName();             
     17            string name = _node.getElementName(); 
    6118            THashAttributes attributes; 
    6219 
    6320            /// PARSING GESTION DES ATTRIBUTS /// 
    64             _node.getAttributes(attributes);   
    65             this->setAttributes(attributes); 
    66              
    67             if (attributes.end() != attributes.find("src")) 
    68             { // Si une demande d'inclusion de fichier est trouvé. 
    69                XMLNode _node_inc = getNodeIncludedFile(attributes["src"], name); 
    70                parse (_node_inc); 
     21            if (_withAttr) 
     22            { 
     23               _node.getAttributes(attributes); 
     24               this->setAttributes(attributes); 
     25 
     26               if (attributes.end() != attributes.find("src")) 
     27               { // Si une demande d'inclusion de fichier est trouvée. 
     28                  XMLNode _node_inc = getNodeIncludedFile(attributes["src"], name); 
     29                  parse (_node_inc); 
     30               } 
     31 
     32               attributes.clear(); 
    7133            } 
    72              
    73             attributes.clear(); 
    74                 
    75             /// PARSING POUR GESION DES ENFANTS 
     34 
     35            /// PARSING POUR GESION DES ENFANTS /// 
    7636            if (!(_node.goToChildElement())) 
    7737               WARNING("Le groupe de fichier ne contient pas d'enfant !"); 
     
    7939            { 
    8040               ////////////////////////////////////// 
    81                do { // Parcours des contexts pour traitement.  
    82                              
     41               do { // Parcours des contexts pour traitement. 
     42 
    8343                  string name = _node.getElementName(); 
    8444                  attributes.clear(); 
    85                   _node.getAttributes(attributes);   
    86                                   
    87                   if (name.compare("file_group") == 0) 
    88                   { // Parsing pour les groupes de champs 
    89                    
    90                      FileGroup* fgroup = NULL; 
    91                          
    92                      if (attributes.end() != attributes.find("id")) 
    93                      {// Si l'identifiant est défini. 
    94                         if (FileGroup::HasObject(attributes["id"])) 
    95                            WARNING("Dans le context actuel, un groupe de fichier du même nom existe déjà, le second fera référence au premier par défaut !"); // TODO TODO 
    96                         fgroup = (FileGroup*)(&createGroup(attributes["id"])); 
    97                         fgroup->parse(_node); 
    98                      } 
    99                      else 
    100                      {// Si l'identifiant n'est pas défini. 
    101                         fgroup = (FileGroup*)(&createGroup()); 
    102                         fgroup->parse(_node); 
    103                      }                         
    104                      continue; 
    105                          
    106                   } 
    107                   else if (name.compare("file") == 0) 
    108                   { // Parsing pour les champs. 
    109                    
    110                      CFile* file = NULL; 
    111                    
    112                      if (attributes.end() != attributes.find("id")) 
    113                      {// Si l'identifiant est défini. 
    114                         if (CFile::HasObject(attributes["id"])) 
    115                            WARNING("Dans le context actuel, un fichier du même nom existe déjà, le second fera référence au premier par défaut !");  // TODO TODO 
    116                         file = (CFile*)(&createChild(attributes["id"])); 
    117                         file->parse(_node); 
    118                      } 
    119                      else 
    120                      {// Si l'identifiant n'est pas défini. 
    121                         file = (CFile*)(&createChild()); 
    122                         file->parse(_node); 
    123                      }                   
    124                      continue; 
    125                   }  
    126                   else 
    127                      WARNING("Un groupe de fichiers ne peut contenir qu'un fichier ou un autre groupe de fichiers !"); 
    128                       
     45                  _node.getAttributes(attributes); 
     46 
     47                  if (name.compare(FileGroup::GetName()) == 0) 
     48                  { createGroupAndParse<FileGroup>(attributes, _node); continue; } 
     49 
     50                  if (name.compare(CFile::GetName()) == 0) 
     51                  { createChildAndParse<CFile>(attributes, _node) ; continue; } 
     52 
     53                  WARNING("Un groupe de fichiers ne peut contenir qu'un fichier ou un autre groupe de fichiers !"); 
     54 
    12955               } while (_node.goToNextElement()); 
    13056               ////////////////////////////////////// 
    131                _node.goToParentElement(); // Retour au parent   
     57               _node.goToParentElement(); // Retour au parent 
    13258            } 
    133                                         
    134             return; 
    13559         } 
    136           
    137          virtual ~FileGroup(void)  
     60 
     61         virtual ~FileGroup(void) 
    13862         {/* Ne rien faire de plus */ } 
    139                   
     63 
    14064   }; // class FileGroup 
    141       
     65 
    14266   typedef FileGroup FileDefinition ; 
    143     
     67 
    14468}; // namespace XMLIOSERVER 
    145     
     69 
    14670#endif // __FILE_GROUP__ 
    14771 
Note: See TracChangeset for help on using the changeset viewer.