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

Last change on this file since 94 was 94, checked in by hozdoba, 14 years ago
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> >(),  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         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>::CreateObject(_id);
23           // groupList.addPtrObject(&obj);// Foireux
24             
25            return (GroupTemplate<T, U>::GetObject(_id));
26         }
27         
28         GroupTemplate<T, U>& createGroup(void)
29         {
30            GroupTemplate<T, U>& obj = GroupTemplate<T, U>::CreateObject();
31            //groupList.addPtrObject(&obj); // Foireux
32                     
33            return (obj);
34         }
35         
36         GroupTemplate<T, U>& getGroup(const string _id) throw (XMLIOUndefinedValueException) { return (*groupList[_id]); }
37         bool hasGroup(const string _id) { return (groupList.hasMappedValue(_id)); }
38         
39         const StrHashMap<GroupTemplate<T, U>* >& getGroupList(void) { return (groupList); }
40         
41         size_t getNbGroup() const {return (groupList.getVectorSize()); }
42         
43         /// Pour les objets enfants ///
44         
45         T& createChild(const string _id) throw (XMLIOUndefinedValueException) 
46         {
47            T& obj = ObjectTemplate<T>::CreateObject(_id);
48            childList.addPtrObject(&obj);
49            return (obj);
50         }
51         
52         T& createChild(void)
53         {
54            T& obj = ObjectTemplate<T>::CreateObject();
55            childList.addPtrObject(&obj);           
56            return (obj);
57         }         
58         
59         T& getChild(const string _id) throw (XMLIOUndefinedValueException) { return (*childList[_id]); }
60         bool hasChild(const string _id) { return (childList.hasMappedValue(_id)); }
61         
62         const StrHashMap<T*>& getCurrentListChild(void) { return (childList); }
63         
64         size_t getNbChild() const {return (childList.getVectorSize()); }
65           
66       
67         ~GroupTemplate()
68         {/* Ne rien faire de plus pour le moment */ }
69         
70      protected:
71     
72      private:
73         StrHashMap<T*> childList;
74         StrHashMap<GroupTemplate<T, U>* > groupList;
75
76   }; // class GroupTemplate
77   
78   
79   
80}// namespace XMLIOSERVER
81
82
83#endif // __XMLIO_GROUP_TEMPLATE__
Note: See TracBrowser for help on using the repository browser.