Changeset 95
- Timestamp:
- 06/04/10 12:02:47 (13 years ago)
- Location:
- XMLIO_V2/dev/dev_rv
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
XMLIO_V2/dev/dev_rv/attribut_registrar.hpp
r88 r95 13 13 {/* Ne rien faire de plus */} 14 14 15 void RegisterAttribut(BaseAttribut* attribut){ attrList.add PtrObject(attribut); }16 StrHashMap<BaseAttribut *>& getAttributList(void) { return (attrList); }15 void RegisterAttribut(BaseAttribut* attribut){ attrList.addObject(attribut); } 16 StrHashMap<BaseAttribut>& getAttributList(void) { return (attrList); } 17 17 size_t getNbAttributes() const {return (attrList.getSize()); } 18 18 bool hasAttribut(const string _id) { return (attrList.hasMappedValue(_id)); } … … 29 29 { 30 30 ostringstream oss; 31 oss << "CAttributRegistrar::setAttribut<ValueType>, could not find <<" <<att_name<<">> attribut in registred list" <<">>";31 oss << "CAttributRegistrar::setAttribut<ValueType>, could not find <<" << att_name <<">> attribut in registred list" <<">>"; 32 32 throw XMLIOUndefinedValueException(oss.str()); 33 } 34 33 } 35 34 } 36 37 ostream & PrintAttribut(ostream& o) {o << "A réimplémenter"; return o ;} 35 36 friend ostream& operator<< (ostream& out, const AttributRegistrar& c) 37 { out << c.toString(); return (out);} 38 39 protected : 40 41 string toString(void) const 42 { 43 ostringstream st("A réimplémenter"); 44 // A compléter 45 return (st.str()); 46 } 47 48 public : 38 49 39 50 ~AttributRegistrar(void) … … 41 52 42 53 private : 43 StrHashMap<BaseAttribut *> attrList;54 StrHashMap<BaseAttribut> attrList; 44 55 45 56 }; // class AttributRegistrar -
XMLIO_V2/dev/dev_rv/context.hpp
r94 r95 55 55 } 56 56 else if (name.compare("file_definition") == 0) 57 { // Parsing pour la définition des fichiers. 57 { // Parsing pour la définition des fichiers. 58 INFO("Le parsing des définitions de fichiers n'est pas encore implémenté"); 58 59 } 59 60 else if (name.compare("axis_definition") == 0) 60 61 { // Parsing pour la définition des axes. 62 INFO("Le parsing des définitions d'axes n'est pas encore implémenté"); 61 63 } 62 64 else if (name.compare("grid_definition") == 0) 63 65 { // Parsing pour la définition des grilles. 66 INFO("Le parsing des définitions de grilles n'est pas encore implémenté"); 64 67 } 65 68 else … … 75 78 return; 76 79 } 77 78 void registerAllAttributes(void)79 { /* Ne rien faire de plus */ }80 80 81 81 virtual const char* getName(void) const {return ("Context"); } -
XMLIO_V2/dev/dev_rv/field.hpp
r91 r95 3 3 4 4 using XMLIOSERVER::XML::XMLNode; 5 using XMLIOSERVER::XML::THashAttributes; 5 6 6 7 namespace XMLIOSERVER 7 8 { 8 class Field : public ObjectTemplate<Field> 9 class Field : public ObjectTemplate<Field>, public FieldAttribut 9 10 { 10 11 public: 11 Field(void) : ObjectTemplate<Field>() 12 Field(void) : ObjectTemplate<Field>(), FieldAttribut() 12 13 {/* Ne rien faire de plus */} 13 Field(const string& _id) : ObjectTemplate<Field>(_id) 14 Field(const string& _id) : ObjectTemplate<Field>(_id), FieldAttribut() 14 15 {/* Ne rien faire de plus */} 16 17 void setAttributes(const THashAttributes& attr) 18 { 19 for (THashAttributes::ConstIterator it = attr.begin(); it != attr.end(); it++) 20 if ((*it).first.compare(string("id"))) // Non prise en compte de l'identifiant lors de l'affectation des attributs. 21 this->setSAttribut((*it).first, (*it).second); 22 23 return; 24 } 15 25 16 26 virtual const char* getName(void) const {return ("Field"); } … … 18 28 void parse (XMLNode& _node) 19 29 { 30 string name = _node.getElementName(); 31 THashAttributes attributes; 32 20 33 /// PARSING GESTION DES ATTRIBUTS /// 21 // A compléter. 34 _node.getAttributes(attributes); 35 this->setAttributes(attributes); 36 attributes.clear(); 22 37 23 38 /// PARSING POUR GESION DES ENFANTS -
XMLIO_V2/dev/dev_rv/field_attribut.hpp
r91 r95 19 19 DECLARE_ATTR(level, int) ; 20 20 DECLARE_ATTR(prec, int) ; 21 22 DECLARE_ATTR(src, string) ; // TEMPORAIRE, pour fieldgroup uniquement 21 23 22 24 DECLARE_ATTR(enabled, bool); … … 28 30 29 31 FieldAttribut(void) 30 { /* Ne rien faire de plus */ } 31 32 // TODO Peut-être définir un constructeur par copie au lieu de registerAllAttributes (éventuellement) 33 34 virtual void registerAllAttributes(void) 32 { registerAllAttributes(); } 33 34 void registerAllAttributes(void) 35 35 { 36 36 RegisterAttribut(&name) ; … … 38 38 RegisterAttribut(&unit) ; 39 39 RegisterAttribut(&operation); 40 41 RegisterAttribut(&src);// TEMPORAIRE, pour fieldgroup uniquement 40 42 41 43 RegisterAttribut(&freq_op) ; -
XMLIO_V2/dev/dev_rv/field_group.hpp
r94 r95 31 31 string name = _node.getElementName(); 32 32 THashAttributes attributes; 33 std::cout << "Traitement de " << name << std::endl;34 33 35 34 /// PARSING GESTION DES ATTRIBUTS /// … … 52 51 if (name.compare("field_group") == 0) 53 52 { // Parsing pour les groupes de champs 53 54 FieldGroup* fgroup = NULL; 54 55 55 56 if (attributes.end() != attributes.find("id")) … … 57 58 if (FieldGroup::HasObject(attributes["id"])) 58 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 59 FieldGroup*fgroup =(FieldGroup*)&createGroup(attributes["id"]);60 fgroup =(FieldGroup*)&createGroup(attributes["id"]); 60 61 fgroup->parse(_node); 61 62 } 62 /*else 63 this->createGroup();*/ 64 63 else 64 {// Si l'identifiant n'est pas défini. 65 fgroup = (FieldGroup*)&createGroup(); 66 fgroup->parse(_node); 67 } 65 68 66 69 continue; … … 70 73 { // Parsing pour les champs 71 74 75 Field* field = NULL; 76 72 77 if (attributes.end() != attributes.find("id")) 78 {// Si l'identifiant est défini. 73 79 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 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; 75 91 } 76 92 else -
XMLIO_V2/dev/dev_rv/xmlio.hpp
r94 r95 24 24 #include "xmlio_logger.hpp" 25 25 #include "xmlio_container.hpp" 26 27 // Concernant les attributs ...28 29 26 #include "xmlio_object.hpp" 30 27 #include "xmlio_xml_node.hpp" -
XMLIO_V2/dev/dev_rv/xmlio_c_interface.cpp
r88 r95 2 2 { // Début du code C 3 3 4 using namespace XMLIOSERVER;5 using namespace XMLIOSERVER::XML;6 using namespace std;4 //using namespace XMLIOSERVER; 5 //using namespace XMLIOSERVER::XML; 6 //using namespace std; 7 7 8 8 typedef void *XMLIOhandle; -
XMLIO_V2/dev/dev_rv/xmlio_container.hpp
r91 r95 19 19 template<class Key, class Mapped, class HashFunc = Hash<Key> > 20 20 class ExHashMap 21 : private HashMap<Key, Mapped , Hash<Key> >21 : private HashMap<Key, Mapped*, Hash<Key> > 22 22 { 23 23 public : 24 ExHashMap() : HashMap<Key, Mapped , Hash<Key> >(), _elemList()24 ExHashMap() : HashMap<Key, Mapped*, Hash<Key> >(), _elemList() 25 25 {/* Ne rien faire de plus */} 26 26 27 Mapped &operator[] (const Key& kval) throw (XMLIOUndefinedValueException)27 Mapped* operator[] (const Key& kval) throw (XMLIOUndefinedValueException) 28 28 { 29 29 if(!hasMappedValue(kval)) … … 44 44 protected : 45 45 46 bool addValue(const Key& kval, Mapped &element)46 bool addValue(const Key& kval, Mapped* element) 47 47 { 48 48 pair<typename ExHashMap::Iterator,bool> p = this->insert(make_pair (kval,element)); … … 51 51 } 52 52 53 bool addValue(Mapped &element)54 { this->_elemList.insert(this->_elemList.end(), &element); return (true); }53 bool addValue(Mapped* element) 54 { this->_elemList.insert(this->_elemList.end(), element); return (true); } 55 55 56 56 57 void removeValue(const Key& kval) 58 { Mapped & element = find(kval)->second; removeValue(element); this->erase(kval);}57 void removeValue(const Key& kval) // Non testé 58 { Mapped* element = find(kval)->second; removeValue(element); this->erase(kval); } 59 59 60 void removeValue(const Mapped & element)60 void removeValue(const Mapped* element) // Non testé 61 61 { 62 62 for (int i = 0; i < this->_elemList.size(); i++) 63 if (*this->_elemList[i] == element ) this->_elemList.erase(this->_elemList.begin()+i); 63 if (*this->_elemList[i] == element ) 64 this->_elemList.erase(this->_elemList.begin()+i); 65 66 delete element; 64 67 } 65 68 … … 80 83 {/* Ne rien faire de plus */} 81 84 82 bool addObject(Mapped& element) 83 { if(element.hasId()) return(addValue(element.getId(), element)); return(addValue(element)); } 84 85 bool addPtrObject(Mapped element) 85 bool addObject(Mapped* element) 86 86 { if(element->hasId()) return(addValue(element->getId(), element)); return(addValue(element)); } 87 87 88 88 bool removeObject(const string& kval) 89 89 { -
XMLIO_V2/dev/dev_rv/xmlio_group_template.hpp
r94 r95 20 20 GroupTemplate<T, U>& createGroup(const string _id) throw (XMLIOUndefinedValueException) 21 21 { 22 GroupTemplate<T, U> ::CreateObject(_id);23 // groupList.addPtrObject(&obj);// Foireux22 GroupTemplate<T, U> &obj = GroupTemplate<T, U>::CreateObject(_id); 23 groupList.addObject(&obj); 24 24 25 25 return (GroupTemplate<T, U>::GetObject(_id)); … … 29 29 { 30 30 GroupTemplate<T, U>& obj = GroupTemplate<T, U>::CreateObject(); 31 //groupList.addPtrObject(&obj); // Foireux31 groupList.addObject(&obj); 32 32 33 33 return (obj); … … 46 46 { 47 47 T& obj = ObjectTemplate<T>::CreateObject(_id); 48 childList.add PtrObject(&obj);48 childList.addObject(&obj); 49 49 return (obj); 50 50 } … … 53 53 { 54 54 T& obj = ObjectTemplate<T>::CreateObject(); 55 childList.add PtrObject(&obj);55 childList.addObject(&obj); 56 56 return (obj); 57 57 } … … 71 71 72 72 private: 73 StrHashMap<T *> childList;74 StrHashMap<GroupTemplate<T, U> *> groupList;73 StrHashMap<T> childList; 74 StrHashMap<GroupTemplate<T, U> > groupList; 75 75 76 76 }; // class GroupTemplate -
XMLIO_V2/dev/dev_rv/xmlio_logger.hpp
r94 r95 3 3 4 4 // Entête Poco logging 5 #include "Poco/Logger.h"6 #include "Poco/PatternFormatter.h"7 #include "Poco/FormattingChannel.h"8 #include "Poco/ConsoleChannel.h"9 #include "Poco/FileChannel.h"10 #include "Poco/Message.h"5 #include <Poco/Logger.h> 6 #include <Poco/PatternFormatter.h> 7 #include <Poco/FormattingChannel.h> 8 #include <Poco/ConsoleChannel.h> 9 #include <Poco/FileChannel.h> 10 #include <Poco/Message.h> 11 11 12 12 // Classes utilisées issues de Poco … … 53 53 #define ERROR(MSG) (ILogger::GetConsoleLogger().error(MSG)) 54 54 #define WARNING(MSG) (ILogger::GetConsoleLogger().warning(MSG)) 55 #define INFO(MSG) (ILogger::GetConsoleLogger().information(MSG)) 55 56 // A compléter. 56 57 -
XMLIO_V2/dev/dev_rv/xmlio_object_template.hpp
r94 r95 22 22 return (ObjectTemplate<T>::GetObject(_id)); 23 23 24 // Ajout d'un nouvel objet si l'identifiant n'est pas répertorié. 25 T identified_object(_id); 26 27 ObjectTemplate<T>::AllListObj[CurrContext].addObject(identified_object); 28 ObjectTemplate<T>::GetObject(_id).registerAllAttributes(); 24 // Ajout d'un nouvel objet si l'identifiant n'est pas répertorié. 25 ObjectTemplate<T>::AllListObj[CurrContext].addObject(new T(_id)); 29 26 30 27 return (ObjectTemplate<T>::GetObject(_id)); … … 33 30 static T& CreateObject(void) 34 31 { 35 ObjectTemplate<T>::AllListObj[CurrContext].addObject(*(new T)); //<< Perte mémoire ici 36 return (*(ObjectTemplate<T>::AllListObj[CurrContext].getVector()[ObjectTemplate<T>::AllListObj[CurrContext].getVectorSize()-1])); 32 T* value = new T; 33 ObjectTemplate<T>::AllListObj[CurrContext].addObject(value); //<< Perte mémoire ici 34 return (*value); 37 35 } 38 36 39 37 static T& GetObject(const string _id) throw (XMLIOUndefinedValueException) 40 { return ( ObjectTemplate<T>::AllListObj[CurrContext][_id]); }38 { return (*ObjectTemplate<T>::AllListObj[CurrContext][_id]); } 41 39 42 40 static bool HasObject(const string _id) … … 47 45 static void SetContext(const string& id) 48 46 { ObjectTemplate<T>::CurrContext = id; } 47 48 static string& GetCurrentContextId(void) { return (CurrContext); } 49 49 50 50 virtual const char* getName(void) const {return ("ObjectTemplate"); } -
XMLIO_V2/dev/dev_rv/xmlio_xml_parser.hpp
r94 r95 43 43 XMLNode node = XMLNode::CreateNode(istr); 44 44 XMLParser::Parse(node); 45 log << "Nombre de contexts listés : " << Context::GetCurrentListObject().getSize() << " contre 2 attendus."<< std::endl; 46 log << "Nombre de contexts listés : " << FieldGroup::GetCurrentListObject().getSize() << " contre 1 attendus."<< std::endl; 45 log << "Nombre de Contexts listés : " << Context::GetCurrentListObject().getSize() << " contre 2 attendus."<< std::endl; 46 log << "Nombre de FieldGroups listés : " << FieldGroup::GetCurrentListObject().getSize() << " contre 5 attendus."<< std::endl; 47 log << "Description du champs votkeavt : " << Field::GetObject("votkeavt").description << " contre \"Vertical Eddy Diffusivity\" attendus."<< std::endl; 48 47 49 log << "Test XMLParser ... ok !" << std::endl; 48 50 return (true);
Note: See TracChangeset
for help on using the changeset viewer.