• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2011-2016, Intel Corporation
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without modification,
6  * are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice, this
9  * list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation and/or
13  * other materials provided with the distribution.
14  *
15  * 3. Neither the name of the copyright holder nor the names of its contributors
16  * may be used to endorse or promote products derived from this software without
17  * specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
23  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 #pragma once
31 
32 #include <mutex>
33 #include <map>
34 #include <vector>
35 #include "RemoteCommandHandlerTemplate.h"
36 #include "PathNavigator.h"
37 #include "SelectionCriterionType.h"
38 #include "SelectionCriterion.h"
39 #include "Element.h"
40 #include "XmlDocSink.h"
41 #include "XmlDocSource.h"
42 #include "XmlDomainExportContext.h"
43 #include "Results.h"
44 #include "ElementHandle.h"
45 #include <log/LogWrapper.h>
46 #include <log/Context.h>
47 
48 #include <istream>
49 #include <memory>
50 #include <ostream>
51 #include <string>
52 
53 class CElementLibrarySet;
54 class CSubsystemLibrary;
55 class CSystemClass;
56 class CSelectionCriteria;
57 class CParameterFrameworkConfiguration;
58 class CParameterBlackboard;
59 class CConfigurableDomains;
60 class IRemoteProcessorServerInterface;
61 class CParameterHandle;
62 class CSubsystemPlugins;
63 class CParameterAccessContext;
64 class CConfigurableElement;
65 
66 class CParameterMgr : private CElement
67 {
68     enum ChildElement
69     {
70         EFrameworkConfiguration,
71         ESelectionCriteria,
72         ESystemClass,
73         EConfigurableDomains
74     };
75     enum ElementLibrary
76     {
77         EFrameworkConfigurationLibrary,
78         EParameterCreationLibrary,
79         EParameterConfigurationLibrary
80     };
81 
82     // Parameter handle friendship
83     friend class ElementHandle;
84 
85 public:
86     // Construction
87     CParameterMgr(const std::string &strConfigurationFilePath, core::log::ILogger &logger);
88     ~CParameterMgr() override;
89 
90     /** Load plugins, structures and settings from the config file given.
91       *
92       * @param[out] strError is a std::string describing the error if an error occurred
93       *                      undefined otherwise.
94       *
95       * @return true if no error occurred, false otherwise.
96       */
97     bool load(std::string &strError);
98 
99     // Remote command parsers
100     using CommandHandler = std::unique_ptr<TRemoteCommandHandlerTemplate<CParameterMgr>>;
101 
102     /** Create and return a command handler for this ParameterMgr instance
103      *
104      * @returns a Command Handler
105      */
106     CommandHandler createCommandHandler();
107 
108     // Selection Criteria
109     CSelectionCriterionType *createSelectionCriterionType(bool bIsInclusive);
110     CSelectionCriterion *createSelectionCriterion(
111         const std::string &strName, const CSelectionCriterionType *pSelectionCriterionType);
112     // Selection criterion retrieval
113     CSelectionCriterion *getSelectionCriterion(const std::string &strName);
114 
115     // Configuration application
116     void applyConfigurations();
117 
118     /** const version of getConfigurableElement */
119     const CConfigurableElement *getConfigurableElement(const std::string &strPath,
120                                                        std::string &strError) const;
121 
122     /** Returns the CConfigurableElement corresponding to the path given in argument.
123      *
124      * @param[in] strPath A std::string representing a path to an element.
125      * @param[out] strError Error message
126      *
127      * @return A const pointer to the corresponding CConfigurableElement.
128      * On error, NULL is returned and the error is explained in strError.
129      */
130     CConfigurableElement *getConfigurableElement(const std::string &strPath, std::string &strError);
131     // Dynamic parameter handling
132     CParameterHandle *createParameterHandle(const std::string &strPath, std::string &strError);
133 
134     /** Creates a handle to a configurable element.
135      *
136      * The returned object is owned by the client who is responsible to delete it.
137      *
138      * @param[in] path A string representing a path to a configurable element.
139      * @param[out] error On error: an human readable error message
140      *                   On success: undefined
141      *
142      * @return An element handle on success
143      *         nullptr on error
144      */
145     ElementHandle *createElementHandle(const std::string &path, std::string &error);
146 
147     /** Is the remote interface forcefully disabled ?
148      */
149     bool getForceNoRemoteInterface() const;
150 
151     /**
152      * Forcefully disable the remote interface or cancel this policy
153      *
154      * @param[in] bForceNoRemoteInterface disable the remote interface if true.
155      */
156     void setForceNoRemoteInterface(bool bForceNoRemoteInterface);
157 
158     /** Should start fail in case of missing subsystems.
159       *
160       * @param[in] bFail: If set to true,  parameterMgr start will fail on missing subsystems.
161       *                   If set to false, missing subsystems will fallback on virtual subsystem.
162       */
163     void setFailureOnMissingSubsystem(bool bFail);
164 
165     /** Would start fail in case of missing subsystems.
166       *
167       * @return true if the subsystem will fail on missing subsystem, false otherwise.
168       */
169     bool getFailureOnMissingSubsystem() const;
170 
171     /** Should start fail in failed settings load.
172       *
173       * @param[in] bFail: If set to true, parameterMgr start will fail on failed settings load.
174       *                   If set to false, failed settings load will be ignored.
175       */
176     void setFailureOnFailedSettingsLoad(bool bFail);
177     /** Would start fail in case of failed settings load.
178       *
179       * @return failure on failed settings load policy state.
180       */
181     bool getFailureOnFailedSettingsLoad() const;
182 
183     /** Get the XML Schemas URI
184      *
185      * @returns the XML Schemas URI
186      */
187     const std::string &getSchemaUri() const;
188 
189     /** Override the XML Schemas URI
190      *
191      * @param[in] schemaUri XML Schemas URI
192      */
193     void setSchemaUri(const std::string &schemaUri);
194 
195     /** Should .xml files be validated on start ?
196      *
197      * @param[in] bValidate:
198      *     If set to true, parameterMgr will report an error
199      *         when being unable to validate .xml files
200      *     If set to false, no .xml/xsd validation will happen
201      *     (default behaviour)
202      *
203      * @return false if unable to set, true otherwise.
204      */
205     void setValidateSchemasOnStart(bool bValidate);
206 
207     /** Would .xml files be validated on start?
208      *
209      * @return areSchemasValidated
210      */
211     bool getValidateSchemasOnStart() const;
212 
213     //////////// Tuning /////////////
214     /**
215      * Activate / deactivate the tuning mode.
216      *
217      * @param[in] bOn true if tuning mode activation is requested, false for desactivation
218      * @param[out] strError human readable error
219      * @return true if request is successful, false if the Parameter Manager is already in the mode
220      *         requested or in case of error.
221      *         If false, strError is set with the associated human readable error.
222      */
223     bool setTuningMode(bool bOn, std::string &strError);
224     bool tuningModeOn() const;
225 
226     // Current value space for user set/get value interpretation
227     void setValueSpace(bool bIsRaw);
228     bool valueSpaceIsRaw();
229 
230     // Current Output Raw Format for user get value interpretation
231     void setOutputRawFormat(bool bIsHex);
232     bool outputRawFormatIsHex();
233 
234     // Automatic hardware synchronization control (during tuning session)
235     bool setAutoSync(bool bAutoSyncOn, std::string &strError);
236     bool autoSyncOn() const;
237     bool sync(std::string &strError);
238 
239     // User set/get parameters
240     bool accessParameterValue(const std::string &strPath, std::string &strValue, bool bSet,
241                               std::string &strError);
242     /**
243      * Returns the element mapping corresponding to the path given in parameter.
244      *
245      * @param[in] strPath Path of an element
246      * @param[out] strValue A sting containing the mapping
247      *
248      * @return true if a mapping was found for this element
249      */
250     bool getParameterMapping(const std::string &strPath, std::string &strValue) const;
251     bool accessConfigurationValue(const std::string &strDomain, const std::string &stConfiguration,
252                                   const std::string &strPath, std::string &strValue, bool bSet,
253                                   std::string &strError);
254 
255     ////////// Configuration/Domains handling //////////////
256     // Creation/Deletion
257     bool createDomain(const std::string &strName, std::string &strError);
258     bool renameDomain(const std::string &strName, const std::string &strNewName,
259                       std::string &strError);
260     bool deleteDomain(const std::string &strName, std::string &strError);
261     bool deleteAllDomains(std::string &strError);
262     bool setSequenceAwareness(const std::string &strName, bool bSequenceAware,
263                               std::string &strResult);
264     bool getSequenceAwareness(const std::string &strName, bool &bSequenceAware,
265                               std::string &strResult);
266     bool createConfiguration(const std::string &strDomain, const std::string &strConfiguration,
267                              std::string &strError);
268     bool deleteConfiguration(const std::string &strDomain, const std::string &strConfiguration,
269                              std::string &strError);
270     bool renameConfiguration(const std::string &strDomain, const std::string &strConfiguration,
271                              const std::string &strNewConfiguration, std::string &strError);
272 
273     /** Restore a configuration
274      *
275      * @param[in] strDomain the domain name
276      * @param[in] strConfiguration the configuration name
277      * @param[out] errors errors encountered during restoration
278      * @return true if success false otherwise
279      */
280     bool restoreConfiguration(const std::string &strDomain, const std::string &strConfiguration,
281                               core::Results &errors);
282 
283     bool saveConfiguration(const std::string &strDomain, const std::string &strConfiguration,
284                            std::string &strError);
285 
286     // Configurable element - domain association
287     bool addConfigurableElementToDomain(const std::string &strDomain,
288                                         const std::string &strConfigurableElementPath,
289                                         std::string &strError);
290     bool removeConfigurableElementFromDomain(const std::string &strDomain,
291                                              const std::string &strConfigurableElementPath,
292                                              std::string &strError);
293     bool split(const std::string &strDomain, const std::string &strConfigurableElementPath,
294                std::string &strError);
295     bool setElementSequence(const std::string &strDomain, const std::string &strConfiguration,
296                             const std::vector<std::string> &astrNewElementSequence,
297                             std::string &strError);
298 
299     bool getApplicationRule(const std::string &strDomain, const std::string &strConfiguration,
300                             std::string &strResult);
301     bool setApplicationRule(const std::string &strDomain, const std::string &strConfiguration,
302                             const std::string &strApplicationRule, std::string &strError);
303     bool clearApplicationRule(const std::string &strDomain, const std::string &strConfiguration,
304                               std::string &strError);
305 
306     /**
307       * Method that imports Configurable Domains from an Xml source.
308       *
309       * @param[in] xmlSource a std::string containing an xml description or a path to an xml file
310       * @param[in] withSettings a boolean that determines if the settings should be used in the
311       * xml description
312       * @param[in] fromFile a boolean that determines if the source is an xml description in
313       * xmlSource or contained in a file. In that case xmlSource is just the file path.
314       * @param[out] errorMsg is used as the error output
315       *
316       * @return false if any error occures
317       */
318     bool importDomainsXml(const std::string &xmlSource, bool withSettings, bool fromFile,
319                           std::string &errorMsg);
320 
321     /**
322       * Method that imports a single Configurable Domain from an Xml source.
323       *
324       * @param[in] xmlSource a string containing an xml description or a path to an xml file
325       * @param[in] overwrite when importing an existing domain, allow
326       * overwriting or return an error
327       * @param[in] withSettings a boolean that determines if the settings should be used in the
328       * xml description
329       * @param[in] fromFile a boolean that determines if the source is an xml description in
330       * xmlSource or contained in a file. In that case xmlSource is just the file path.
331       * @param[out] errorMsg is used as the error output
332       *
333       * @return false if any error occurs
334       */
335     bool importSingleDomainXml(const std::string &xmlSource, bool overwrite, bool withSettings,
336                                bool fromFile, std::string &errorMsg);
337 
338     /**
339       * Method that exports Configurable Domains to an Xml destination.
340       *
341       * @param[in,out] xmlDest a string containing an xml description or a path to an xml file
342       * @param[in] withSettings a boolean that determines if the settings should be used in the
343       * xml description
344       * @param[in] toFile a boolean that determines if the destination is an xml description in
345       * xmlDest or contained in a file. In that case xmlDest is just the file path.
346       * @param[out] errorMsg is used as the error output
347       *
348       * @return false if any error occurs, true otherwise.
349       */
350     bool exportDomainsXml(std::string &xmlDest, bool withSettings, bool toFile,
351                           std::string &errorMsg) const;
352 
353     /**
354       * Method that exports a given Configurable Domain to an Xml destination.
355       *
356       * @param[in,out] xmlDest a string containing an xml description or a path to an xml file
357       * @param[in] domainName the name of the domain to be exported
358       * @param[in] withSettings a boolean that determines if the settings should be used in the
359       * xml description
360       * @param[in] toFile a boolean that determines if the destination is an xml description in
361       * xmlDest or contained in a file. In that case xmlDest is just the file path.
362       * @param[out] errorMsg is used as the error output
363       *
364       * @return false if any error occurs, true otherwise.
365       */
366     bool exportSingleDomainXml(std::string &xmlDest, const std::string &domainName,
367                                bool withSettings, bool toFile, std::string &errorMsg) const;
368 
369     /**
370       * Method that exports an Xml description of the passed element into a string
371       *
372       * @param[in] pXmlSource The source element to export
373       * @param[in] strRootElementType The XML root element name of the exported instance document
374       * @param[in] xmlSerializingContext the context to use for serialization
375       *                                  Is an rvalue as it must be destructed after this function
376       *                                  call to set the error.
377       *                                  Additionally, using it for an other serialization would
378       *                                  override the error.
379       * @param[out] strResult contains the xml description or the error description in case false is
380      * returned
381       *
382       * @return true for success, false if any error occurs during the creation of the xml
383      * description (validation or encoding)
384       */
385     bool exportElementToXMLString(const IXmlSource *pXmlSource,
386                                   const std::string &strRootElementType,
387                                   CXmlSerializingContext &&xmlSerializingContext,
388                                   std::string &strResult) const;
389 
390     // CElement
391     std::string getKind() const override;
392 
393 private:
394     CParameterMgr(const CParameterMgr &);
395     CParameterMgr &operator=(const CParameterMgr &);
396 
397     // Init
398     bool init(std::string &strError) override;
399 
400     // Version
401     std::string getVersion() const;
402 
403     // This using is here for internal reasons: CommandHandler is public and is
404     // a unique_ptr but we want the type that's inside. And for legacy reason
405     // because that's the original name before a rework; this directive avoids
406     // renaming a lot of stuff.
407     using CCommandHandler = CommandHandler::element_type;
408     using RemoteCommandParser = CCommandHandler::CommandStatus (CParameterMgr::*)(
409         const IRemoteCommand &remoteCommand, std::string &strResult);
410 
411     // Parser descriptions
412     struct SRemoteCommandParserItem
413     {
414         const char *_pcCommandName;
415         CParameterMgr::RemoteCommandParser _pfnParser;
416         size_t _minArgumentCount;
417         const char *_pcHelp;
418         const char *_pcDescription;
419     };
420 
421     ////////////////:: Remote command parsers
422     /// Version
423     CCommandHandler::CommandStatus versionCommandProcess(const IRemoteCommand &remoteCommand,
424                                                          std::string &strResult);
425     /// Status
426     CCommandHandler::CommandStatus statusCommandProcess(const IRemoteCommand &remoteCommand,
427                                                         std::string &strResult);
428     /// Tuning Mode
429     CCommandHandler::CommandStatus setTuningModeCommandProcess(const IRemoteCommand &remoteCommand,
430                                                                std::string &strResult);
431     CCommandHandler::CommandStatus getTuningModeCommandProcess(const IRemoteCommand &remoteCommand,
432                                                                std::string &strResult);
433     /// Value Space
434     CCommandHandler::CommandStatus setValueSpaceCommandProcess(const IRemoteCommand &remoteCommand,
435                                                                std::string &strResult);
436     CCommandHandler::CommandStatus getValueSpaceCommandProcess(const IRemoteCommand &remoteCommand,
437                                                                std::string &strResult);
438     /// Output Raw Format
439     CCommandHandler::CommandStatus setOutputRawFormatCommandProcess(
440         const IRemoteCommand &remoteCommand, std::string &strResult);
441     CCommandHandler::CommandStatus getOutputRawFormatCommandProcess(
442         const IRemoteCommand &remoteCommand, std::string &strResult);
443     /// Sync
444     CCommandHandler::CommandStatus setAutoSyncCommandProcess(const IRemoteCommand &remoteCommand,
445                                                              std::string &strResult);
446     CCommandHandler::CommandStatus getAutoSyncCommandProcess(const IRemoteCommand &remoteCommand,
447                                                              std::string &strResult);
448     CCommandHandler::CommandStatus syncCommandProcess(const IRemoteCommand &remoteCommand,
449                                                       std::string &strResult);
450     /// Criteria
451     CCommandHandler::CommandStatus listCriteriaCommandProcess(const IRemoteCommand &remoteCommand,
452                                                               std::string &strResult);
453     /// Domains
454     CCommandHandler::CommandStatus listDomainsCommandProcess(const IRemoteCommand &remoteCommand,
455                                                              std::string &strResult);
456     CCommandHandler::CommandStatus createDomainCommandProcess(const IRemoteCommand &remoteCommand,
457                                                               std::string &strResult);
458     CCommandHandler::CommandStatus deleteDomainCommandProcess(const IRemoteCommand &remoteCommand,
459                                                               std::string &strResult);
460     CCommandHandler::CommandStatus deleteAllDomainsCommandProcess(
461         const IRemoteCommand &remoteCommand, std::string &strResult);
462     CCommandHandler::CommandStatus renameDomainCommandProcess(const IRemoteCommand &remoteCommand,
463                                                               std::string &strResult);
464     CCommandHandler::CommandStatus setSequenceAwarenessCommandProcess(
465         const IRemoteCommand &remoteCommand, std::string &strResult);
466     CCommandHandler::CommandStatus getSequenceAwarenessCommandProcess(
467         const IRemoteCommand &remoteCommand, std::string &strResult);
468     CCommandHandler::CommandStatus listDomainElementsCommandProcess(
469         const IRemoteCommand &remoteCommand, std::string &strResult);
470     CCommandHandler::CommandStatus addElementCommandProcess(const IRemoteCommand &remoteCommand,
471                                                             std::string &strResult);
472     CCommandHandler::CommandStatus removeElementCommandProcess(const IRemoteCommand &remoteCommand,
473                                                                std::string &strResult);
474     CCommandHandler::CommandStatus splitDomainCommandProcess(const IRemoteCommand &remoteCommand,
475                                                              std::string &strResult);
476     /// Configurations
477     CCommandHandler::CommandStatus listConfigurationsCommandProcess(
478         const IRemoteCommand &remoteCommand, std::string &strResult);
479     CCommandHandler::CommandStatus dumpDomainsCommandProcess(const IRemoteCommand &remoteCommand,
480                                                              std::string &strResult);
481     CCommandHandler::CommandStatus createConfigurationCommandProcess(
482         const IRemoteCommand &remoteCommand, std::string &strResult);
483     CCommandHandler::CommandStatus deleteConfigurationCommandProcess(
484         const IRemoteCommand &remoteCommand, std::string &strResult);
485     CCommandHandler::CommandStatus renameConfigurationCommandProcess(
486         const IRemoteCommand &remoteCommand, std::string &strResult);
487     CCommandHandler::CommandStatus saveConfigurationCommandProcess(
488         const IRemoteCommand &remoteCommand, std::string &strResult);
489     CCommandHandler::CommandStatus restoreConfigurationCommandProcess(
490         const IRemoteCommand &remoteCommand, std::string &strResult);
491     CCommandHandler::CommandStatus setElementSequenceCommandProcess(
492         const IRemoteCommand &remoteCommand, std::string &strResult);
493     CCommandHandler::CommandStatus getElementSequenceCommandProcess(
494         const IRemoteCommand &remoteCommand, std::string &strResult);
495     CCommandHandler::CommandStatus setRuleCommandProcess(const IRemoteCommand &remoteCommand,
496                                                          std::string &strResult);
497     CCommandHandler::CommandStatus clearRuleCommandProcess(const IRemoteCommand &remoteCommand,
498                                                            std::string &strResult);
499     CCommandHandler::CommandStatus getRuleCommandProcess(const IRemoteCommand &remoteCommand,
500                                                          std::string &strResult);
501     /// Elements/Parameters
502     CCommandHandler::CommandStatus listElementsCommandProcess(const IRemoteCommand &remoteCommand,
503                                                               std::string &strResult);
504     CCommandHandler::CommandStatus listParametersCommandProcess(const IRemoteCommand &remoteCommand,
505                                                                 std::string &strResult);
506     CCommandHandler::CommandStatus getElementStructureXMLCommandProcess(
507         const IRemoteCommand &remoteCommand, std::string &strResult);
508     CCommandHandler::CommandStatus getElementBytesCommandProcess(
509         const IRemoteCommand &remoteCommand, std::string &strResult);
510     CCommandHandler::CommandStatus setElementBytesCommandProcess(
511         const IRemoteCommand &remoteCommand, std::string &strResult);
512     CCommandHandler::CommandStatus getElementXMLCommandProcess(const IRemoteCommand &remoteCommand,
513                                                                std::string &strResult);
514     CCommandHandler::CommandStatus setElementXMLCommandProcess(const IRemoteCommand &remoteCommand,
515                                                                std::string &strResult);
516     CCommandHandler::CommandStatus dumpElementCommandProcess(const IRemoteCommand &remoteCommand,
517                                                              std::string &strResult);
518     CCommandHandler::CommandStatus getElementSizeCommandProcess(const IRemoteCommand &remoteCommand,
519                                                                 std::string &strResult);
520     CCommandHandler::CommandStatus showPropertiesCommandProcess(const IRemoteCommand &remoteCommand,
521                                                                 std::string &strResult);
522     CCommandHandler::CommandStatus getParameterCommandProcess(const IRemoteCommand &remoteCommand,
523                                                               std::string &strResult);
524     CCommandHandler::CommandStatus setParameterCommandProcess(const IRemoteCommand &remoteCommand,
525                                                               std::string &strResult);
526     CCommandHandler::CommandStatus getConfigurationParameterCommandProcess(
527         const IRemoteCommand &remoteCommand, std::string &strResult);
528     CCommandHandler::CommandStatus setConfigurationParameterCommandProcess(
529         const IRemoteCommand &remoteCommand, std::string &strResult);
530     CCommandHandler::CommandStatus listBelongingDomainsCommandProcess(
531         const IRemoteCommand &remoteCommand, std::string &strResult);
532     CCommandHandler::CommandStatus listAssociatedDomainsCommandProcess(
533         const IRemoteCommand &remoteCommand, std::string &strResult);
534     CCommandHandler::CommandStatus showMappingCommandProcess(const IRemoteCommand &remoteCommand,
535                                                              std::string &strResult);
536     /// Browse
537     CCommandHandler::CommandStatus listAssociatedElementsCommandProcess(
538         const IRemoteCommand &remoteCommand, std::string &strResult);
539     CCommandHandler::CommandStatus listConflictingElementsCommandProcess(
540         const IRemoteCommand &remoteCommand, std::string &strResult);
541     CCommandHandler::CommandStatus listRogueElementsCommandProcess(
542         const IRemoteCommand &remoteCommand, std::string &strResult);
543     /// Settings Import/Export
544     CCommandHandler::CommandStatus exportDomainsXMLCommandProcess(
545         const IRemoteCommand &remoteCommand, std::string &strResult);
546     CCommandHandler::CommandStatus importDomainsXMLCommandProcess(
547         const IRemoteCommand &remoteCommand, std::string &strResult);
548     CCommandHandler::CommandStatus exportDomainsWithSettingsXMLCommandProcess(
549         const IRemoteCommand &remoteCommand, std::string &strResult);
550     CCommandHandler::CommandStatus importDomainsWithSettingsXMLCommandProcess(
551         const IRemoteCommand &remoteCommand, std::string &strResult);
552     /**
553       * Command handler method for exportDomainWithSettingsXML command.
554       *
555       * @param[in] remoteCommand contains the arguments of the received command.
556       * @param[out] result a std::string containing the result of the command
557       *
558       * @return CCommandHandler::ESucceeded if command succeeded or CCommandHandler::EFailed
559       * in the other case
560       */
561     CCommandHandler::CommandStatus exportDomainWithSettingsXMLCommandProcess(
562         const IRemoteCommand &remoteCommand, std::string &result);
563     CCommandHandler::CommandStatus importDomainWithSettingsXMLCommandProcess(
564         const IRemoteCommand &remoteCommand, std::string &strResult);
565 
566     /**
567       * Command handler method for getDomainsWithSettings command.
568       *
569       * @param[in] remoteCommand contains the arguments of the received command.
570       * @param[out] strResult a std::string containing the result of the command
571       *
572       * @return CCommandHandler::ESucceeded if command succeeded or CCommandHandler::EFailed
573       * in the other case
574       */
575     CCommandHandler::CommandStatus getDomainsWithSettingsXMLCommandProcess(
576         const IRemoteCommand &remoteCommand, std::string &strResult);
577 
578     /**
579       * Command handler method for getDomainWithSettings command.
580       *
581       * @param[in] remoteCommand contains the arguments of the received command.
582       * @param[out] strResult a string containing the result of the command
583       *
584       * @return CCommandHandler::ESucceeded if command succeeded or CCommandHandler::EFailed
585       * in the other case
586       */
587     CCommandHandler::CommandStatus getDomainWithSettingsXMLCommandProcess(
588         const IRemoteCommand &remoteCommand, std::string &strResult);
589 
590     /**
591       * Command handler method for setDomainsWithSettings command.
592       *
593       * @param[in] remoteCommand contains the arguments of the received command.
594       * @param[out] strResult a std::string containing the result of the command
595       *
596       * @return CCommandHandler::ESucceeded if command succeeded or CCommandHandler::EFailed
597       * in the other case
598       */
599     CCommandHandler::CommandStatus setDomainsWithSettingsXMLCommandProcess(
600         const IRemoteCommand &remoteCommand, std::string &strResult);
601 
602     /**
603       * Command handler method for setDomainWithSettings command.
604       *
605       * @param[in] remoteCommand contains the arguments of the received command.
606       * @param[out] result a std::string containing the result of the command
607       *
608       * @return CCommandHandler::ESucceeded if command succeeded or CCommandHandler::EFailed
609       * in the other case
610       */
611     CCommandHandler::CommandStatus setDomainWithSettingsXMLCommandProcess(
612         const IRemoteCommand &remoteCommand, std::string &result);
613 
614     /**
615       * Command handler method for getSystemClass command.
616       *
617       * @param[in] remoteCommand contains the arguments of the received command.
618       * @param[out] strResult a std::string containing the result of the command
619       *
620       * @return CCommandHandler::ESucceeded if command succeeded or CCommandHandler::EFailed
621       * in the other case
622       */
623     CCommandHandler::CommandStatus getSystemClassXMLCommandProcess(
624         const IRemoteCommand &remoteCommand, std::string &strResult);
625 
626     // Max command usage length, use for formatting
627     void setMaxCommandUsageLength();
628 
629     // For tuning, check we're in tuning mode
630     bool checkTuningModeOn(std::string &strError) const;
631 
632     // Blackboard (dynamic parameter handling)
633     std::mutex &getBlackboardMutex();
634 
635     // Blackboard reference (dynamic parameter handling)
636     CParameterBlackboard *getParameterBlackboard();
637 
638     // Parameter access
639     bool accessValue(CParameterAccessContext &parameterAccessContext, const std::string &strPath,
640                      std::string &strValue, bool bSet, std::string &strError);
641     bool doSetValue(const std::string &strPath, const std::string &strValue, bool bRawValueSpace,
642                     bool bDynamicAccess, std::string &strError) const;
643     bool doGetValue(const std::string &strPath, std::string &strValue, bool bRawValueSpace,
644                     bool bHexOutputRawFormat, bool bDynamicAccess, std::string &strError) const;
645 
646     // Framework global configuration loading
647     bool loadFrameworkConfiguration(std::string &strError);
648 
649     /** Load required subsystems
650      *
651      * @param[out] error error description if there is one
652      * @return true if succeed false otherwise
653      */
654     bool loadSubsystems(std::string &error);
655 
656     // System class Structure loading
657     bool loadStructure(std::string &strError);
658 
659     // System class Structure loading
660     bool loadSettings(std::string &strError);
661     bool loadSettingsFromConfigFile(std::string &strError);
662 
663     /** Get settings from a configurable element in binary format.
664      *
665      * @param[in] element configurable element.
666      * @param[out] settings current element settings (in mainblackboard) in binary format
667      *
668      * @return true on success, false on error
669      */
670     void getSettingsAsBytes(const CConfigurableElement &element,
671                             std::vector<uint8_t> &settings) const;
672 
673     /** Assign settings to a configurable element in binary format.
674      *
675      * @param[in] element configurable element.
676      * @param[in] settings the settings as byte array (binary).
677      * @param[out] error error message filled in case of error
678      *
679      * @return true in case of success, false oherwise, in which case error is filled with error
680      * message.
681      */
682     bool setSettingsAsBytes(const CConfigurableElement &element,
683                             const std::vector<uint8_t> &settings, std::string &error);
684 
685     /** Assign settings to a configurable element in XML format.
686      *
687      * @param[in] configurableElement The element to set.
688      * @param[in] settings The settings to set.
689      * @param[out] error human readable error message filled in case of error,
690      *                   undefined in case of success.
691      * @return true in case of success, false otherwise
692      */
693     bool setSettingsAsXML(CConfigurableElement *configurableElement, const std::string &settings,
694                           std::string &error);
695 
696     /** Get settings from a configurable element in XML format.
697      *
698      * @param[in] configurableElement The element to get settings from.
699      * @param[out] result on success: the exported setttings in XML
700      *                    on error: human readable error message
701      *
702      * @return true in case of success, false otherwise.
703      */
704     bool getSettingsAsXML(const CConfigurableElement *configurableElement,
705                           std::string &result) const;
706 
707     /** Parse an XML stream into an element
708      *
709      * @param[in] elementSerializingContext serializing context
710      * @param[out] pRootElement the receiving element
711      * @param[in] input the input XML stream
712      * @param[in] baseUri the XML input file URI or ""
713      * @param[in] eElementLibrary which element library to be used
714      * @param[in] replace Should the element be overridden or modified in place
715      * @param[in] strNameAttributeName the name of the element's XML "name" attribute
716      *
717      * @returns true if parsing succeeded, false otherwise
718      */
719     bool xmlParse(CXmlElementSerializingContext &elementSerializingContext, CElement *pRootElement,
720                   _xmlDoc *doc, const std::string &baseUri, ElementLibrary eElementLibrary,
721                   bool replace = true, const std::string &strNameAttributeName = "Name");
722 
723     /** Wrapper for converting public APIs semantics to internal API
724      *
725      * Public APIs have a string argument that can either contain:
726      * - a path to an XML file or;
727      * - an actual XML document.
728      * They also have a boolean argument specifying which of the two cases it
729      * is.
730      *
731      * Instead, the internal APIs only take an std::istream argument. This
732      * method opens the file as a stream if applicable or simply wrap the
733      * string in a stream. It then passes the stream to the internal methods.
734      *
735      * @param[in] xmlSource the XML source (either a path or an actual xml
736      * document)
737      * @param[in] fromFile specifies whether xmlSource is a path or an
738      * actual XML document
739      * @param[in] withSettings if false, only import the configurations
740      * applicability rules; if true, also import their settings
741      * @param[out] element the receiving element
742      * @param[in] nameAttributeName the name of the element's XML "name"
743      * attribute
744      * @param[out] errorMsg string used as output for any error message
745      *
746      * @returns true if the import succeeded, false otherwise
747      */
748     bool wrapLegacyXmlImport(const std::string &xmlSource, bool fromFile, bool withSettings,
749                              CElement &element, const std::string &nameAttributeName,
750                              std::string &errorMsg);
751 
752     /**
753      * Export an element object to an Xml destination.
754      *
755      *
756      * @param[out] output the stream to output the XML to
757      * @param[in] xmlSerializingContext the serializing context
758      * @param[in] element object to be serialized.
759      *
760      * @return false if any error occurs, true otherwise.
761      */
762     bool serializeElement(std::ostream &output, CXmlSerializingContext &xmlSerializingContext,
763                           const CElement &element) const;
764 
765     /** Wrapper for converting public APIs semantics to internal API
766      *
767      * Public APIs have a string argument that can either:
768      * - contain a path to an XML file or;
769      * - receive an actual XML document.
770      * They also have a boolean argument specifying which of the two cases it
771      * is.
772      *
773      * Instead, the internal APIs only take an std::ostream argument. This
774      * method opens the file as a stream if applicable or simply wrap the
775      * string in a stream. It then passes the stream to the internal methods.
776      *
777      * @param[in] xmlDest the XML sink (either a path or any string that
778      * will be filled)
779      * @param[in] toFile specifies whether xmlSource is a path or a
780      * string that will receive an actual XML document
781      * @param[in] withSettings if false, only export the configurations
782      * applicability rules; if true, also export their settings
783      * @param[out] element the element to be exported
784      * @param[out] errorMsg string used as output for any error message
785      *
786      * @returns true if the export succeeded, false otherwise
787      */
788     bool wrapLegacyXmlExport(std::string &xmlDest, bool toFile, bool withSettings,
789                              const CElement &element, std::string &errorMsg) const;
790 
791     /** Wrapper for converting public APIs semantics to internal API
792      *
793      * @see wrapLegacyXmlExport
794      */
795     bool wrapLegacyXmlExportToFile(std::string &xmlDest, const CElement &element,
796                                    CXmlDomainExportContext &context) const;
797 
798     /** Wrapper for converting public APIs semantics to internal API
799      *
800      * @see wrapLegacyXmlExport
801      */
802     bool wrapLegacyXmlExportToString(std::string &xmlDest, const CElement &element,
803                                      CXmlDomainExportContext &context) const;
804 
805     // Framework Configuration
806     CParameterFrameworkConfiguration *getFrameworkConfiguration();
807     const CParameterFrameworkConfiguration *getConstFrameworkConfiguration();
808 
809     // Selection Criteria
810     CSelectionCriteria *getSelectionCriteria();
811     const CSelectionCriteria *getConstSelectionCriteria();
812 
813     // System Class
814     CSystemClass *getSystemClass();
815     const CSystemClass *getConstSystemClass() const;
816 
817     // Configurable Domains
818     CConfigurableDomains *getConfigurableDomains();
819     const CConfigurableDomains *getConstConfigurableDomains();
820     const CConfigurableDomains *getConstConfigurableDomains() const;
821 
822     // Apply configurations
823     void doApplyConfigurations(bool bForce);
824 
825     // Dynamic object creation libraries feeding
826     void feedElementLibraries();
827 
828     // Remote Processor Server connection handling
829     bool isRemoteInterfaceRequired();
830     bool handleRemoteProcessingInterface(std::string &strError);
831 
832     /** Log the result of a function
833      *
834      * @param[in] isSuccess indicates if the previous function has succeed
835      * @param[in] result function provided result string
836      * @return isSuccess parameter
837      */
838     bool logResult(bool isSuccess, const std::string &result);
839 
840     /** Info logger call helper */
841     inline core::log::details::Info info();
842 
843     /** Warning logger call helper */
844     inline core::log::details::Warning warning();
845 
846     // Tuning
847     bool _bTuningModeIsOn{false};
848 
849     // Value Space
850     bool _bValueSpaceIsRaw{false};
851 
852     // Output Raw Format
853     bool _bOutputRawFormatIsHex{false};
854 
855     // Automatic synchronization to HW during Tuning session
856     bool _bAutoSyncOn{true};
857 
858     // Current Parameter Settings
859     CParameterBlackboard *_pMainParameterBlackboard;
860 
861     // Dynamic object creation
862     CElementLibrarySet *_pElementLibrarySet;
863 
864     // XML parsing, object creation handling
865     std::string _xmlConfigurationUri;
866     std::string _schemaUri; // Place where schemas stand
867 
868     // Subsystem plugin location
869     const CSubsystemPlugins *_pSubsystemPlugins{nullptr};
870 
871     // Remote Processor Server
872     IRemoteProcessorServerInterface *_pRemoteProcessorServer{nullptr};
873 
874     // Parser description array
875     static const SRemoteCommandParserItem gastRemoteCommandParserItems[];
876 
877     // Maximum command usage length
878     size_t _maxCommandUsageLength{0};
879 
880     // Blackboard access mutex
881     std::mutex _blackboardMutex;
882 
883     /** Application main logger based on the one provided by the client */
884     mutable core::log::Logger _logger;
885 
886     /** If set to false, the remote interface won't be started no matter what.
887      * If set to true - the default - it has no impact on the policy for
888      * starting the remote interface.
889      */
890     bool _bForceNoRemoteInterface{false};
891 
892     /** If set to true, missing subsystem will abort parameterMgr start.
893       * If set to false, missing subsystem will fallback on virtual subsystem.
894       */
895     bool _bFailOnMissingSubsystem{true};
896     /** If set to true, unparsable or discording domains will abort parameterMgr start.
897       * If set to false, unparsable or discording domains
898       *                 will continue the parameterMgr start with no domains.
899       */
900     bool _bFailOnFailedSettingsLoad{true};
901 
902     /**
903      * If set to true, parameterMgr will report an error
904      *     when being unable to validate .xml files
905      * If set to false, no .xml/xsd validation will happen (default behaviour)
906      */
907     bool _bValidateSchemasOnStart{false};
908 };
909