1 /* 2 * Copyright (c) 2015, 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 "parameter_export.h" 33 34 #include "SelectionCriterionTypeInterface.h" 35 #include "SelectionCriterionInterface.h" 36 #include "ParameterHandle.h" 37 #include "ParameterMgrLoggerForward.h" 38 #include "ParameterMgrPlatformConnector.h" 39 #include "CommandHandlerInterface.h" 40 41 #include <string> 42 #include <list> 43 #include <memory> 44 #include <stdint.h> 45 46 class CParameterMgr; 47 48 /** @note Since only C++11 components use this interface 49 * (contrary to the more restricted CParameterMgrPlatformConnector), 50 * could this api not be transition to c++11 ? 51 */ 52 class PARAMETER_EXPORT CParameterMgrFullConnector : public CParameterMgrPlatformConnector 53 { 54 public: 55 /** String list type which can hold list of error/info and can be presented to client */ 56 typedef std::list<std::string> Results; 57 58 CParameterMgrFullConnector(const std::string &strConfigurationFilePath); 59 60 /** Create and return a command handler for this ParameterMgr instance 61 * 62 * The caller owns the returned pointer and is responsible for deleting it 63 * before destroying the Connector object. 64 * 65 * @returns a Command Handler 66 */ 67 CommandHandlerInterface *createCommandHandler(); 68 69 /** @deprecated Same as its overload without error handling. 70 * @note this deprecated method in not available in the python wrapper. 71 */ 72 void setFailureOnMissingSubsystem(bool bFail); 73 using CParameterMgrPlatformConnector::setFailureOnMissingSubsystem; 74 75 /** @deprecated Same as its overload without error handling. 76 * @note this deprecated method in not available in the python wrapper. 77 */ 78 void setFailureOnFailedSettingsLoad(bool bFail); 79 using CParameterMgrPlatformConnector::setFailureOnFailedSettingsLoad; 80 81 /** @deprecated Same as its overload without error handling. 82 * @note this deprecated method in not available in the python wrapper. 83 */ 84 void setValidateSchemasOnStart(bool bValidate); 85 using CParameterMgrPlatformConnector::setValidateSchemasOnStart; 86 87 //////////// Tuning ///////////// 88 // Tuning mode 89 bool setTuningMode(bool bOn, std::string &strError); 90 bool isTuningModeOn() const; 91 92 // Current value space for user set/get value interpretation 93 void setValueSpace(bool bIsRaw); 94 bool isValueSpaceRaw() const; 95 96 // Current Output Raw Format for user get value interpretation 97 void setOutputRawFormat(bool bIsHex); 98 bool isOutputRawFormatHex() const; 99 // Automatic hardware synchronization control (during tuning session) 100 bool setAutoSync(bool bAutoSyncOn, std::string &strError); 101 bool isAutoSyncOn() const; 102 bool sync(std::string &strError); 103 104 // User set/get parameters 105 bool accessParameterValue(const std::string &strPath, std::string &strValue, bool bSet, 106 std::string &strError); 107 bool accessConfigurationValue(const std::string &strDomain, const std::string &strConfiguration, 108 const std::string &strPath, std::string &strValue, bool bSet, 109 std::string &strError); 110 111 /** 112 * Returns the element mapping corresponding to the path given in parameter. 113 * 114 * @param[in] strPath Path of an element 115 * @param[out] strValue A sting containing the mapping 116 * 117 * @return true if a mapping was found for this element 118 */ 119 bool getParameterMapping(const std::string &strPath, std::string &strValue) const; 120 ////////// Configuration/Domains handling ////////////// 121 // Creation/Deletion 122 bool createDomain(const std::string &strName, std::string &strError); 123 bool deleteDomain(const std::string &strName, std::string &strError); 124 bool renameDomain(const std::string &strName, const std::string &strNewName, 125 std::string &strError); 126 bool deleteAllDomains(std::string &strError); 127 bool setSequenceAwareness(const std::string &strName, bool bSequenceAware, 128 std::string &strResult); 129 bool getSequenceAwareness(const std::string &strName, bool &bSequenceAware, 130 std::string &strResult); 131 bool createConfiguration(const std::string &strDomain, const std::string &strConfiguration, 132 std::string &strError); 133 bool deleteConfiguration(const std::string &strDomain, const std::string &strConfiguration, 134 std::string &strError); 135 bool renameConfiguration(const std::string &strDomain, const std::string &strConfiguration, 136 const std::string &strNewConfiguration, std::string &strError); 137 138 /** Restore a configuration 139 * 140 * @param[in] strDomain the domain name 141 * @param[in] strConfiguration the configuration name 142 * @param[out] errors, errors encountered during restoration 143 * @return true if success false otherwise 144 */ 145 bool restoreConfiguration(const std::string &strDomain, const std::string &strConfiguration, 146 Results &errors); 147 148 bool saveConfiguration(const std::string &strDomain, const std::string &strConfiguration, 149 std::string &strError); 150 151 // Configurable element - domain association 152 bool addConfigurableElementToDomain(const std::string &strDomain, 153 const std::string &strConfigurableElementPath, 154 std::string &strError); 155 bool removeConfigurableElementFromDomain(const std::string &strDomain, 156 const std::string &strConfigurableElementPath, 157 std::string &strError); 158 bool split(const std::string &strDomain, const std::string &strConfigurableElementPath, 159 std::string &strError); 160 bool setElementSequence(const std::string &strDomain, const std::string &strConfiguration, 161 const std::vector<std::string> &astrNewElementSequence, 162 std::string &strError); 163 164 bool setApplicationRule(const std::string &strDomain, const std::string &strConfiguration, 165 const std::string &strApplicationRule, std::string &strError); 166 bool getApplicationRule(const std::string &strDomain, const std::string &strConfiguration, 167 std::string &strResult); 168 bool clearApplicationRule(const std::string &strDomain, const std::string &strConfiguration, 169 std::string &strError); 170 171 /** 172 * Method that imports Configurable Domains from an Xml source. 173 * 174 * @param[in] strXmlSource a string containing an xml description or a path to an xml file 175 * @param[in] bWithSettings a boolean that determines if the settings should be used in the 176 * xml description 177 * @param[in] bFromFile a boolean that determines if the source is an xml description in 178 * strXmlSource or contained in a file. In that case strXmlSource is just the file path. 179 * @param[out] strError is used as the error output 180 * 181 * @return false if any error occures 182 */ 183 bool importDomainsXml(const std::string &strXmlSource, bool bWithSettings, bool bFromFile, 184 std::string &strError); 185 /** 186 * Method that imports a single Configurable Domain from an Xml source. 187 * 188 * @param[in] xmlSource a string containing an xml description or a path to an xml file 189 * @param[in] overwrite when importing an existing domain, allow overwriting or return an 190 * error 191 * @param[in] withSettings a boolean that determines if the settings should be used in the 192 * xml description 193 * @param[in] fromFile a boolean that determines if the source is an xml description in 194 * strXmlSource or contained in a file. In that case strXmlSource is just the file path. 195 * @param[out] errorMsg is used as the error output 196 * 197 * @return false if any error occurs 198 */ 199 bool importSingleDomainXml(const std::string &xmlSource, bool overwrite, bool withSettings, 200 bool fromFile, std::string &errorMsg); 201 /** 202 * Method that imports a single Configurable Domain from an string 203 * describing an Xml source. 204 * 205 * @deprecated use the other versions of importSingleDomainXml instead 206 * 207 * @param[in] strXmlSource a string containing an xml description 208 * @param[in] bOverwrite when importing an existing domain, allow overwriting or return an 209 * error 210 * @param[out] strError is used as the error output 211 * 212 * @return false if any error occurs 213 */ 214 bool importSingleDomainXml(const std::string &strXmlSource, bool bOverwrite, 215 std::string &strError); 216 217 /** 218 * Method that exports Configurable Domains to an Xml destination. 219 * 220 * @param[in,out] strXmlDest a string containing an xml description or a path to an xml file 221 * @param[in] bWithSettings a boolean that determines if the settings should be used in the 222 * xml description 223 * @param[in] bToFile a boolean that determines if the destination is an xml description in 224 * strXmlDest or contained in a file. In that case strXmlDest is just the file path. 225 * @param[out] strError is used as the error output 226 * 227 * @return false if any error occures, true otherwise. 228 */ 229 bool exportDomainsXml(std::string &strXmlDest, bool bWithSettings, bool bToFile, 230 std::string &strError) const; 231 232 /** 233 * Method that exports a given Configurable Domain to an Xml destination. 234 * 235 * @param[in,out] strXmlDest a string containing an xml description or a path to an xml file 236 * @param[in] strDomainName the name of the domain to be exported 237 * @param[in] bWithSettings a boolean that determines if the settings should be used in the 238 * xml description 239 * @param[in] bToFile a boolean that determines if the destination is an xml description in 240 * strXmlDest or contained in a file. In that case strXmlDest is just the file path. 241 * @param[out] strError is used as the error output 242 * 243 * @return false if any error occurs, true otherwise. 244 */ 245 bool exportSingleDomainXml(std::string &strXmlDest, const std::string &strDomainName, 246 bool bWithSettings, bool bToFile, std::string &strError) const; 247 248 private: 249 // disallow copying because this class manages raw pointers' lifecycle 250 CParameterMgrFullConnector(const CParameterMgrFullConnector &); 251 CParameterMgrFullConnector &operator=(const CParameterMgrFullConnector &); 252 }; 253