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 "SelectionCriterionTypeInterface.h" 33 #include "SelectionCriterionInterface.h" 34 #include "ParameterHandle.h" 35 #include "ParameterMgrLoggerForward.h" 36 37 class CParameterMgr; 38 39 class CParameterMgrPlatformConnector 40 { 41 friend class CParameterMgrLogger<CParameterMgrPlatformConnector>; 42 public: 43 // Logger interface 44 class ILogger 45 { 46 public: 47 virtual void log(bool bIsWarning, const std::string& strLog) = 0; 48 protected: ~ILogger()49 virtual ~ILogger() {} 50 }; 51 52 // Construction 53 CParameterMgrPlatformConnector(const std::string& strConfigurationFilePath); 54 ~CParameterMgrPlatformConnector(); // Not virtual since not supposed to be derived! 55 56 // Selection Criteria interface. Beware returned objects are lent, clients shall not delete them! 57 // Should be called before start 58 ISelectionCriterionTypeInterface* createSelectionCriterionType(bool bIsInclusive = false); 59 ISelectionCriterionInterface* createSelectionCriterion(const std::string& strName, const ISelectionCriterionTypeInterface* pSelectionCriterionType); 60 // Selection criterion retrieval 61 ISelectionCriterionInterface* getSelectionCriterion(const std::string& strName) const; 62 63 // Logging 64 // Should be called before start 65 void setLogger(ILogger* pLogger); 66 67 // Start 68 bool start(std::string& strError); 69 70 // Started state 71 bool isStarted() const; 72 73 // Configuration application 74 void applyConfigurations(); 75 76 // Dynamic parameter handling 77 // Returned objects are owned by clients 78 // Must be cassed after successfull start 79 CParameterHandle* createParameterHandle(const std::string& strPath, std::string& strError) const; 80 81 /** Is the remote interface forcefully disabled ? 82 */ 83 bool getForceNoRemoteInterface() const; 84 85 /** 86 * Forcefully disable the remote interface or cancel this policy. 87 * 88 * Has no effect if called after calling start(). 89 * 90 * @param[in] bForceNoRemoteInterface disable the remote interface if true. 91 */ 92 void setForceNoRemoteInterface(bool bForceNoRemoteInterface); 93 94 /** Should start fail in case of missing subsystems. 95 * 96 * Will fail if called on started instance. 97 * 98 * @param[in] bFail: If set to true, parameterMgr start will fail on missing subsystems 99 * If set to false, missing subsystems will fallbacks on virtual subsystem 100 * @param[out] strError a string describing the error if the function failed, 101 unmodified otherwise. 102 * 103 * @return false if unable to set, true otherwise. 104 */ 105 bool setFailureOnMissingSubsystem(bool bFail, std::string& strError); 106 107 /** Would start fail in case of missing subsystems. 108 * 109 * @return if the subsystem load will fail on missing subsystem. 110 */ 111 bool getFailureOnMissingSubsystem(); 112 113 /** Should start fail in failed settings load. 114 * 115 * Will fail if called on started instance. 116 * 117 * @param[in] bFail: If set to true, parameterMgr start will fail on failed settings load. 118 * If set to false, failed settings load will be ignored. 119 * @param[out] strResult a string containing the result of the command. 120 * 121 * @return false if unable to set, true otherwise. 122 */ 123 bool setFailureOnFailedSettingsLoad(bool bFail, std::string& strError); 124 /** Would start fail in case of failed settings load. 125 * 126 * @return failure on failed settings load policy state. 127 */ 128 bool getFailureOnFailedSettingsLoad(); 129 130 /** Get the path to the directory containing the XML Schemas 131 * 132 * @returns the directory containing the XML Schemas 133 */ 134 const std::string& getSchemaFolderLocation() const; 135 136 /** Override the directory containing the XML Schemas 137 * 138 * @param[in] strSchemaFolderLocation directory containing the XML Schemas 139 */ 140 void setSchemaFolderLocation(const std::string& strSchemaFolderLocation); 141 142 /** Should .xml files be validated on start ? 143 * 144 * @param[in] bValidate: 145 * If set to true, parameterMgr will abort when being unable to validate .xml files 146 * If set to false, no .xml/xsd validation will happen (default behaviour) 147 * @param[out] strResult a string containing the result of the command. 148 * 149 * @return false if unable to set, true otherwise. 150 */ 151 bool setValidateSchemasOnStart(bool bValidate, std::string &strError); 152 153 /** Would .xml files be validated on start? 154 * 155 * @return areSchemasValidated 156 */ 157 bool getValidateSchemasOnStart(); 158 159 private: 160 CParameterMgrPlatformConnector(const CParameterMgrPlatformConnector&); 161 CParameterMgrPlatformConnector& operator=(const CParameterMgrPlatformConnector&); 162 // Private logging 163 void doLog(bool bIsWarning, const std::string& strLog); 164 165 // Implementation 166 CParameterMgr* _pParameterMgr; 167 // State 168 bool _bStarted; 169 // Logging 170 ILogger* _pLogger; 171 // Private logging 172 CParameterMgrLogger<CParameterMgrPlatformConnector>* _pParameterMgrLogger; 173 }; 174