source: XMLIO_V2/dev/dev_rv/field_group.hpp @ 94

Last change on this file since 94 was 94, checked in by hozdoba, 13 years ago
File size: 3.7 KB
Line 
1#ifndef __FIELD_GROUP__
2#define __FIELD_GROUP__
3
4
5using XMLIOSERVER::XML::THashAttributes;
6
7namespace XMLIOSERVER
8{   
9   class FieldGroup : public GroupTemplate<Field, FieldAttribut>
10   {
11      public:
12     
13         FieldGroup(void) : GroupTemplate<Field, FieldAttribut>()
14         {/* Ne rien faire de plus */}               
15         FieldGroup(const string& _id) : GroupTemplate<Field, FieldAttribut>(_id)
16         {/* Ne rien faire de plus */}
17         
18         void setAttributes(const THashAttributes& attr)
19         {
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.
22                  this->setSAttribut((*it).first, (*it).second);
23           
24            return;
25         }
26                 
27         virtual const char* getName(void) const {return ("FieldGroup"); } 
28         
29         void parse (XMLNode& _node)
30         {
31            string name = _node.getElementName();           
32            THashAttributes attributes;
33            std::cout << "Traitement de " << name << std::endl;
34           
35            /// PARSING GESTION DES ATTRIBUTS ///
36            _node.getAttributes(attributes); 
37            this->setAttributes(attributes);
38            attributes.clear();
39               
40            /// PARSING POUR GESION DES ENFANTS
41            if (!(_node.goToChildElement()))
42               WARNING("Le groupe de champ ne contient pas d'enfant !");
43            else
44            {
45               //////////////////////////////////////
46               do { // Parcours des contexts pour traitement.
47                           
48                  string name = _node.getElementName();
49                  attributes.clear();
50                  _node.getAttributes(attributes); 
51                                 
52                  if (name.compare("field_group") == 0)
53                  { // Parsing pour les groupes de champs
54                       
55                     if (attributes.end() != attributes.find("id"))
56                     {// Si l'identifiant est défini.
57                        if (FieldGroup::HasObject(attributes["id"]))
58                           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->parse(_node);
61                     }
62                     /*else
63                        this->createGroup();*/
64
65                       
66                     continue;
67                       
68                  }
69                  else if (name.compare("field") == 0)
70                  { // Parsing pour les champs
71                 
72                     if (attributes.end() != attributes.find("id"))
73                        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               
75                  } 
76                  else
77                     WARNING("Un groupe de champs ne peut contenir qu'un champ ou un autre groupe de champs !");
78                     
79               } while (_node.goToNextElement());
80               //////////////////////////////////////
81               _node.goToParentElement(); // Retour au parent 
82            }
83                                       
84            return;
85         }
86         
87         ~FieldGroup(void) 
88         {/* Ne rien faire de plus */}   
89         
90   }; // class FieldGroup
91     
92   typedef FieldGroup FieldDefinition ;
93   
94}; // namespace XMLIOSERVER
95   
96#endif // __FIELD_GROUP__
97
Note: See TracBrowser for help on using the repository browser.