source: XMLIO_V2/dev/dev_rv/src/XMLIO/xmlio_group_template.hpp @ 104

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

Prise en charge de l'héritage descendant.
Travail sur les flux de sortie.
Correction de divers problÚmes.
Ajout d'une macro à BaseAttribut?.

File size: 3.2 KB
Line 
1#ifndef __XMLIO_GROUP_TEMPLATE__
2#define __XMLIO_GROUP_TEMPLATE__
3
4namespace XMLIOSERVER
5{
6   template <class T, class U>
7      class GroupTemplate : public ObjectTemplate<GroupTemplate<T, U> >, public U
8   {
9      public:
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 */}           
15     
16         /// Pour les groupes d'objets enfants ///
17         
18         GroupTemplate<T, U>& createGroup(const string _id) throw (XMLIOUndefinedValueException) 
19         {
20            GroupTemplate<T, U> &obj = GroupTemplate<T, U>::CreateObject(_id);
21            groupList.addObject(&obj);
22             
23            return (GroupTemplate<T, U>::GetObject(_id));
24         }
25         
26         XML::XMLNode getNodeIncludedFile(const string& path, const string& _rootName)
27         {
28            ifstream istr( path.c_str() , ifstream::in );
29            return XML::XMLNode::CreateNode(istr, _rootName);
30         }
31         
32         GroupTemplate<T, U>& createGroup(void)
33         {
34            GroupTemplate<T, U>& obj = GroupTemplate<T, U>::CreateObject();
35            groupList.addObject(&obj);
36                     
37            return (obj);
38         }
39         
40         GroupTemplate<T, U>& getGroup(const string _id) throw (XMLIOUndefinedValueException) { return (*groupList[_id]); }
41         bool hasGroup(const string _id) { return (groupList.hasMappedValue(_id)); }
42         
43         const StrHashMap<GroupTemplate<T, U>* >& getGroupList(void) { return (groupList); }
44         
45         size_t getNbGroup() const {return (groupList.getVectorSize()); }
46         
47         /// Pour les objets enfants ///
48         
49         T& createChild(const string _id) throw (XMLIOUndefinedValueException) 
50         {
51            T& obj = ObjectTemplate<T>::CreateObject(_id);
52            childList.addObject(&obj);
53            return (obj);
54         }
55         
56         T& createChild(void)
57         {
58            T& obj = ObjectTemplate<T>::CreateObject();
59            childList.addObject(&obj);           
60            return (obj);
61         }         
62         
63         T& getChild(const string _id) throw (XMLIOUndefinedValueException) { return (*childList[_id]); }
64         bool hasChild(const string _id) { return (childList.hasMappedValue(_id)); }
65         
66         const StrHashMap<T*>& getCurrentListChild(void) { return (childList); }
67         
68         size_t getNbChild() const {return (childList.getVectorSize()); }
69           
70       
71         virtual ~GroupTemplate()
72         {
73            for (unsigned int i = 0; i < childList.getVector().size(); i++)
74               delete childList.getVector()[i];
75            for (unsigned int i = 0; i < groupList.getVector().size(); i++)
76               delete groupList.getVector()[i];
77         }
78         
79      protected:
80     
81         StrHashMap<T> childList;
82         StrHashMap<GroupTemplate<T, U> > groupList;
83
84   }; // class GroupTemplate
85   
86   
87   
88}// namespace XMLIOSERVER
89
90
91#endif // __XMLIO_GROUP_TEMPLATE__
Note: See TracBrowser for help on using the repository browser.