1 /* 2 * Copyright (c) 2011-2014, 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 <pthread.h> 33 #include <map> 34 #include <vector> 35 #include <list> 36 #include "RemoteCommandHandlerTemplate.h" 37 #include "PathNavigator.h" 38 #include "SelectionCriterionType.h" 39 #include "SelectionCriterion.h" 40 #include "Element.h" 41 #include "XmlDocSink.h" 42 #include "XmlDocSource.h" 43 #include "XmlDomainExportContext.h" 44 45 #include <string> 46 #include <ostream> 47 #include <istream> 48 49 class CElementLibrarySet; 50 class CSubsystemLibrary; 51 class CSystemClass; 52 class CSelectionCriteria; 53 class CParameterFrameworkConfiguration; 54 class CSystemClassConfiguration; 55 class CParameterBlackboard; 56 class CConfigurableDomains; 57 class IRemoteProcessorServerInterface; 58 class CParameterHandle; 59 class CSubsystemPlugins; 60 class CParameterAccessContext; 61 class CConfigurableElement; 62 63 class CParameterMgr : private CElement 64 { 65 enum ChildElement { 66 EFrameworkConfiguration, 67 ESelectionCriteria, 68 ESystemClass, 69 EConfigurableDomains 70 }; 71 enum ElementLibrary { 72 EFrameworkConfigurationLibrary, 73 EParameterCreationLibrary, 74 EParameterConfigurationLibrary 75 }; 76 77 // Remote command parsers 78 typedef TRemoteCommandHandlerTemplate<CParameterMgr> CCommandHandler; 79 80 typedef CCommandHandler::CommandStatus (CParameterMgr::*RemoteCommandParser)(const IRemoteCommand& remoteCommand, std::string& strResult); 81 82 // Parser descriptions 83 struct SRemoteCommandParserItem 84 { 85 const char* _pcCommandName; 86 CParameterMgr::RemoteCommandParser _pfnParser; 87 uint32_t _uiMinArgumentCount; 88 const char* _pcHelp; 89 const char* _pcDescription; 90 }; 91 // Version 92 static const uint32_t guiEditionMajor = 2; 93 static const uint32_t guiEditionMinor = 6; 94 static const uint32_t guiRevision = 0; 95 96 // Parameter handle friendship 97 friend class CParameterHandle; 98 public: 99 // Logger interface 100 class ILogger 101 { 102 public: 103 virtual void log(bool bIsWarning, const std::string& strLog) = 0; 104 protected: ~ILogger()105 virtual ~ILogger() {} 106 }; 107 108 // Construction 109 CParameterMgr(const std::string& strConfigurationFilePath); 110 virtual ~CParameterMgr(); 111 112 // Logging 113 void setLogger(ILogger* pLogger); 114 115 /** Load plugins, structures and settings from the config file given. 116 * 117 * @param[out] strError is a std::string describing the error if an error occurred 118 * undefined otherwise. 119 * 120 * @return true if no error occurred, false otherwise. 121 */ 122 bool load(std::string& strError); 123 124 // Selection Criteria 125 CSelectionCriterionType* createSelectionCriterionType(bool bIsInclusive); 126 CSelectionCriterion* createSelectionCriterion(const std::string& strName, const CSelectionCriterionType* pSelectionCriterionType); 127 // Selection criterion retrieval 128 CSelectionCriterion* getSelectionCriterion(const std::string& strName); 129 130 // Configuration application 131 void applyConfigurations(); 132 133 /** 134 * Returns the CConfigurableElement corresponding to the path given in argument. 135 * 136 * @param[in] strPath A std::string representing a path to an element. 137 * @param[out] strError Error message 138 * 139 * @return A const pointer to the corresponding CConfigurableElement. 140 * On error, NULL is returned and the error is explained in strError. 141 */ 142 const CConfigurableElement* getConfigurableElement(const std::string& strPath, 143 std::string& strError) const; 144 // Dynamic parameter handling 145 CParameterHandle* createParameterHandle(const std::string& strPath, std::string& strError); 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(); 182 183 /** Get the path to the directory containing the XML Schemas 184 * 185 * @returns the directory containing the XML Schemas 186 */ 187 const std::string& getSchemaFolderLocation() const; 188 189 /** Override the directory containing the XML Schemas 190 * 191 * @param[in] strSchemaFolderLocation directory containing the XML Schemas 192 */ 193 void setSchemaFolderLocation(const std::string& strSchemaFolderLocation); 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 // Tuning mode 215 bool setTuningMode(bool bOn, std::string& strError); 216 bool tuningModeOn() const; 217 218 // Current value space for user set/get value interpretation 219 void setValueSpace(bool bIsRaw); 220 bool valueSpaceIsRaw(); 221 222 // Current Output Raw Format for user get value interpretation 223 void setOutputRawFormat(bool bIsHex); 224 bool outputRawFormatIsHex(); 225 226 // Automatic hardware synchronization control (during tuning session) 227 bool setAutoSync(bool bAutoSyncOn, std::string& strError); 228 bool autoSyncOn() const; 229 bool sync(std::string& strError); 230 231 // User set/get parameters 232 bool accessParameterValue(const std::string& strPath, std::string& strValue, bool bSet, std::string& strError); 233 /** 234 * Returns the element mapping corresponding to the path given in parameter. 235 * 236 * @param[in] strPath Path of an element 237 * @param[out] strValue A sting containing the mapping 238 * 239 * @return true if a mapping was found for this element 240 */ 241 bool getParameterMapping(const std::string& strPath, std::string& strValue) const; 242 bool accessConfigurationValue(const std::string &strDomain, const std::string &stConfiguration, const std::string& strPath, std::string& strValue, bool bSet, std::string& strError); 243 244 ////////// Configuration/Domains handling ////////////// 245 // Creation/Deletion 246 bool createDomain(const std::string& strName, std::string& strError); 247 bool renameDomain(const std::string& strName, const std::string& strNewName, 248 std::string& strError); 249 bool deleteDomain(const std::string& strName, std::string& strError); 250 bool deleteAllDomains(std::string& strError); 251 bool setSequenceAwareness(const std::string& strName, bool bSequenceAware, 252 std::string& strResult); 253 bool getSequenceAwareness(const std::string& strName, bool& bSequenceAware, 254 std::string& strResult); 255 bool createConfiguration(const std::string& strDomain, const std::string& strConfiguration, std::string& strError); 256 bool deleteConfiguration(const std::string& strDomain, const std::string& strConfiguration, std::string& strError); 257 bool renameConfiguration(const std::string& strDomain, const std::string& strConfiguration, const std::string& strNewConfiguration, std::string& strError); 258 259 // Save/Restore 260 bool restoreConfiguration(const std::string& strDomain, const std::string& strConfiguration, std::list<std::string>& strError); 261 bool saveConfiguration(const std::string& strDomain, const std::string& strConfiguration, std::string& strError); 262 263 // Configurable element - domain association 264 bool addConfigurableElementToDomain(const std::string& strDomain, const std::string& strConfigurableElementPath, std::string& strError); 265 bool removeConfigurableElementFromDomain(const std::string& strDomain, const std::string& strConfigurableElementPath, std::string& strError); 266 bool split(const std::string& strDomain, const std::string& strConfigurableElementPath, std::string& strError); 267 bool setElementSequence(const std::string& strDomain, const std::string& strConfiguration, 268 const std::vector<std::string>& astrNewElementSequence, 269 std::string& strError); 270 271 bool getApplicationRule(const std::string& strDomain, const std::string& strConfiguration, 272 std::string& strResult); 273 bool setApplicationRule(const std::string& strDomain, const std::string& strConfiguration, 274 const std::string& strApplicationRule, std::string& strError); 275 bool clearApplicationRule(const std::string& strDomain, const std::string& strConfiguration, 276 std::string& strError); 277 278 /** 279 * Method that imports Configurable Domains from an Xml source. 280 * 281 * @param[in] xmlSource a std::string containing an xml description or a path to an xml file 282 * @param[in] withSettings a boolean that determines if the settings should be used in the 283 * xml description 284 * @param[in] fromFile a boolean that determines if the source is an xml description in 285 * xmlSource or contained in a file. In that case xmlSource is just the file path. 286 * @param[out] errorMsg is used as the error output 287 * 288 * @return false if any error occures 289 */ 290 bool importDomainsXml(const std::string& xmlSource, bool withSettings, bool fromFile, 291 std::string& errorMsg); 292 293 /** 294 * Method that imports a single Configurable Domain from an Xml source. 295 * 296 * @param[in] xmlSource a string containing an xml description or a path to an xml file 297 * @param[in] overwrite when importing an existing domain, allow 298 * overwriting or return an error 299 * @param[in] withSettings a boolean that determines if the settings should be used in the 300 * xml description 301 * @param[in] fromFile a boolean that determines if the source is an xml description in 302 * xmlSource or contained in a file. In that case xmlSource is just the file path. 303 * @param[out] errorMsg is used as the error output 304 * 305 * @return false if any error occurs 306 */ 307 bool importSingleDomainXml(const std::string& xmlSource, bool overwrite, bool withSettings, 308 bool fromFile, std::string& errorMsg); 309 310 /** 311 * Method that exports Configurable Domains to an Xml destination. 312 * 313 * @param[in,out] xmlDest a string containing an xml description or a path to an xml file 314 * @param[in] withSettings a boolean that determines if the settings should be used in the 315 * xml description 316 * @param[in] toFile a boolean that determines if the destination is an xml description in 317 * xmlDest or contained in a file. In that case xmlDest is just the file path. 318 * @param[out] errorMsg is used as the error output 319 * 320 * @return false if any error occurs, true otherwise. 321 */ 322 bool exportDomainsXml(std::string& xmlDest, bool withSettings, bool toFile, 323 std::string& errorMsg) const; 324 325 /** 326 * Method that exports a given Configurable Domain to an Xml destination. 327 * 328 * @param[in,out] xmlDest a string containing an xml description or a path to an xml file 329 * @param[in] domainName the name of the domain to be exported 330 * @param[in] withSettings a boolean that determines if the settings should be used in the 331 * xml description 332 * @param[in] toFile a boolean that determines if the destination is an xml description in 333 * xmlDest or contained in a file. In that case xmlDest is just the file path. 334 * @param[out] errorMsg is used as the error output 335 * 336 * @return false if any error occurs, true otherwise. 337 */ 338 bool exportSingleDomainXml(std::string& xmlDest, const std::string& domainName, 339 bool withSettings, bool toFile, std::string& errorMsg) const; 340 341 // Binary Import/Export 342 bool importDomainsBinary(const std::string& strFileName, std::string& strError); 343 bool exportDomainsBinary(const std::string& strFileName, std::string& strError); 344 345 /** 346 * Method that exports an Xml description of the passed element into a string 347 * 348 * @param[in] pXmlSource The source element to export 349 * @param[in] strRootElementType The XML root element name of the exported instance document 350 * @param[out] strResult contains the xml description or the error description in case false is returned 351 * 352 * @return true for success, false if any error occurs during the creation of the xml description (validation or encoding) 353 */ 354 bool exportElementToXMLString(const IXmlSource* pXmlSource, 355 const std::string& strRootElementType, 356 std::string& strResult) const; 357 358 // CElement 359 virtual std::string getKind() const; 360 361 private: 362 CParameterMgr(const CParameterMgr&); 363 CParameterMgr& operator=(const CParameterMgr&); 364 365 // Init 366 virtual bool init(std::string& strError); 367 368 // Logging (done by root) 369 virtual void doLog(bool bIsWarning, const std::string& strLog) const; 370 virtual void nestLog() const; 371 virtual void unnestLog() const; 372 373 // Version 374 std::string getVersion() const; 375 376 ////////////////:: Remote command parsers 377 /// Version 378 CCommandHandler::CommandStatus versionCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 379 /// Status 380 CCommandHandler::CommandStatus statusCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 381 /// Tuning Mode 382 CCommandHandler::CommandStatus setTuningModeCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 383 CCommandHandler::CommandStatus getTuningModeCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 384 /// Value Space 385 CCommandHandler::CommandStatus setValueSpaceCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 386 CCommandHandler::CommandStatus getValueSpaceCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 387 /// Output Raw Format 388 CCommandHandler::CommandStatus setOutputRawFormatCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 389 CCommandHandler::CommandStatus getOutputRawFormatCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 390 /// Sync 391 CCommandHandler::CommandStatus setAutoSyncCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 392 CCommandHandler::CommandStatus getAutoSyncCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 393 CCommandHandler::CommandStatus syncCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 394 /// Criteria 395 CCommandHandler::CommandStatus listCriteriaCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 396 /// Domains 397 CCommandHandler::CommandStatus listDomainsCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 398 CCommandHandler::CommandStatus createDomainCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 399 CCommandHandler::CommandStatus deleteDomainCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 400 CCommandHandler::CommandStatus deleteAllDomainsCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 401 CCommandHandler::CommandStatus renameDomainCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 402 CCommandHandler::CommandStatus setSequenceAwarenessCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 403 CCommandHandler::CommandStatus getSequenceAwarenessCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 404 CCommandHandler::CommandStatus listDomainElementsCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 405 CCommandHandler::CommandStatus addElementCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 406 CCommandHandler::CommandStatus removeElementCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 407 CCommandHandler::CommandStatus splitDomainCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 408 /// Configurations 409 CCommandHandler::CommandStatus listConfigurationsCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 410 CCommandHandler::CommandStatus dumpDomainsCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 411 CCommandHandler::CommandStatus createConfigurationCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 412 CCommandHandler::CommandStatus deleteConfigurationCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 413 CCommandHandler::CommandStatus renameConfigurationCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 414 CCommandHandler::CommandStatus saveConfigurationCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 415 CCommandHandler::CommandStatus restoreConfigurationCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 416 CCommandHandler::CommandStatus setElementSequenceCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 417 CCommandHandler::CommandStatus getElementSequenceCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 418 CCommandHandler::CommandStatus setRuleCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 419 CCommandHandler::CommandStatus clearRuleCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 420 CCommandHandler::CommandStatus getRuleCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 421 /// Elements/Parameters 422 CCommandHandler::CommandStatus listElementsCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 423 CCommandHandler::CommandStatus listParametersCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 424 CCommandHandler::CommandStatus dumpElementCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 425 CCommandHandler::CommandStatus getElementSizeCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 426 CCommandHandler::CommandStatus showPropertiesCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 427 CCommandHandler::CommandStatus getParameterCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 428 CCommandHandler::CommandStatus setParameterCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 429 CCommandHandler::CommandStatus getConfigurationParameterCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 430 CCommandHandler::CommandStatus setConfigurationParameterCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 431 CCommandHandler::CommandStatus listBelongingDomainsCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 432 CCommandHandler::CommandStatus listAssociatedDomainsCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 433 CCommandHandler::CommandStatus showMappingCommandProcess(const IRemoteCommand& remoteCommand, 434 std::string& strResult); 435 /// Browse 436 CCommandHandler::CommandStatus listAssociatedElementsCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 437 CCommandHandler::CommandStatus listConflictingElementsCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 438 CCommandHandler::CommandStatus listRogueElementsCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 439 /// Settings Import/Export 440 CCommandHandler::CommandStatus exportDomainsXMLCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 441 CCommandHandler::CommandStatus importDomainsXMLCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 442 CCommandHandler::CommandStatus exportDomainsWithSettingsXMLCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 443 CCommandHandler::CommandStatus importDomainsWithSettingsXMLCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 444 /** 445 * Command handler method for exportDomainWithSettingsXML command. 446 * 447 * @param[in] remoteCommand contains the arguments of the received command. 448 * @param[out] result a std::string containing the result of the command 449 * 450 * @return CCommandHandler::ESucceeded if command succeeded or CCommandHandler::EFailed 451 * in the other case 452 */ 453 CCommandHandler::CommandStatus exportDomainWithSettingsXMLCommandProcess(const IRemoteCommand& remoteCommand, std::string& result); 454 CCommandHandler::CommandStatus importDomainWithSettingsXMLCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 455 CCommandHandler::CommandStatus exportSettingsCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 456 CCommandHandler::CommandStatus importSettingsCommandProcess(const IRemoteCommand& remoteCommand, std::string& strResult); 457 458 /** 459 * Command handler method for getDomainsWithSettings command. 460 * 461 * @param[in] remoteCommand contains the arguments of the received command. 462 * @param[out] strResult a std::string containing the result of the command 463 * 464 * @return CCommandHandler::ESucceeded if command succeeded or CCommandHandler::EFailed 465 * in the other case 466 */ 467 CCommandHandler::CommandStatus getDomainsWithSettingsXMLCommandProcess( 468 const IRemoteCommand& remoteCommand, std::string& strResult); 469 470 /** 471 * Command handler method for getDomainWithSettings command. 472 * 473 * @param[in] remoteCommand contains the arguments of the received command. 474 * @param[out] strResult a string containing the result of the command 475 * 476 * @return CCommandHandler::ESucceeded if command succeeded or CCommandHandler::EFailed 477 * in the other case 478 */ 479 CCommandHandler::CommandStatus getDomainWithSettingsXMLCommandProcess( 480 const IRemoteCommand& remoteCommand, std::string& strResult); 481 482 /** 483 * Command handler method for setDomainsWithSettings command. 484 * 485 * @param[in] remoteCommand contains the arguments of the received command. 486 * @param[out] strResult a std::string containing the result of the command 487 * 488 * @return CCommandHandler::ESucceeded if command succeeded or CCommandHandler::EFailed 489 * in the other case 490 */ 491 CCommandHandler::CommandStatus setDomainsWithSettingsXMLCommandProcess( 492 const IRemoteCommand& remoteCommand, std::string& strResult); 493 494 /** 495 * Command handler method for setDomainWithSettings command. 496 * 497 * @param[in] remoteCommand contains the arguments of the received command. 498 * @param[out] result a std::string containing the result of the command 499 * 500 * @return CCommandHandler::ESucceeded if command succeeded or CCommandHandler::EFailed 501 * in the other case 502 */ 503 CCommandHandler::CommandStatus setDomainWithSettingsXMLCommandProcess( 504 const IRemoteCommand& remoteCommand, std::string& result); 505 506 /** 507 * Command handler method for getSystemClass command. 508 * 509 * @param[in] remoteCommand contains the arguments of the received command. 510 * @param[out] strResult a std::string containing the result of the command 511 * 512 * @return CCommandHandler::ESucceeded if command succeeded or CCommandHandler::EFailed 513 * in the other case 514 */ 515 CCommandHandler::CommandStatus getSystemClassXMLCommandProcess( 516 const IRemoteCommand& remoteCommand, std::string& strResult); 517 518 // Max command usage length, use for formatting 519 void setMaxCommandUsageLength(); 520 521 // For tuning, check we're in tuning mode 522 bool checkTuningModeOn(std::string& strError) const; 523 524 // Blackboard (dynamic parameter handling) 525 pthread_mutex_t* getBlackboardMutex(); 526 527 // Blackboard reference (dynamic parameter handling) 528 CParameterBlackboard* getParameterBlackboard(); 529 530 // Parameter access 531 bool accessValue(CParameterAccessContext& parameterAccessContext, const std::string& strPath, std::string& strValue, bool bSet, std::string& strError); 532 bool doSetValue(const std::string& strPath, const std::string& strValue, bool bRawValueSpace, bool bDynamicAccess, std::string& strError) const; 533 bool doGetValue(const std::string& strPath, std::string& strValue, bool bRawValueSpace, bool bHexOutputRawFormat, bool bDynamicAccess, std::string& strError) const; 534 535 // Framework global configuration loading 536 bool loadFrameworkConfiguration(std::string& strError); 537 538 // System class Structure loading 539 bool loadStructure(std::string& strError); 540 541 // System class Structure loading 542 bool loadSettings(std::string& strError); 543 bool loadSettingsFromConfigFile(std::string& strError); 544 545 /** Parse an XML stream into an element 546 * 547 * @param[in] elementSerializingContext serializing context 548 * @param[out] pRootElement the receiving element 549 * @param[in] input the input XML stream 550 * @param[in] strXmlFolder the folder containing the XML input file (if applicable) or "" 551 * @param[in] eElementLibrary which element library to be used 552 * @param[in] strNameAttributeName the name of the element's XML "name" attribute 553 * 554 * @returns true if parsing succeeded, false otherwise 555 */ 556 bool xmlParse(CXmlElementSerializingContext& elementSerializingContext, CElement* pRootElement, 557 _xmlDoc* doc, const std::string& strXmlFolder, 558 ElementLibrary eElementLibrary, const std::string& strNameAttributeName = "Name"); 559 560 /** Wrapper for converting public APIs semantics to internal API 561 * 562 * Public APIs have a string argument that can either contain: 563 * - a path to an XML file or; 564 * - an actual XML document. 565 * They also have a boolean argument specifying which of the two cases it 566 * is. 567 * 568 * Instead, the internal APIs only take an std::istream argument. This 569 * method opens the file as a stream if applicable or simply wrap the 570 * string in a stream. It then passes the stream to the internal methods. 571 * 572 * @param[in] xmlSource the XML source (either a path or an actual xml 573 * document) 574 * @param[in] fromFile specifies whether xmlSource is a path or an 575 * actual XML document 576 * @param[in] withSettings if false, only import the configurations 577 * applicability rules; if true, also import their settings 578 * @param[out] element the receiving element 579 * @param[in] nameAttributeName the name of the element's XML "name" 580 * attribute 581 * @param[out] errorMsg string used as output for any error message 582 * 583 * @returns true if the import succeeded, false otherwise 584 */ 585 bool wrapLegacyXmlImport(const std::string& xmlSource, bool fromFile, bool withSettings, 586 CElement& element, const std::string& nameAttributeName, 587 std::string& errorMsg); 588 589 /** 590 * Export an element object to an Xml destination. 591 * 592 * 593 * @param[out] output the stream to output the XML to 594 * @param[in] xmlSerializingContext the serializing context 595 * @param[in] element object to be serialized. 596 * 597 * @return false if any error occurs, true otherwise. 598 */ 599 bool serializeElement(std::ostream& output, CXmlSerializingContext& xmlSerializingContext, 600 const CElement& element) const; 601 602 /** Wrapper for converting public APIs semantics to internal API 603 * 604 * Public APIs have a string argument that can either: 605 * - contain a path to an XML file or; 606 * - receive an actual XML document. 607 * They also have a boolean argument specifying which of the two cases it 608 * is. 609 * 610 * Instead, the internal APIs only take an std::ostream argument. This 611 * method opens the file as a stream if applicable or simply wrap the 612 * string in a stream. It then passes the stream to the internal methods. 613 * 614 * @param[in] xmlDest the XML sink (either a path or any string that 615 * will be filled) 616 * @param[in] toFile specifies whether xmlSource is a path or a 617 * string that will receive an actual XML document 618 * @param[in] withSettings if false, only export the configurations 619 * applicability rules; if true, also export their settings 620 * @param[out] element the element to be exported 621 * @param[out] errorMsg string used as output for any error message 622 * 623 * @returns true if the export succeeded, false otherwise 624 */ 625 bool wrapLegacyXmlExport(std::string& xmlDest, bool toFile, bool withSettings, 626 const CElement& element, std::string& errorMsg) const; 627 628 /** Wrapper for converting public APIs semantics to internal API 629 * 630 * @see wrapLegacyXmlExport 631 */ 632 bool wrapLegacyXmlExportToFile(std::string& xmlDest, 633 const CElement& element, 634 CXmlDomainExportContext &context) const; 635 636 /** Wrapper for converting public APIs semantics to internal API 637 * 638 * @see wrapLegacyXmlExport 639 */ 640 bool wrapLegacyXmlExportToString(std::string& xmlDest, 641 const CElement& element, 642 CXmlDomainExportContext &context) const; 643 644 645 // Framework Configuration 646 CParameterFrameworkConfiguration* getFrameworkConfiguration(); 647 const CParameterFrameworkConfiguration* getConstFrameworkConfiguration(); 648 649 // Selection Criteria 650 CSelectionCriteria* getSelectionCriteria(); 651 const CSelectionCriteria* getConstSelectionCriteria(); 652 653 // System Class 654 CSystemClass* getSystemClass(); 655 const CSystemClass* getConstSystemClass() const; 656 657 // Configurable Domains 658 CConfigurableDomains* getConfigurableDomains(); 659 const CConfigurableDomains* getConstConfigurableDomains(); 660 const CConfigurableDomains* getConstConfigurableDomains() const; 661 662 // Apply configurations 663 void doApplyConfigurations(bool bForce); 664 665 // Dynamic object creation libraries feeding 666 void feedElementLibraries(); 667 668 // Remote Processor Server connection handling 669 bool handleRemoteProcessingInterface(std::string& strError); 670 671 // Tuning 672 bool _bTuningModeIsOn; 673 674 // Value Space 675 bool _bValueSpaceIsRaw; 676 677 // Output Raw Format 678 bool _bOutputRawFormatIsHex; 679 680 // Automatic synchronization to HW during Tuning session 681 bool _bAutoSyncOn; 682 683 // Current Parameter Settings 684 CParameterBlackboard* _pMainParameterBlackboard; 685 686 // Dynamic object creation 687 CElementLibrarySet* _pElementLibrarySet; 688 689 // XML parsing, object creation handling 690 std::string _strXmlConfigurationFilePath; // Configuration file path 691 std::string _strXmlConfigurationFolderPath; // Root folder for configuration file 692 std::string _strSchemaFolderLocation; // Place where schemas stand 693 694 // Subsystem plugin location 695 const CSubsystemPlugins* _pSubsystemPlugins; 696 697 /** 698 * Remote processor library handle 699 */ 700 void* _pvLibRemoteProcessorHandle; 701 702 // Whole system structure checksum 703 uint8_t _uiStructureChecksum; 704 705 // Command Handler 706 CCommandHandler* _pCommandHandler; 707 708 // Remote Processor Server 709 IRemoteProcessorServerInterface* _pRemoteProcessorServer; 710 711 // Parser description array 712 static const SRemoteCommandParserItem gastRemoteCommandParserItems[]; 713 714 // Parser description array size 715 static const uint32_t guiNbRemoteCommandParserItems; 716 717 // Maximum command usage length 718 uint32_t _uiMaxCommandUsageLength; 719 720 // Blackboard access mutex 721 pthread_mutex_t _blackboardMutex; 722 723 // Logging 724 ILogger* _pLogger; 725 mutable uint32_t _uiLogDepth; 726 727 /** If set to false, the remote interface won't be started no matter what. 728 * If set to true - the default - it has no impact on the policy for 729 * starting the remote interface. 730 */ 731 bool _bForceNoRemoteInterface; 732 733 /** If set to true, missing subsystem will abort parameterMgr start. 734 * If set to false, missing subsystem will fallback on virtual subsystem. 735 */ 736 bool _bFailOnMissingSubsystem; 737 /** If set to true, unparsable or discording domains will abort parameterMgr start. 738 * If set to false, unparsable or discording domains 739 * will continue the parameterMgr start with no domains. 740 */ 741 bool _bFailOnFailedSettingsLoad; 742 743 /** 744 * If set to true, parameterMgr will report an error 745 * when being unable to validate .xml files 746 * If set to false, no .xml/xsd validation will happen (default behaviour) 747 */ 748 bool _bValidateSchemasOnStart; 749 }; 750 751