1 | #ifndef __FIELD_GROUP__ |
---|
2 | #define __FIELD_GROUP__ |
---|
3 | |
---|
4 | |
---|
5 | using XMLIOSERVER::XML::THashAttributes; |
---|
6 | |
---|
7 | namespace 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 | |
---|
34 | /// PARSING GESTION DES ATTRIBUTS /// |
---|
35 | _node.getAttributes(attributes); |
---|
36 | this->setAttributes(attributes); |
---|
37 | attributes.clear(); |
---|
38 | |
---|
39 | /// PARSING POUR GESION DES ENFANTS |
---|
40 | if (!(_node.goToChildElement())) |
---|
41 | WARNING("Le groupe de champ ne contient pas d'enfant !"); |
---|
42 | else |
---|
43 | { |
---|
44 | ////////////////////////////////////// |
---|
45 | do { // Parcours des contexts pour traitement. |
---|
46 | |
---|
47 | string name = _node.getElementName(); |
---|
48 | attributes.clear(); |
---|
49 | _node.getAttributes(attributes); |
---|
50 | |
---|
51 | if (name.compare("field_group") == 0) |
---|
52 | { // Parsing pour les groupes de champs |
---|
53 | |
---|
54 | FieldGroup* fgroup = NULL; |
---|
55 | |
---|
56 | if (attributes.end() != attributes.find("id")) |
---|
57 | {// Si l'identifiant est défini. |
---|
58 | if (FieldGroup::HasObject(attributes["id"])) |
---|
59 | 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"]); |
---|
61 | fgroup->parse(_node); |
---|
62 | } |
---|
63 | else |
---|
64 | {// Si l'identifiant n'est pas défini. |
---|
65 | fgroup = (FieldGroup*)&createGroup(); |
---|
66 | fgroup->parse(_node); |
---|
67 | } |
---|
68 | |
---|
69 | continue; |
---|
70 | |
---|
71 | } |
---|
72 | else if (name.compare("field") == 0) |
---|
73 | { // Parsing pour les champs |
---|
74 | |
---|
75 | Field* field = NULL; |
---|
76 | |
---|
77 | if (attributes.end() != attributes.find("id")) |
---|
78 | {// Si l'identifiant est défini. |
---|
79 | if (Field::HasObject(attributes["id"])) |
---|
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; |
---|
91 | } |
---|
92 | else |
---|
93 | WARNING("Un groupe de champs ne peut contenir qu'un champ ou un autre groupe de champs !"); |
---|
94 | |
---|
95 | } while (_node.goToNextElement()); |
---|
96 | ////////////////////////////////////// |
---|
97 | _node.goToParentElement(); // Retour au parent |
---|
98 | } |
---|
99 | |
---|
100 | return; |
---|
101 | } |
---|
102 | |
---|
103 | virtual ~FieldGroup(void) |
---|
104 | {/* Ne rien faire de plus */} |
---|
105 | |
---|
106 | }; // class FieldGroup |
---|
107 | |
---|
108 | typedef FieldGroup FieldDefinition ; |
---|
109 | |
---|
110 | }; // namespace XMLIOSERVER |
---|
111 | |
---|
112 | #endif // __FIELD_GROUP__ |
---|
113 | |
---|