Changeset 107 for XMLIO_V2/dev/dev_rv/src/XMLIO/file_group.hpp
- Timestamp:
- 06/17/10 16:44:31 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XMLIO_V2/dev/dev_rv/src/XMLIO/file_group.hpp
r106 r107 3 3 4 4 namespace XMLIOSERVER 5 { 5 { 6 6 class FileGroup : public GroupTemplate<CFile, FileAttribut> 7 7 { 8 8 public: 9 9 10 10 FileGroup(void) : GroupTemplate<CFile, FileAttribut>() 11 {/* Ne rien faire de plus */} 11 {/* Ne rien faire de plus */} 12 12 FileGroup(const string& _id) : GroupTemplate<CFile, FileAttribut>(_id) 13 13 {/* 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) 39 16 { 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(); 61 18 THashAttributes attributes; 62 19 63 20 /// 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(); 71 33 } 72 73 attributes.clear(); 74 75 /// PARSING POUR GESION DES ENFANTS 34 35 /// PARSING POUR GESION DES ENFANTS /// 76 36 if (!(_node.goToChildElement())) 77 37 WARNING("Le groupe de fichier ne contient pas d'enfant !"); … … 79 39 { 80 40 ////////////////////////////////////// 81 do { // Parcours des contexts pour traitement. 82 41 do { // Parcours des contexts pour traitement. 42 83 43 string name = _node.getElementName(); 84 44 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 129 55 } while (_node.goToNextElement()); 130 56 ////////////////////////////////////// 131 _node.goToParentElement(); // Retour au parent 57 _node.goToParentElement(); // Retour au parent 132 58 } 133 134 return;135 59 } 136 137 virtual ~FileGroup(void) 60 61 virtual ~FileGroup(void) 138 62 {/* Ne rien faire de plus */ } 139 63 140 64 }; // class FileGroup 141 65 142 66 typedef FileGroup FileDefinition ; 143 67 144 68 }; // namespace XMLIOSERVER 145 69 146 70 #endif // __FILE_GROUP__ 147 71
Note: See TracChangeset
for help on using the changeset viewer.