1 | #ifndef __XMLIO_CGroupTemplate_impl__ |
---|
2 | #define __XMLIO_CGroupTemplate_impl__ |
---|
3 | |
---|
4 | namespace xmlioserver |
---|
5 | { |
---|
6 | using namespace tree; |
---|
7 | |
---|
8 | /// ////////////////////// Définitions ////////////////////// /// |
---|
9 | |
---|
10 | template <class U, class V, class W> |
---|
11 | CGroupTemplate<U, V, W>::CGroupTemplate(void) |
---|
12 | : CObjectTemplate<V>() //, V() |
---|
13 | , childMap(), childList() |
---|
14 | , groupMap(), groupList() |
---|
15 | { /* Ne rien faire de plus */ } |
---|
16 | |
---|
17 | template <class U, class V, class W> |
---|
18 | CGroupTemplate<U, V, W>::CGroupTemplate(const StdString & id) |
---|
19 | : CObjectTemplate<V>(id) //, V() |
---|
20 | , childMap(), childList() |
---|
21 | , groupMap(), groupList() |
---|
22 | { /* Ne rien faire de plus */ } |
---|
23 | |
---|
24 | template <class U, class V, class W> |
---|
25 | CGroupTemplate<U, V, W>::~CGroupTemplate(void) |
---|
26 | { /* Ne rien faire de plus */ } |
---|
27 | |
---|
28 | template <class U, class V, class W> |
---|
29 | StdString CGroupTemplate<U, V, W>::toString(void) const |
---|
30 | { |
---|
31 | StdOStringStream oss; |
---|
32 | StdString name = (this->getId().compare(V::GetDefName()) != 0) |
---|
33 | ? V::GetName() |
---|
34 | : V::GetDefName(); |
---|
35 | |
---|
36 | oss << "< " << name << " "; |
---|
37 | if (this->hasId() && (this->getId().compare(V::GetDefName()) != 0)) |
---|
38 | oss << " id=\"" << this->getId() << "\" "; |
---|
39 | |
---|
40 | if (this->hasChild()) |
---|
41 | { |
---|
42 | oss << SuperClassAttribute::toString() << ">" << std::endl; |
---|
43 | |
---|
44 | typename std::vector<boost::shared_ptr<V> >::const_iterator |
---|
45 | itg = this->groupList.begin(), endg = this->groupList.end(); |
---|
46 | typename std::vector<boost::shared_ptr<U> >::const_iterator |
---|
47 | itc = this->childList.begin(), endc = this->childList.end(); |
---|
48 | |
---|
49 | for (; itg != endg; itg++) |
---|
50 | { |
---|
51 | boost::shared_ptr<V> group = *itg; |
---|
52 | oss << *group << std::endl; |
---|
53 | } |
---|
54 | |
---|
55 | for (; itc != endc; itc++) |
---|
56 | { |
---|
57 | boost::shared_ptr<U> child = *itc; |
---|
58 | oss << *child << std::endl; |
---|
59 | } |
---|
60 | |
---|
61 | oss << "</ " << name << " >"; |
---|
62 | } |
---|
63 | else |
---|
64 | { |
---|
65 | oss << SuperClassAttribute::toString() << "/>"; |
---|
66 | } |
---|
67 | return (oss.str()); |
---|
68 | } |
---|
69 | |
---|
70 | template <class U, class V, class W> |
---|
71 | void CGroupTemplate<U, V, W>::fromString(const StdString & str) |
---|
72 | { |
---|
73 | ERROR("CGroupTemplate<U, V, W>::toString(void)", |
---|
74 | << "[ str = " << str << "] Not implemented yet !"); |
---|
75 | } |
---|
76 | |
---|
77 | template <class U, class V, class W> |
---|
78 | StdString CGroupTemplate<U, V, W>::GetName(void) |
---|
79 | { |
---|
80 | return (U::GetName().append("_group")); |
---|
81 | } |
---|
82 | |
---|
83 | template <class U, class V, class W> |
---|
84 | StdString CGroupTemplate<U, V, W>::GetDefName(void) |
---|
85 | { |
---|
86 | return (U::GetName().append("_definition")); |
---|
87 | } |
---|
88 | |
---|
89 | template <class U, class V, class W> |
---|
90 | const std::vector<boost::shared_ptr<U> >& |
---|
91 | CGroupTemplate<U, V, W>::getChildList(void) const |
---|
92 | { |
---|
93 | return (this->childList); |
---|
94 | } |
---|
95 | |
---|
96 | template <class U, class V, class W> |
---|
97 | const xios_map<StdString, boost::shared_ptr<V> >& |
---|
98 | CGroupTemplate<U, V, W>::getGroupMap(void) const |
---|
99 | { |
---|
100 | return (this->groupList); |
---|
101 | } |
---|
102 | |
---|
103 | template <class U, class V, class W> |
---|
104 | bool CGroupTemplate<U, V, W>::hasChild(void) const |
---|
105 | { |
---|
106 | return ((groupList.size() + childList.size()) > 0); |
---|
107 | } |
---|
108 | |
---|
109 | template <class U, class V, class W> |
---|
110 | void CGroupTemplate<U, V, W>::parse(xml::CXMLNode & node) |
---|
111 | { |
---|
112 | this->parse(node, true); |
---|
113 | } |
---|
114 | |
---|
115 | template <class U, class V, class W> |
---|
116 | void CGroupTemplate<U, V, W>::solveDescInheritance(const CAttributeMap * const parent) |
---|
117 | { |
---|
118 | if (parent != NULL) |
---|
119 | SuperClassAttribute::setAttributes(parent); |
---|
120 | |
---|
121 | typename std::vector<boost::shared_ptr<U> >::const_iterator |
---|
122 | itc = this->childList.begin(), endc = this->childList.end(); |
---|
123 | typename std::vector<boost::shared_ptr<V> >::const_iterator |
---|
124 | itg = this->groupList.begin(), endg = this->groupList.end(); |
---|
125 | |
---|
126 | for (; itc != endc; itc++) |
---|
127 | { |
---|
128 | boost::shared_ptr<U> child = *itc; |
---|
129 | child->solveDescInheritance(this); |
---|
130 | } |
---|
131 | |
---|
132 | for (; itg != endg; itg++) |
---|
133 | { |
---|
134 | boost::shared_ptr<V> group = *itg; |
---|
135 | group->solveRefInheritance(); |
---|
136 | group->solveDescInheritance(this); |
---|
137 | } |
---|
138 | } |
---|
139 | |
---|
140 | template <class U, class V, class W> |
---|
141 | void CGroupTemplate<U, V, W>::getAllChildren(std::vector<boost::shared_ptr<U> > & allc) const |
---|
142 | { |
---|
143 | allc.insert (allc.end(), childList.begin(), childList.end()); |
---|
144 | typename std::vector<boost::shared_ptr<V> >::const_iterator |
---|
145 | itg = this->groupList.begin(), endg = this->groupList.end(); |
---|
146 | |
---|
147 | for (; itg != endg; itg++) |
---|
148 | { |
---|
149 | boost::shared_ptr<V> group = *itg; |
---|
150 | group->getAllChildren(allc); |
---|
151 | } |
---|
152 | } |
---|
153 | |
---|
154 | template <class U, class V, class W> |
---|
155 | std::vector<boost::shared_ptr<U> > CGroupTemplate<U, V, W>::getAllChildren(void) const |
---|
156 | { |
---|
157 | std::vector<boost::shared_ptr<U> > allc; |
---|
158 | this->getAllChildren(allc); |
---|
159 | return (allc); |
---|
160 | } |
---|
161 | |
---|
162 | template <class U, class V, class W> |
---|
163 | void CGroupTemplate<U, V, W>::solveRefInheritance(void) |
---|
164 | { /* Ne rien faire de plus */ } |
---|
165 | |
---|
166 | } // namespace xmlioserver |
---|
167 | |
---|
168 | |
---|
169 | #endif // __XMLIO_CGroupTemplate_impl__ |
---|