source: XMLIO_V2/dev/dev_rv/xmlio_group_template.hpp @ 91

Last change on this file since 91 was 91, checked in by hozdoba, 13 years ago

Corrections de plusieurs problÚmes.

File size: 2.8 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> >(), childList(), groupList(), U()
12         {/* Ne rien faire de plus */}               
13         GroupTemplate(const string& _id) : ObjectTemplate<GroupTemplate<T, U> >(_id), childList(), groupList(), U()
14         {/* Ne rien faire de plus */}           
15     
16         virtual const char* getName(void) const {return ("GroupTemplate"); }
17         
18         /// Pour les groupes d'objets enfants ///
19         
20         GroupTemplate<T, U>& createGroup(const string _id) throw (XMLIOUndefinedValueException) 
21         {
22            GroupTemplate<T, U>& obj = GroupTemplate<T, U>::CreateObject(_id);
23            groupList.addPtrObject(&obj);
24            return (obj);
25         }
26         
27         GroupTemplate<T, U>& createGroup(void)
28         {
29            GroupTemplate<T, U>& obj = GroupTemplate<T, U>::CreateObject();
30            groupList.addPtrObject(&obj);           
31            return (obj);
32         }
33         
34         GroupTemplate<T, U>& getGroup(const string _id) throw (XMLIOUndefinedValueException) { return (*groupList[_id]); }
35         bool hasGroup(const string _id) { return (groupList.hasMappedValue(_id)); }
36         
37         const StrHashMap<GroupTemplate<T, U>* >& getGroupList(void) { return (groupList); }
38         
39         size_t getNbGroup() const {return (groupList.getVectorSize()); }
40         
41         /// Pour les objets enfants ///
42         
43         T& createChild(const string _id) throw (XMLIOUndefinedValueException) 
44         {
45            T& obj = ObjectTemplate<T>::CreateObject(_id);
46            childList.addPtrObject(&obj);
47            return (obj);
48         }
49         
50         T& createChild(void)
51         {
52            T& obj = ObjectTemplate<T>::CreateObject();
53            childList.addPtrObject(&obj);           
54            return (obj);
55         }         
56         
57         T& getChild(const string _id) throw (XMLIOUndefinedValueException) { return (*childList[_id]); }
58         bool hasChild(const string _id) { return (childList.hasMappedValue(_id)); }
59         
60         const StrHashMap<T*>& getCurrentListChild(void) { return (childList); }
61         
62         size_t getNbChild() const {return (childList.getVectorSize()); }
63           
64       
65         ~GroupTemplate()
66         {/* Ne rien faire de plus pour le moment */ }
67         
68      protected:
69     
70      private:
71         StrHashMap<T*> childList;
72         StrHashMap<GroupTemplate<T, U>* > groupList;
73
74   }; // class GroupTemplate
75   
76   
77   
78}// namespace XMLIOSERVER
79
80
81#endif // __XMLIO_GROUP_TEMPLATE__
Note: See TracBrowser for help on using the repository browser.