Changeset 126 for XMLIO_V2/dev/dev_rv/src/XMLIO/group_template.hpp
- Timestamp:
- 10/07/10 10:29:38 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XMLIO_V2/dev/dev_rv/src/XMLIO/group_template.hpp
r122 r126 9 9 public: 10 10 11 GroupTemplate(void) : ObjectTemplate<GroupTemplate<T, U> >(), U(), childList(), groupList() 12 {/* Ne rien faire de plus */} 13 GroupTemplate(const string& _id) : ObjectTemplate<GroupTemplate<T, U> >(_id), U(), childList(), groupList() 14 {/* Ne rien faire de plus */} 11 GroupTemplate(void) 12 : ObjectTemplate<GroupTemplate<T, U> >(), U(), childList(), groupList() 13 { /* Ne rien faire de plus */ } 14 15 GroupTemplate(const string& _id) 16 : ObjectTemplate<GroupTemplate<T, U> >(_id), U(), childList(), groupList() 17 { /* Ne rien faire de plus */ } 15 18 16 19 /// Pour les groupes d'objets enfants /// 17 20 18 static string GetName(void) {return (T::GetName().append("_group")); } 19 static string GetDefName(void) {return (T::GetName().append("_definition")); } 21 GroupTemplate<T, U>& createGroup(const string& _id) 22 throw (XMLIOUndefinedValueException) 23 { 24 GroupTemplate<T, U> &obj = *GroupTemplate<T, U>::CreateObject(_id); 25 groupList.addObject(&obj); 26 27 return (obj); 28 } 29 30 GroupTemplate<T, U>& createGroup(void) 31 { 32 GroupTemplate<T, U>& obj = *(GroupTemplate<T, U>::CreateObject()); 33 groupList.addObject(&obj); 34 35 return (obj); 36 } 37 38 GroupTemplate<T, U>& getGroup(const string& _id) const 39 throw (XMLIOUndefinedValueException) 40 { return (*groupList[_id]); } 41 42 bool hasGroup(const string& _id) const { return (groupList.hasMappedValue(_id)); } 43 44 const StrHashMap<GroupTemplate<T, U>* >& getGroupList(void) const { return (groupList); } 45 46 size_t getNbGroup() const {return (groupList.getVectorSize()); } 47 48 /// Pour les objets enfants /// 49 50 T& createChild(const string& _id) 51 throw (XMLIOUndefinedValueException) 52 { 53 T& obj = *ObjectTemplate<T>::CreateObject(_id); 54 childList.addObject(&obj); 55 return (obj); 56 } 57 58 T& createChild(void) 59 { 60 T& obj = *ObjectTemplate<T>::CreateObject(); 61 childList.addObject(&obj); 62 return (obj); 63 } 64 65 T& getChild(const string& _id) const 66 throw (XMLIOUndefinedValueException) 67 { return (*childList[_id]); } 68 69 bool hasChild(const string& _id) const { return (childList.hasMappedValue(_id)); } 70 71 const StrHashMap<T*> & getCurrentListChild (void) const { return (childList); } 72 const std::vector<T*>& getCurrentVectorChild(void) const { return (childList.getVector()); } 73 74 size_t getNbChild() const {return (childList.getVectorSize()); } 75 76 void getAllChildren(std::vector<T*>& _allc ) const 77 { 78 const vector<GroupTemplate<T, U>*>& groupvect = groupList.getVector(); 79 _allc.insert (_allc.end(), getCurrentVectorChild().begin(), getCurrentVectorChild().end()); 80 81 for(unsigned int i = 0; i < groupvect.size() ; i++) 82 groupvect[i] -> getAllChildren(_allc); 83 } 84 85 public : /* static */ 86 87 static string GetName(void) { return (T::GetName().append("_group")); } 88 static string GetDefName(void) { return (T::GetName().append("_definition")); } 89 90 public : /* virtual */ 91 92 virtual ~GroupTemplate() 93 { 94 for (unsigned int i = 0; i < childList.getVector().size(); i++) 95 delete childList.getVector()[i]; 96 for (unsigned int i = 0; i < groupList.getVector().size(); i++) 97 delete groupList.getVector()[i]; 98 } 20 99 21 100 virtual bool hasChild(void) const { return ((getNbGroup() + getNbChild())>0); } … … 35 114 const vector<GroupTemplate<T, U>*>& groupvect = groupList.getVector(); 36 115 37 // On complÚte les propres attributs du groupe .38 if (_parent != NULL) AttributRegistrar::addAttributes(*_parent);116 // On complÚte les propres attributs du groupe avec ceux du parent. 117 if (_parent != NULL) AttributRegistrar::addAttributes(*_parent); 39 118 40 119 for(unsigned int i = 0; i < childvect.size() ; i++) … … 45 124 // on complÚte les attributs des groupes enfants. 46 125 groupvect[i] -> resolveDescInheritance(this); 47 }48 49 GroupTemplate<T, U>& createGroup(const string& _id) throw (XMLIOUndefinedValueException)50 {51 GroupTemplate<T, U> &obj = *GroupTemplate<T, U>::CreateObject(_id);52 groupList.addObject(&obj);53 54 return (obj);55 }56 57 GroupTemplate<T, U>& createGroup(void)58 {59 GroupTemplate<T, U>& obj = *(GroupTemplate<T, U>::CreateObject());60 groupList.addObject(&obj);61 62 return (obj);63 }64 65 GroupTemplate<T, U>& getGroup(const string& _id) throw (XMLIOUndefinedValueException) { return (*groupList[_id]); }66 bool hasGroup(const string _id) { return (groupList.hasMappedValue(_id)); }67 68 const StrHashMap<GroupTemplate<T, U>* >& getGroupList(void) const { return (groupList); }69 70 size_t getNbGroup() const {return (groupList.getVectorSize()); }71 72 /// Pour les objets enfants ///73 74 T& createChild(const string& _id) throw (XMLIOUndefinedValueException)75 {76 T& obj = *ObjectTemplate<T>::CreateObject(_id);77 childList.addObject(&obj);78 return (obj);79 }80 81 T& createChild(void)82 {83 T& obj = *ObjectTemplate<T>::CreateObject();84 childList.addObject(&obj);85 return (obj);86 }87 88 T& getChild(const string& _id) throw (XMLIOUndefinedValueException) { return (*childList[_id]); }89 bool hasChild(const string& _id) { return (childList.hasMappedValue(_id)); }90 91 const StrHashMap<T*>& getCurrentListChild(void) const { return (childList); }92 const vector<T*>& getCurrentVectorChild(void) const { return (childList.getVector()); }93 94 size_t getNbChild() const {return (childList.getVectorSize()); }95 96 void getAllChildren(std::vector<T*>& _allc )97 {98 const vector<GroupTemplate<T, U>*>& groupvect = groupList.getVector();99 _allc.insert (_allc.end(), getCurrentVectorChild().begin(), getCurrentVectorChild().end());100 101 for(unsigned int i = 0; i < groupvect.size() ; i++)102 groupvect[i] -> getAllChildren(_allc);103 }104 105 virtual ~GroupTemplate()106 {107 for (unsigned int i = 0; i < childList.getVector().size(); i++)108 delete childList.getVector()[i];109 for (unsigned int i = 0; i < groupList.getVector().size(); i++)110 delete groupList.getVector()[i];111 126 } 112 127 … … 158 173 {// Si l'identifiant est défini. 159 174 if (V::HasObject(attributes["id"])) 160 WARNING("Dans le context actuel, une instance de type "+V::GetName()+" nommée \""+attributes["id"]+"\" existe déjà , le second fera référence au premier par défaut !"); // TODO TODO 175 WARNING("Dans le context actuel, une instance de type "+V::GetName()+" nommée \""+attributes["id"] 176 +"\" existe déjà , le second fera référence au premier par défaut !"); // TODO TODO 161 177 instance_ptr = (V*)(&createGroup(attributes["id"])); 162 178 instance_ptr->parse(_node); … … 176 192 {// Si l'identifiant est défini. 177 193 if (V::HasObject(attributes["id"])) 178 WARNING("Dans le context actuel, une instance de type "+V::GetName()+" nommée \""+attributes["id"]+"\" existe déjà , le second fera référence au premier par défaut !"); // TODO TODO 194 WARNING("Dans le context actuel, une instance de type "+V::GetName()+" nommée \""+attributes["id"] 195 +"\" existe déjà , le second fera référence au premier par défaut !"); // TODO TODO 179 196 instance_ptr = (V*)(&createChild(attributes["id"])); 180 197 instance_ptr->parse(_node);
Note: See TracChangeset
for help on using the changeset viewer.