2828 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2929 */
3030#include " ParameterFrameworkConfiguration.h"
31- #include " XmlFileDocSource.h"
32- #include " XmlMemoryDocSink.h"
33- #include " XmlElement.h"
31+ #include " Deserializer.hpp"
32+ #include " ParameterFrameworkConfigurationXmlBinding.hpp"
3433
3534CParameterFrameworkConfiguration::CParameterFrameworkConfiguration (const std::string &configurationFile)
3635 : _bTuningAllowed(false ), _uiServerPort(0 ), _configurationFile(configurationFile)
@@ -49,14 +48,14 @@ bool CParameterFrameworkConfiguration::init(std::string &error)
4948 }
5049 _schemasLocation = _configurationFolder + " /Schemas" ;
5150
52- CXmlSerializingContext context (error);
53- CXmlFileDocSource source (_configurationFile,
54- _schemasLocation + " /ParameterFrameworkConfiguration.xsd " ,
55- " ParameterFrameworkConfiguration " ,
56- false );
57-
58- CXmlMemoryDocSink sink ( this );
59- return sink. process (source, context) ;
51+ try {
52+ core::xml::bindings::ParameterFrameworkConfigurationXmlBinding bindings{* this };
53+ core::xml::serialization::Deserializer test{_configurationFile, bindings. getBindings ()};
54+ } catch (std::runtime_error &e) {
55+ error = e. what ( );
56+ return false ;
57+ }
58+ return true ;
6059}
6160
6261// System class name
@@ -76,134 +75,3 @@ uint16_t CParameterFrameworkConfiguration::getServerPort() const
7675{
7776 return _uiServerPort;
7877}
79-
80- bool CParameterFrameworkConfiguration::retrieveSettingsConfiguration (const CXmlElement &settingsNode,
81- CXmlSerializingContext& context)
82- {
83- if (settingsNode.getNbChildElements () > 2 ) {
84- context.setError (" too much settings node" );
85- return false ;
86- }
87- bool settingsChildFound = false ;
88- CXmlElement childNode;
89- CXmlElement::CChildIterator childIterator (settingsNode);
90- while (childIterator.next (childNode)) {
91- if (childNode.getType () == " ConfigurableDomainsFileLocation" ) {
92- if (!retrievePathAttribute (childNode, _settingsFile, context)) {
93- return false ;
94- }
95- settingsChildFound = true ;
96- } else if (childNode.getType () == " BinarySettingsFileLocation" ) {
97- if (!retrievePathAttribute (childNode, _binarySettingsFile, context)) {
98- return false ;
99- }
100- } else {
101- context.setError (" Unknown child" );
102- return false ;
103- }
104- }
105- if (!settingsChildFound) {
106- context.setError (" No ConfigurableDomainsFileLocation element found"
107- " for SystemClass " + _strSystemClassName);
108- return false ;
109- }
110- return true ;
111- }
112-
113- bool CParameterFrameworkConfiguration::retrievePathAttribute (const CXmlElement &xmlElement,
114- std::string &path,
115- CXmlSerializingContext& context)
116- {
117- xmlElement.getAttribute (" Path" , path);
118- if (path.empty ()) {
119- context.setError (" Empty Path attribute in element " + xmlElement.getPath ());
120- return false ;
121- }
122- if (path[0 ] != ' /' ) {
123- // Path is relative
124- path = _configurationFolder + " /" + path;
125- }
126- return true ;
127- }
128-
129- bool CParameterFrameworkConfiguration::retrievePluginsConfiguration (const CXmlElement &pluginNode,
130- CXmlSerializingContext& context)
131- {
132- CXmlElement::CChildIterator childLocation (pluginNode);
133- CXmlElement xmlPluginLocation;
134- while (childLocation.next (xmlPluginLocation)) {
135- if (!(xmlPluginLocation.getType () == " Location" )) {
136- context.setError (" pas de location" );
137- return false ;
138- }
139- // Retrieve folder
140- std::string pluginFolder;
141- pluginNode.getAttribute (" Folder" , pluginFolder);
142- if (!pluginFolder.empty ()) {
143- pluginFolder += " /" ;
144- }
145-
146- // Get Info from children
147- CXmlElement::CChildIterator childIterator (xmlPluginLocation);
148- CXmlElement xmlPluginElement;
149- while (childIterator.next (xmlPluginElement)) {
150- if (!(xmlPluginElement.getType () == " Plugin" )) {
151- context.setError (" pas de plugin" );
152- return false ;
153- }
154-
155- // Fill Plugin List
156- _plugins.push_back (pluginFolder + xmlPluginElement.getNameAttribute ());
157- }
158- }
159- return true ;
160- }
161-
162- // From IXmlSink
163- bool CParameterFrameworkConfiguration::fromXml (const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext)
164- {
165- // System class name
166- xmlElement.getAttribute (" SystemClassName" , _strSystemClassName);
167-
168- // Tuning allowed
169- xmlElement.getAttribute (" TuningAllowed" , _bTuningAllowed);
170-
171- // Server port
172- xmlElement.getAttribute (" ServerPort" , _uiServerPort);
173-
174- CXmlElement childNode;
175- CXmlElement::CChildIterator childIterator (xmlElement);
176-
177- bool structureChildFound = false ;
178- bool subsystemPluginsChildFound = false ;
179- while (childIterator.next (childNode)) {
180- if (childNode.getType () == " SubsystemPlugins" ) {
181- if (!retrievePluginsConfiguration (childNode, serializingContext)) {
182- return false ;
183- }
184- subsystemPluginsChildFound = true ;
185- } else if (childNode.getType () == " StructureDescriptionFileLocation" ) {
186- if (!retrievePathAttribute (childNode, _structureFile, serializingContext)) {
187- return false ;
188- }
189- structureChildFound = true ;
190- } else if (childNode.getType () == " SettingsConfiguration" ) {
191- if (!retrieveSettingsConfiguration (childNode, serializingContext)) {
192- return false ;
193- }
194- } else {
195- serializingContext.setError (" Unknown child" );
196- return false ;
197- }
198- }
199- if (!structureChildFound) {
200- serializingContext.setError (" No StructureDescriptionFileLocation element"
201- " found for SystemClass " + _strSystemClassName);
202- }
203- if (!subsystemPluginsChildFound) {
204- serializingContext.setError (" Parameter Framework Configuration: couldn't "
205- " find SubsystemPlugins element" );
206- }
207- return true ;
208- }
209-
0 commit comments