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 #include "ParameterMgrFullConnector.h" 31 #include "ParameterMgr.h" 32 #include "ParameterMgrLogger.h" 33 34 #include <list> 35 36 using std::string; 37 38 CParameterMgrFullConnector::CParameterMgrFullConnector(const string& strConfigurationFilePath) : 39 _pParameterMgr(new CParameterMgr(strConfigurationFilePath)), _pLogger(NULL) 40 { 41 _pParameterMgrLogger = new CParameterMgrLogger<CParameterMgrFullConnector>(*this); 42 _pParameterMgr->setLogger(_pParameterMgrLogger); 43 } 44 45 CParameterMgrFullConnector::~CParameterMgrFullConnector() 46 { 47 delete _pParameterMgr; 48 delete _pParameterMgrLogger; 49 } 50 51 52 bool CParameterMgrFullConnector::start(string& strError) 53 { 54 // Create data structure & Init flow 55 return _pParameterMgr->load(strError); 56 } 57 58 void CParameterMgrFullConnector::setLogger(CParameterMgrFullConnector::ILogger* pLogger) 59 { 60 _pLogger = pLogger; 61 } 62 63 // Private logging 64 void CParameterMgrFullConnector::doLog(bool bIsWarning, const string& strLog) 65 { 66 if (_pLogger) { 67 68 _pLogger->log(bIsWarning, strLog); 69 } 70 } 71 72 CParameterHandle* CParameterMgrFullConnector::createParameterHandle(const string& strPath, 73 string& strError) 74 { 75 return _pParameterMgr->createParameterHandle(strPath, strError); 76 } 77 78 ISelectionCriterionTypeInterface* CParameterMgrFullConnector::createSelectionCriterionType( 79 bool bIsInclusive) 80 { 81 return _pParameterMgr->createSelectionCriterionType(bIsInclusive); 82 } 83 84 ISelectionCriterionInterface* CParameterMgrFullConnector::createSelectionCriterion( 85 const string& strName, 86 const ISelectionCriterionTypeInterface* pSelectionCriterionType) 87 { 88 return _pParameterMgr->createSelectionCriterion(strName, 89 static_cast<const CSelectionCriterionType*>(pSelectionCriterionType)); 90 } 91 92 ISelectionCriterionInterface* CParameterMgrFullConnector::getSelectionCriterion( 93 const string& strName) 94 { 95 return _pParameterMgr->getSelectionCriterion(strName); 96 } 97 98 bool CParameterMgrFullConnector::getForceNoRemoteInterface() const 99 { 100 return _pParameterMgr->getForceNoRemoteInterface(); 101 } 102 103 void CParameterMgrFullConnector::setForceNoRemoteInterface(bool bForceNoRemoteInterface) 104 { 105 _pParameterMgr->setForceNoRemoteInterface(bForceNoRemoteInterface); 106 } 107 108 void CParameterMgrFullConnector::applyConfigurations() 109 { 110 return _pParameterMgr->applyConfigurations(); 111 } 112 113 void CParameterMgrFullConnector::setFailureOnMissingSubsystem(bool bFail) 114 { 115 _pParameterMgr->setFailureOnMissingSubsystem(bFail); 116 } 117 118 bool CParameterMgrFullConnector::getFailureOnMissingSubsystem() const 119 { 120 return _pParameterMgr->getFailureOnMissingSubsystem(); 121 } 122 123 void CParameterMgrFullConnector::setFailureOnFailedSettingsLoad(bool bFail) 124 { 125 _pParameterMgr->setFailureOnFailedSettingsLoad(bFail); 126 } 127 128 bool CParameterMgrFullConnector::getFailureOnFailedSettingsLoad() 129 { 130 return _pParameterMgr->getFailureOnFailedSettingsLoad(); 131 } 132 133 const string& CParameterMgrFullConnector::getSchemaFolderLocation() const 134 { 135 return _pParameterMgr->getSchemaFolderLocation(); 136 } 137 138 void CParameterMgrFullConnector::setSchemaFolderLocation(const string& strSchemaFolderLocation) 139 { 140 _pParameterMgr->setSchemaFolderLocation(strSchemaFolderLocation); 141 } 142 143 void CParameterMgrFullConnector::setValidateSchemasOnStart(bool bValidate) 144 { 145 _pParameterMgr->setValidateSchemasOnStart(bValidate); 146 } 147 148 bool CParameterMgrFullConnector::getValidateSchemasOnStart() const 149 { 150 return _pParameterMgr->getValidateSchemasOnStart(); 151 } 152 153 bool CParameterMgrFullConnector::setTuningMode(bool bOn, string& strError) 154 { 155 return _pParameterMgr->setTuningMode(bOn, strError); 156 } 157 158 bool CParameterMgrFullConnector::isTuningModeOn() const 159 { 160 return _pParameterMgr->tuningModeOn(); 161 } 162 163 void CParameterMgrFullConnector::setValueSpace(bool bIsRaw) 164 { 165 return _pParameterMgr->setValueSpace(bIsRaw); 166 } 167 168 bool CParameterMgrFullConnector::isValueSpaceRaw() const 169 { 170 return _pParameterMgr->valueSpaceIsRaw(); 171 } 172 173 void CParameterMgrFullConnector::setOutputRawFormat(bool bIsHex) 174 { 175 return _pParameterMgr->setOutputRawFormat(bIsHex); 176 } 177 178 bool CParameterMgrFullConnector::isOutputRawFormatHex() const 179 { 180 return _pParameterMgr->outputRawFormatIsHex(); 181 } 182 183 bool CParameterMgrFullConnector::setAutoSync(bool bAutoSyncOn, string& strError) 184 { 185 return _pParameterMgr->setAutoSync(bAutoSyncOn, strError); 186 } 187 188 bool CParameterMgrFullConnector::isAutoSyncOn() const 189 { 190 return _pParameterMgr->autoSyncOn(); 191 } 192 193 bool CParameterMgrFullConnector::sync(string& strError) 194 { 195 return _pParameterMgr->sync(strError); 196 } 197 198 bool CParameterMgrFullConnector::accessParameterValue(const string& strPath, string& strValue, 199 bool bSet, string& strError) 200 { 201 return _pParameterMgr->accessParameterValue(strPath, strValue, bSet, strError); 202 } 203 204 bool CParameterMgrFullConnector::accessConfigurationValue(const string &strDomain, 205 const string &strConfiguration, 206 const string& strPath, string& strValue, 207 bool bSet, string& strError) 208 { 209 return _pParameterMgr->accessConfigurationValue(strDomain, strConfiguration, strPath, strValue, 210 bSet, strError); 211 } 212 213 bool CParameterMgrFullConnector::getParameterMapping(const string& strPath, string& strValue) const 214 { 215 return _pParameterMgr->getParameterMapping(strPath, strValue); 216 } 217 218 bool CParameterMgrFullConnector::createDomain(const string& strName, string& strError) 219 { 220 return _pParameterMgr->createDomain(strName, strError); 221 } 222 223 bool CParameterMgrFullConnector::deleteDomain(const string& strName, string& strError) 224 { 225 return _pParameterMgr->deleteDomain(strName, strError); 226 } 227 228 bool CParameterMgrFullConnector::renameDomain(const string& strName, const string& strNewName, 229 string& strError) 230 { 231 return _pParameterMgr->renameDomain(strName, strNewName, strError); 232 } 233 234 bool CParameterMgrFullConnector::deleteAllDomains(string& strError) 235 { 236 return _pParameterMgr->deleteAllDomains(strError); 237 } 238 239 bool CParameterMgrFullConnector::createConfiguration(const string& strDomain, 240 const string& strConfiguration, 241 string& strError) 242 { 243 return _pParameterMgr->createConfiguration(strDomain, strConfiguration, strError); 244 } 245 246 bool CParameterMgrFullConnector::deleteConfiguration(const string& strDomain, 247 const string& strConfiguration, 248 string& strError) 249 { 250 return _pParameterMgr->deleteConfiguration(strDomain, strConfiguration, strError); 251 } 252 253 bool CParameterMgrFullConnector::renameConfiguration(const string& strDomain, 254 const string& strConfiguration, 255 const string& strNewConfiguration, 256 string& strError) 257 { 258 return _pParameterMgr->renameConfiguration(strDomain, strConfiguration, strNewConfiguration, 259 strError); 260 } 261 262 bool CParameterMgrFullConnector::saveConfiguration(const string& strDomain, 263 const string& strConfiguration, string& strError) 264 { 265 return _pParameterMgr->saveConfiguration(strDomain, strConfiguration, strError); 266 } 267 268 bool CParameterMgrFullConnector::restoreConfiguration(const string& strDomain, 269 const string& strConfiguration, 270 std::list<string>& lstrError) 271 { 272 return _pParameterMgr->restoreConfiguration(strDomain, strConfiguration, lstrError); 273 } 274 275 bool CParameterMgrFullConnector::setSequenceAwareness(const string& strName, bool bSequenceAware, 276 string& strResult) 277 { 278 return _pParameterMgr->setSequenceAwareness(strName, bSequenceAware, strResult); 279 } 280 281 bool CParameterMgrFullConnector::getSequenceAwareness(const string& strName, bool& bSequenceAware, 282 string& strResult) 283 { 284 return _pParameterMgr->getSequenceAwareness(strName, bSequenceAware, strResult); 285 } 286 287 bool CParameterMgrFullConnector::addConfigurableElementToDomain(const string& strDomain, 288 const string& strConfigurableElementPath, string& strError) 289 { 290 return _pParameterMgr->addConfigurableElementToDomain(strDomain, strConfigurableElementPath, 291 strError); 292 } 293 294 bool CParameterMgrFullConnector::removeConfigurableElementFromDomain(const string& strDomain, 295 const string& strConfigurableElementPath, string& strError) 296 { 297 return _pParameterMgr->removeConfigurableElementFromDomain(strDomain, 298 strConfigurableElementPath, strError); 299 } 300 301 bool CParameterMgrFullConnector::split(const string& strDomain, 302 const string& strConfigurableElementPath, string& strError) 303 { 304 return _pParameterMgr->split(strDomain, strConfigurableElementPath, strError); 305 } 306 307 bool CParameterMgrFullConnector::setElementSequence(const string& strDomain, 308 const string& strConfiguration, 309 const std::vector<string>& astrNewElementSequence, 310 string& strError) 311 { 312 return _pParameterMgr->setElementSequence(strDomain, strConfiguration, astrNewElementSequence, 313 strError); 314 } 315 316 bool CParameterMgrFullConnector::setApplicationRule(const string& strDomain, 317 const string& strConfiguration, 318 const string& strApplicationRule, 319 string& strError) 320 { 321 return _pParameterMgr->setApplicationRule(strDomain, strConfiguration, strApplicationRule, 322 strError); 323 } 324 325 326 bool CParameterMgrFullConnector::getApplicationRule(const string& strDomain, 327 const string& strConfiguration, 328 string& strResult) 329 { 330 return _pParameterMgr->getApplicationRule(strDomain, strConfiguration, strResult); 331 } 332 bool CParameterMgrFullConnector::clearApplicationRule(const string& strDomain, 333 const string& strConfiguration, 334 string& strError) 335 { 336 return _pParameterMgr->clearApplicationRule(strDomain, strConfiguration, strError); 337 } 338 339 340 bool CParameterMgrFullConnector::importDomainsXml(const string& strXmlSource, bool bWithSettings, 341 bool bFromFile, string& strError) 342 { 343 return _pParameterMgr->importDomainsXml(strXmlSource, bWithSettings, bFromFile, strError); 344 } 345 346 bool CParameterMgrFullConnector::exportDomainsXml(string& strXmlDest, bool bWithSettings, 347 bool bToFile, string& strError) const 348 { 349 return _pParameterMgr->exportDomainsXml(strXmlDest, bWithSettings, bToFile, strError); 350 } 351 352 // deprecated, use the other version of importSingleDomainXml instead 353 bool CParameterMgrFullConnector::importSingleDomainXml(const string& strXmlSource, bool bOverwrite, 354 string& strError) 355 { 356 return importSingleDomainXml(strXmlSource, bOverwrite, true, false, strError); 357 } 358 359 bool CParameterMgrFullConnector::importSingleDomainXml(const string& xmlSource, bool overwrite, 360 bool withSettings, bool fromFile, 361 string& errorMsg) 362 { 363 return _pParameterMgr->importSingleDomainXml(xmlSource, overwrite, withSettings, fromFile, 364 errorMsg); 365 } 366 367 bool CParameterMgrFullConnector::exportSingleDomainXml(string& strXmlDest, 368 const string& strDomainName, 369 bool bWithSettings, bool bToFile, 370 string& strError) const 371 { 372 return _pParameterMgr->exportSingleDomainXml(strXmlDest, strDomainName, bWithSettings, bToFile, 373 strError); 374 } 375