source: XMLIO_V2/dev/dev_rv/src/XMLIO/file.hpp @ 109

Last change on this file since 109 was 109, checked in by hozdoba, 14 years ago

Ajout de contrÎles sur les dépendances circulaires, passages des attributs lors de l'héritage par réf.

File size: 2.5 KB
Line 
1#ifndef __CFILE__
2#define __CFILE__
3
4using XMLIOSERVER::XML::XMLNode;
5using XMLIOSERVER::XML::THashAttributes;
6
7namespace XMLIOSERVER
8{
9   class CFile : public ObjectTemplate<CFile>, public FileAttribut
10   {
11      public:
12
13         CFile(void) : ObjectTemplate<CFile>(), FileAttribut(), vfieldGroup(NULL)
14         {/* Ne rien faire de plus */}
15         CFile(const string& _id) : ObjectTemplate<CFile>(_id), FileAttribut(), vfieldGroup(NULL)
16         {/* Ne rien faire de plus */}
17
18         static string GetName(void) { return ("file"); }
19
20         void parse (XMLNode& _node)
21         {
22            string name = _node.getElementName();
23            THashAttributes attributes;
24
25            /// PARSING GESTION DES ATTRIBUTS ///
26            _node.getAttributes(attributes);
27            this->setAttributes(attributes);
28            attributes.clear();
29
30            /// PARSING POUR GESION DES ENFANTS ///
31            if (_node.goToChildElement() and hasId())
32            { // Si la définition du fichier intégre des champs et si le fichier est identifié.
33               _node.goToParentElement();
34               vfieldGroup = CreateInstanceAndParse<FieldGroup>(attributes, _node, getId().c_str(), false );
35            }
36         }
37
38         void getAllFields(std::vector<CField*>& _allF) const {  if (vfieldGroup!=NULL) vfieldGroup->getAllChildren(_allF); }
39         virtual bool hasChild(void) const { return (vfieldGroup != NULL); }
40         virtual void printChild(ostream& out) const { out << *vfieldGroup << std::endl; }
41         /*{ // Sortie sans affichage des groupes.
42            std::vector<CField*> allF; getAllFields(allF);
43            for (unsigned int i = 0; i < allF.size(); i++)
44               out << *(allF[i]) << std::endl;
45         }*/
46         virtual void resolveDescInheritance(const AttributRegistrar* _parent = 0)
47         { addAttributes(*_parent); if(vfieldGroup != NULL) vfieldGroup->resolveDescInheritance(); }
48
49         void resolveFieldRefInheritance(void)
50         { // Résolution des héritages par référence de chacun des champs contenus dans le fichier.
51            std::vector<CField*> allF; getAllFields(allF);
52            for (unsigned int i = 0; i < allF.size(); i++) allF[i]->resolveRefInheritance();
53         }
54
55         FieldGroup* getVirtualFieldGroup(void) { return (vfieldGroup); }
56
57         ~CFile(void)
58         { if(vfieldGroup != NULL) delete vfieldGroup; }
59
60      private :
61
62         FieldGroup* vfieldGroup; // FieldGroup "virtuel"
63
64   }; // class CFile
65
66}; // namespace XMLIOSERVER
67
68#endif // __CFILE__
Note: See TracBrowser for help on using the repository browser.