| David Wagner | b76c9d6 | 2014-02-05 18:30:24 +0100 | [diff] [blame] | 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. |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 29 | */ |
| 30 | #pragma once |
| 31 | |
| 32 | #include <pthread.h> |
| Kevin Rocard | ace81f8 | 2012-12-11 16:19:17 +0100 | [diff] [blame] | 33 | #include <map> |
| 34 | #include <vector> |
| 35 | #include <list> |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 36 | #include "RemoteCommandHandlerTemplate.h" |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 37 | #include "PathNavigator.h" |
| 38 | #include "SelectionCriterionType.h" |
| 39 | #include "SelectionCriterion.h" |
| 40 | #include "Element.h" |
| Georges-Henri Baron | 326a31d | 2012-06-28 12:05:09 +0200 | [diff] [blame] | 41 | #include "XmlDocSink.h" |
| 42 | #include "XmlDocSource.h" |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 43 | |
| Patrick Benavoli | 592ae56 | 2011-09-05 16:53:58 +0200 | [diff] [blame] | 44 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 45 | class CElementLibrarySet; |
| 46 | class CSubsystemLibrary; |
| 47 | class CSystemClass; |
| 48 | class CSelectionCriteria; |
| 49 | class CParameterFrameworkConfiguration; |
| 50 | class CSystemClassConfiguration; |
| 51 | class CParameterBlackboard; |
| 52 | class CConfigurableDomains; |
| 53 | class IRemoteProcessorServerInterface; |
| 54 | class CBackSynchronizer; |
| Patrick Benavoli | 065264a | 2011-11-20 15:46:41 +0100 | [diff] [blame] | 55 | class CParameterHandle; |
| Guillaume Denneulin | a4ec15d | 2012-02-17 14:38:14 +0100 | [diff] [blame] | 56 | class CSubsystemPlugins; |
| Frédéric Boisnard | e42dacd | 2013-02-25 15:56:56 +0100 | [diff] [blame] | 57 | class CParameterAccessContext; |
| Frederic Boisnard | 6cae0ec | 2013-05-23 18:48:58 +0200 | [diff] [blame] | 58 | class CConfigurableElement; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 59 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 60 | class CParameterMgr : private CElement |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 61 | { |
| 62 | enum ChildElement { |
| 63 | EFrameworkConfiguration, |
| 64 | ESelectionCriteria, |
| 65 | ESystemClass, |
| 66 | EConfigurableDomains |
| 67 | }; |
| 68 | enum ElementLibrary { |
| 69 | EFrameworkConfigurationLibrary, |
| 70 | EParameterCreationLibrary, |
| 71 | EParameterConfigurationLibrary |
| 72 | }; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 73 | |
| 74 | // Remote command parsers |
| Patrick Benavoli | 065264a | 2011-11-20 15:46:41 +0100 | [diff] [blame] | 75 | typedef TRemoteCommandHandlerTemplate<CParameterMgr> CCommandHandler; |
| 76 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 77 | typedef CCommandHandler::CommandStatus (CParameterMgr::*RemoteCommandParser)(const IRemoteCommand& remoteCommand, string& strResult); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 78 | |
| 79 | // Parser descriptions |
| 80 | struct SRemoteCommandParserItem |
| 81 | { |
| 82 | const char* _pcCommandName; |
| 83 | CParameterMgr::RemoteCommandParser _pfnParser; |
| 84 | uint32_t _uiMinArgumentCount; |
| 85 | const char* _pcHelp; |
| 86 | const char* _pcDescription; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 87 | }; |
| Patrick Benavoli | 592ae56 | 2011-09-05 16:53:58 +0200 | [diff] [blame] | 88 | // Version |
| Patrick Benavoli | 065264a | 2011-11-20 15:46:41 +0100 | [diff] [blame] | 89 | static const uint32_t guiEditionMajor = 0x2; |
| Kevin Rocard | 265e43c | 2013-06-20 18:55:22 +0200 | [diff] [blame] | 90 | static const uint32_t guiEditionMinor = 0x2; |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 91 | static const uint32_t guiRevision = 0x0; |
| Patrick Benavoli | 065264a | 2011-11-20 15:46:41 +0100 | [diff] [blame] | 92 | |
| 93 | // Parameter handle friendship |
| 94 | friend class CParameterHandle; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 95 | public: |
| 96 | // Logger interface |
| 97 | class ILogger |
| 98 | { |
| 99 | public: |
| Kevin Rocard | ace81f8 | 2012-12-11 16:19:17 +0100 | [diff] [blame] | 100 | virtual void log(bool bIsWarning, const std::string& strLog) = 0; |
| Sebastien Gonzalve | d7e4844 | 2013-03-12 14:30:27 +0100 | [diff] [blame] | 101 | protected: |
| 102 | virtual ~ILogger() {} |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 103 | }; |
| 104 | |
| 105 | // Construction |
| Patrick Benavoli | 95ac034 | 2011-11-07 20:32:51 +0100 | [diff] [blame] | 106 | CParameterMgr(const string& strConfigurationFilePath); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 107 | virtual ~CParameterMgr(); |
| 108 | |
| 109 | // Logging |
| 110 | void setLogger(ILogger* pLogger); |
| 111 | |
| Kevin Rocard | ecf9310 | 2013-07-10 18:28:10 +0200 | [diff] [blame] | 112 | /** Load plugins, structures and settings from the config file given. |
| 113 | * |
| 114 | * @param[out] strError is a string describing the error if an error occurred |
| 115 | * undefined otherwise. |
| 116 | * |
| 117 | * @return true if no error occurred, false otherwise. |
| 118 | */ |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 119 | bool load(string& strError); |
| 120 | virtual bool init(string& strError); |
| 121 | |
| 122 | // Selection Criteria |
| 123 | CSelectionCriterionType* createSelectionCriterionType(bool bIsInclusive); |
| 124 | CSelectionCriterion* createSelectionCriterion(const string& strName, const CSelectionCriterionType* pSelectionCriterionType); |
| Patrick Benavoli | b71ccf7 | 2011-09-13 14:15:52 +0200 | [diff] [blame] | 125 | // Selection criterion retrieval |
| 126 | CSelectionCriterion* getSelectionCriterion(const string& strName); |
| 127 | |
| 128 | // Configuration application |
| Kevin Rocard | ace81f8 | 2012-12-11 16:19:17 +0100 | [diff] [blame] | 129 | void applyConfigurations(); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 130 | |
| Frederic Boisnard | 6cae0ec | 2013-05-23 18:48:58 +0200 | [diff] [blame] | 131 | /** |
| 132 | * Returns the CConfigurableElement corresponding to the path given in argument. |
| 133 | * |
| 134 | * @param[in] strPath A string representing a path to an element. |
| 135 | * @param[out] strError Error message |
| 136 | * |
| 137 | * @return A const pointer to the corresponding CConfigurableElement. |
| 138 | * On error, NULL is returned and the error is explained in strError. |
| 139 | */ |
| 140 | const CConfigurableElement* getConfigurableElement(const string& strPath, |
| 141 | string& strError) const; |
| Patrick Benavoli | 4bed921 | 2011-10-27 14:18:00 +0200 | [diff] [blame] | 142 | // Dynamic parameter handling |
| Patrick Benavoli | 065264a | 2011-11-20 15:46:41 +0100 | [diff] [blame] | 143 | CParameterHandle* createParameterHandle(const string& strPath, string& strError); |
| Patrick Benavoli | 4bed921 | 2011-10-27 14:18:00 +0200 | [diff] [blame] | 144 | |
| Kevin Rocard | ecf9310 | 2013-07-10 18:28:10 +0200 | [diff] [blame] | 145 | /** Should start fail in case of missing subsystems. |
| Kevin Rocard | ecf9310 | 2013-07-10 18:28:10 +0200 | [diff] [blame] | 146 | * |
| Kevin Rocard | d6909eb | 2013-07-18 09:13:51 +0200 | [diff] [blame] | 147 | * @param[in] bFail: If set to true, parameterMgr start will fail on missing subsystems. |
| 148 | * If set to false, missing subsystems will fallback on virtual subsystem. |
| Kevin Rocard | ecf9310 | 2013-07-10 18:28:10 +0200 | [diff] [blame] | 149 | */ |
| 150 | void setFailureOnMissingSubsystem(bool bFail); |
| 151 | |
| 152 | /** Would start fail in case of missing subsystems. |
| 153 | * |
| 154 | * @return true if the subsystem will fail on missing subsystem, false otherwise. |
| 155 | */ |
| 156 | bool getFailureOnMissingSubsystem() const; |
| 157 | |
| Kevin Rocard | d6909eb | 2013-07-18 09:13:51 +0200 | [diff] [blame] | 158 | /** Should start fail in failed settings load. |
| 159 | * |
| 160 | * @param[in] bFail: If set to true, parameterMgr start will fail on failed settings load. |
| 161 | * If set to false, failed settings load will be ignored. |
| 162 | */ |
| 163 | void setFailureOnFailedSettingsLoad(bool bFail); |
| 164 | /** Would start fail in case of failed settings load. |
| 165 | * |
| 166 | * @return failure on failed settings load policy state. |
| 167 | */ |
| 168 | bool getFailureOnFailedSettingsLoad(); |
| 169 | |
| Mattijs Korpershoek | cce85f6 | 2014-04-08 14:10:03 +0200 | [diff] [blame] | 170 | /** Should .xml files be validated on start ? |
| 171 | * |
| 172 | * @param[in] bValidate: |
| 173 | * If set to true, parameterMgr will report an error |
| 174 | * when being unable to validate .xml files |
| 175 | * If set to false, no .xml/xsd validation will happen |
| 176 | * (default behaviour) |
| 177 | * |
| 178 | * @return false if unable to set, true otherwise. |
| 179 | */ |
| 180 | void setValidateSchemasOnStart(bool bValidate); |
| 181 | |
| 182 | /** Would .xml files be validated on start? |
| 183 | * |
| 184 | * @return areSchemasValidated |
| 185 | */ |
| 186 | bool getValidateSchemasOnStart() const; |
| 187 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 188 | //////////// Tuning ///////////// |
| 189 | // Tuning mode |
| 190 | bool setTuningMode(bool bOn, string& strError); |
| 191 | bool tuningModeOn() const; |
| 192 | |
| 193 | // Current value space for user set/get value interpretation |
| 194 | void setValueSpace(bool bIsRaw); |
| 195 | bool valueSpaceIsRaw(); |
| 196 | |
| Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 197 | // Current Output Raw Format for user get value interpretation |
| 198 | void setOutputRawFormat(bool bIsHex); |
| 199 | bool outputRawFormatIsHex(); |
| 200 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 201 | // Automatic hardware synchronization control (during tuning session) |
| 202 | bool setAutoSync(bool bAutoSyncOn, string& strError); |
| 203 | bool autoSyncOn() const; |
| 204 | bool sync(string& strError); |
| 205 | |
| 206 | // User set/get parameters |
| Frédéric Boisnard | e42dacd | 2013-02-25 15:56:56 +0100 | [diff] [blame] | 207 | bool accessValue(CParameterAccessContext& parameterAccessContext, const string& strPath, string& strValue, bool bSet, string& strError); |
| 208 | bool accessParameterValue(const string& strPath, string& strValue, bool bSet, string& strError); |
| Frederic Boisnard | 6cae0ec | 2013-05-23 18:48:58 +0200 | [diff] [blame] | 209 | /** |
| 210 | * Returns the element mapping corresponding to the path given in parameter. |
| 211 | * |
| 212 | * @param[in] strPath Path of an element |
| 213 | * @param[out] strValue A sting containing the mapping |
| 214 | * |
| 215 | * @return true if a mapping was found for this element |
| 216 | */ |
| 217 | bool getParameterMapping(const string& strPath, string& strValue) const; |
| Frédéric Boisnard | e42dacd | 2013-02-25 15:56:56 +0100 | [diff] [blame] | 218 | bool accessConfigurationValue(const string &strDomain, const string &stConfiguration, const string& strPath, string& strValue, bool bSet, string& strError); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 219 | |
| 220 | ////////// Configuration/Domains handling ////////////// |
| 221 | // Creation/Deletion |
| 222 | bool createDomain(const string& strName, string& strError); |
| 223 | bool deleteDomain(const string& strName, string& strError); |
| Kevin Rocard | 170f0a4 | 2012-06-18 13:56:05 +0200 | [diff] [blame] | 224 | bool deleteAllDomains(string& strError); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 225 | bool createConfiguration(const string& strDomain, const string& strConfiguration, string& strError); |
| 226 | bool deleteConfiguration(const string& strDomain, const string& strConfiguration, string& strError); |
| 227 | |
| 228 | // Save/Restore |
| Kevin Rocard | ace81f8 | 2012-12-11 16:19:17 +0100 | [diff] [blame] | 229 | bool restoreConfiguration(const string& strDomain, const string& strConfiguration, list<string>& strError); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 230 | bool saveConfiguration(const string& strDomain, const string& strConfiguration, string& strError); |
| 231 | |
| 232 | // Configurable element - domain association |
| 233 | bool addConfigurableElementToDomain(const string& strDomain, const string& strConfigurableElementPath, string& strError); |
| 234 | bool removeConfigurableElementFromDomain(const string& strDomain, const string& strConfigurableElementPath, string& strError); |
| 235 | bool split(const string& strDomain, const string& strConfigurableElementPath, string& strError); |
| 236 | |
| Georges-Henri Baron | cec86c1 | 2012-09-04 17:30:28 +0200 | [diff] [blame] | 237 | /** |
| 238 | * Method that imports Configurable Domains from an Xml source. |
| 239 | * |
| 240 | * @param[in] strXmlSource a string containing an xml description or a path to an xml file |
| 241 | * @param[in] bWithSettings a boolean that determines if the settings should be used in the |
| 242 | * xml description |
| 243 | * @param[in] bFromFile a boolean that determines if the source is an xml description in |
| 244 | * strXmlSource or contained in a file. In that case strXmlSource is just the file path. |
| 245 | * @param[out] strError is used as the error output |
| 246 | * |
| 247 | * @return false if any error occures |
| 248 | */ |
| 249 | bool importDomainsXml(const string& strXmlSource, bool bWithSettings, bool bFromFile, |
| 250 | string& strError); |
| 251 | |
| 252 | /** |
| 253 | * Method that exports Configurable Domains to an Xml destination. |
| 254 | * If bToFile is false, the xml description from the xml document will be written |
| 255 | * in strXmlDest. Otherwise it will be written in a file located at the path in strXmlDest |
| 256 | * |
| 257 | * @param[in:out] strXmlDest a string containing an xml description or a path to an xml file |
| 258 | * @param[in] bWithSettings a boolean that determines if the settings should be used in the |
| 259 | * xml description |
| 260 | * @param[in] bToFile a boolean that determines if the destination is an xml description in |
| 261 | * strXmlDest or contained in a file. In that case strXmlDest is just the file path. |
| 262 | * @param[out] strError is used as the error output |
| 263 | * |
| 264 | * @return false if any error occures |
| 265 | */ |
| 266 | bool exportDomainsXml(string& strXmlDest, bool bWithSettings, bool bToFile, |
| 267 | string& strError) const; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 268 | |
| 269 | // Binary Import/Export |
| 270 | bool importDomainsBinary(const string& strFileName, string& strError); |
| 271 | bool exportDomainsBinary(const string& strFileName, string& strError); |
| 272 | |
| Georges-Henri Baron | cec86c1 | 2012-09-04 17:30:28 +0200 | [diff] [blame] | 273 | /** |
| 274 | * Method that creates an Xml description of the instanciated parameter structure contained |
| 275 | * in SystemClass. |
| 276 | * |
| 277 | * @param[out] strResult contains the xml description of SystemClass or the errors if any |
| 278 | * |
| 279 | * @return false if any error occures during the creation of the xml description |
| 280 | */ |
| Georges-Henri Baron | 326a31d | 2012-06-28 12:05:09 +0200 | [diff] [blame] | 281 | bool getSystemClassXMLString(string& strResult); |
| 282 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 283 | // Introspect |
| 284 | void logStructureContent(string& strContent) const; |
| 285 | |
| 286 | // CElement |
| 287 | virtual string getKind() const; |
| Kevin Rocard | ace81f8 | 2012-12-11 16:19:17 +0100 | [diff] [blame] | 288 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 289 | private: |
| JhinX Lee | 4ebc098 | 2012-07-12 17:50:07 +0200 | [diff] [blame] | 290 | CParameterMgr(const CParameterMgr&); |
| 291 | CParameterMgr& operator=(const CParameterMgr&); |
| 292 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 293 | // Logging (done by root) |
| Kevin Rocard | ace81f8 | 2012-12-11 16:19:17 +0100 | [diff] [blame] | 294 | virtual void doLog(bool bIsWarning, const string& strLog) const; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 295 | virtual void nestLog() const; |
| 296 | virtual void unnestLog() const; |
| 297 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 298 | // Version |
| 299 | string getVersion() const; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 300 | |
| 301 | ////////////////:: Remote command parsers |
| Patrick Benavoli | 592ae56 | 2011-09-05 16:53:58 +0200 | [diff] [blame] | 302 | /// Version |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 303 | CCommandHandler::CommandStatus versionCommandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 304 | /// Status |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 305 | CCommandHandler::CommandStatus statusCommandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 306 | /// Tuning Mode |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 307 | CCommandHandler::CommandStatus setTuningModeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| 308 | CCommandHandler::CommandStatus getTuningModeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 309 | /// Value Space |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 310 | CCommandHandler::CommandStatus setValueSpaceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| 311 | CCommandHandler::CommandStatus getValueSpaceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 312 | /// Output Raw Format |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 313 | CCommandHandler::CommandStatus setOutputRawFormatCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| 314 | CCommandHandler::CommandStatus getOutputRawFormatCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 315 | /// Sync |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 316 | CCommandHandler::CommandStatus setAutoSyncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| 317 | CCommandHandler::CommandStatus getAutoSyncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| 318 | CCommandHandler::CommandStatus syncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 319 | /// Criteria |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 320 | CCommandHandler::CommandStatus listCriteriaCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 321 | /// Domains |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 322 | CCommandHandler::CommandStatus listDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| 323 | CCommandHandler::CommandStatus createDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| 324 | CCommandHandler::CommandStatus deleteDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| Kevin Rocard | 170f0a4 | 2012-06-18 13:56:05 +0200 | [diff] [blame] | 325 | CCommandHandler::CommandStatus deleteAllDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 326 | CCommandHandler::CommandStatus renameDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| 327 | CCommandHandler::CommandStatus setSequenceAwarenessCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| 328 | CCommandHandler::CommandStatus getSequenceAwarenessCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| 329 | CCommandHandler::CommandStatus listDomainElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| 330 | CCommandHandler::CommandStatus addElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| 331 | CCommandHandler::CommandStatus removeElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| 332 | CCommandHandler::CommandStatus splitDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 333 | /// Configurations |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 334 | CCommandHandler::CommandStatus listConfigurationsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| Patrick Benavoli | 0bd5054 | 2011-11-29 11:10:27 +0100 | [diff] [blame] | 335 | CCommandHandler::CommandStatus dumpDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 336 | CCommandHandler::CommandStatus createConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| 337 | CCommandHandler::CommandStatus deleteConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| 338 | CCommandHandler::CommandStatus renameConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| 339 | CCommandHandler::CommandStatus saveConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| 340 | CCommandHandler::CommandStatus restoreConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| 341 | CCommandHandler::CommandStatus setElementSequenceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| 342 | CCommandHandler::CommandStatus getElementSequenceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| Patrick Benavoli | 0bd5054 | 2011-11-29 11:10:27 +0100 | [diff] [blame] | 343 | CCommandHandler::CommandStatus setRuleCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| 344 | CCommandHandler::CommandStatus clearRuleCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| 345 | CCommandHandler::CommandStatus getRuleCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 346 | /// Elements/Parameters |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 347 | CCommandHandler::CommandStatus listElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| 348 | CCommandHandler::CommandStatus listParametersCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| 349 | CCommandHandler::CommandStatus dumpElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| 350 | CCommandHandler::CommandStatus getElementSizeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| 351 | CCommandHandler::CommandStatus showPropertiesCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| 352 | CCommandHandler::CommandStatus getParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| 353 | CCommandHandler::CommandStatus setParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| Frédéric Boisnard | e42dacd | 2013-02-25 15:56:56 +0100 | [diff] [blame] | 354 | CCommandHandler::CommandStatus getConfigurationParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| 355 | CCommandHandler::CommandStatus setConfigurationParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 356 | CCommandHandler::CommandStatus listBelongingDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| 357 | CCommandHandler::CommandStatus listAssociatedDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| Frederic Boisnard | 6cae0ec | 2013-05-23 18:48:58 +0200 | [diff] [blame] | 358 | CCommandHandler::CommandStatus showMappingCommmandProcess(const IRemoteCommand& remoteCommand, |
| 359 | string& strResult); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 360 | /// Browse |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 361 | CCommandHandler::CommandStatus listAssociatedElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| 362 | CCommandHandler::CommandStatus listConflictingElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| 363 | CCommandHandler::CommandStatus listRogueElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 364 | /// Settings Import/Export |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 365 | CCommandHandler::CommandStatus exportConfigurableDomainsToXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| 366 | CCommandHandler::CommandStatus importConfigurableDomainsFromXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| 367 | CCommandHandler::CommandStatus exportConfigurableDomainsWithSettingsToXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| 368 | CCommandHandler::CommandStatus importConfigurableDomainsWithSettingsFromXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| 369 | CCommandHandler::CommandStatus exportSettingsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| 370 | CCommandHandler::CommandStatus importSettingsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult); |
| Georges-Henri Baron | cec86c1 | 2012-09-04 17:30:28 +0200 | [diff] [blame] | 371 | |
| 372 | /** |
| 373 | * Command handler method for getConfigurableDomainWithSettings command. |
| 374 | * |
| 375 | * @param[in] remoteCommand contains the arguments of the received command. |
| 376 | * @param[out] strResult a string containing the result of the command |
| 377 | * |
| 378 | * @return CCommandHandler::ESucceeded if command succeeded or CCommandHandler::EFailed |
| 379 | * in the other case |
| 380 | */ |
| 381 | CCommandHandler::CommandStatus getConfigurableDomainsWithSettingsXMLCommmandProcess( |
| 382 | const IRemoteCommand& remoteCommand, string& strResult); |
| 383 | |
| 384 | /** |
| 385 | * Command handler method for setConfigurableDomainWithSettings command. |
| 386 | * |
| 387 | * @param[in] remoteCommand contains the arguments of the received command. |
| 388 | * @param[out] strResult a string containing the result of the command |
| 389 | * |
| 390 | * @return CCommandHandler::ESucceeded if command succeeded or CCommandHandler::EFailed |
| 391 | * in the other case |
| 392 | */ |
| 393 | CCommandHandler::CommandStatus setConfigurableDomainsWithSettingsXMLCommmandProcess( |
| 394 | const IRemoteCommand& remoteCommand, string& strResult); |
| 395 | |
| 396 | /** |
| 397 | * Command handler method for getSystemClass command. |
| 398 | * |
| 399 | * @param[in] remoteCommand contains the arguments of the received command. |
| 400 | * @param[out] strResult a string containing the result of the command |
| 401 | * |
| 402 | * @return CCommandHandler::ESucceeded if command succeeded or CCommandHandler::EFailed |
| 403 | * in the other case |
| 404 | */ |
| 405 | CCommandHandler::CommandStatus getSystemClassXMLCommmandProcess( |
| 406 | const IRemoteCommand& remoteCommand, string& strResult); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 407 | |
| 408 | // Max command usage length, use for formatting |
| 409 | void setMaxCommandUsageLength(); |
| 410 | |
| 411 | // For tuning, check we're in tuning mode |
| 412 | bool checkTuningModeOn(string& strError) const; |
| 413 | |
| Patrick Benavoli | 065264a | 2011-11-20 15:46:41 +0100 | [diff] [blame] | 414 | // Blackboard (dynamic parameter handling) |
| 415 | pthread_mutex_t* getBlackboardMutex(); |
| 416 | |
| 417 | // Blackboard reference (dynamic parameter handling) |
| 418 | CParameterBlackboard* getParameterBlackboard(); |
| 419 | |
| Patrick Benavoli | 4bed921 | 2011-10-27 14:18:00 +0200 | [diff] [blame] | 420 | // Parameter access |
| Patrick Benavoli | 065264a | 2011-11-20 15:46:41 +0100 | [diff] [blame] | 421 | bool doSetValue(const string& strPath, const string& strValue, bool bRawValueSpace, bool bDynamicAccess, string& strError) const; |
| Patrick Benavoli | 4bed921 | 2011-10-27 14:18:00 +0200 | [diff] [blame] | 422 | bool doGetValue(const string& strPath, string& strValue, bool bRawValueSpace, bool bHexOutputRawFormat, bool bDynamicAccess, string& strError) const; |
| 423 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 424 | // Framework global configuration loading |
| 425 | bool loadFrameworkConfiguration(string& strError); |
| 426 | |
| 427 | // System class Structure loading |
| 428 | bool loadStructure(string& strError); |
| 429 | |
| 430 | // System class Structure loading |
| 431 | bool loadSettings(string& strError); |
| Kevin Rocard | d6909eb | 2013-07-18 09:13:51 +0200 | [diff] [blame] | 432 | bool loadSettingsFromConfigFile(string& strError); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 433 | |
| 434 | // Parse XML file into Root element |
| 435 | bool xmlParse(CXmlElementSerializingContext& elementSerializingContext, CElement* pRootElement, const string& strXmlFilePath, const string& strXmlFolder, ElementLibrary eElementLibrary, const string& strNameAttrituteName = "Name"); |
| 436 | |
| 437 | // Framework Configuration |
| 438 | CParameterFrameworkConfiguration* getFrameworkConfiguration(); |
| 439 | const CParameterFrameworkConfiguration* getConstFrameworkConfiguration(); |
| 440 | |
| 441 | // Selection Criteria |
| 442 | CSelectionCriteria* getSelectionCriteria(); |
| 443 | const CSelectionCriteria* getConstSelectionCriteria(); |
| 444 | |
| 445 | // System Class |
| 446 | CSystemClass* getSystemClass(); |
| 447 | const CSystemClass* getConstSystemClass() const; |
| 448 | |
| 449 | // Configurable Domains |
| 450 | CConfigurableDomains* getConfigurableDomains(); |
| 451 | const CConfigurableDomains* getConstConfigurableDomains(); |
| 452 | const CConfigurableDomains* getConstConfigurableDomains() const; |
| 453 | |
| Guillaume Denneulin | f2fd15a | 2012-12-20 17:53:29 +0100 | [diff] [blame] | 454 | // Apply configurations |
| 455 | void doApplyConfigurations(bool bForce); |
| 456 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 457 | // Dynamic object creation libraries feeding |
| 458 | void feedElementLibraries(); |
| 459 | |
| 460 | // Remote Processor Server connection handling |
| 461 | bool handleRemoteProcessingInterface(string& strError); |
| 462 | |
| 463 | // Back synchronization |
| Kevin Rocard | ace81f8 | 2012-12-11 16:19:17 +0100 | [diff] [blame] | 464 | CBackSynchronizer* createBackSynchronizer() const; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 465 | |
| 466 | // Tuning |
| 467 | bool _bTuningModeIsOn; |
| 468 | |
| 469 | // Value Space |
| 470 | bool _bValueSpaceIsRaw; |
| 471 | |
| Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 472 | // Output Raw Format |
| 473 | bool _bOutputRawFormatIsHex; |
| 474 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 475 | // Automatic synchronization to HW during Tuning session |
| 476 | bool _bAutoSyncOn; |
| 477 | |
| 478 | // Current Parameter Settings |
| 479 | CParameterBlackboard* _pMainParameterBlackboard; |
| 480 | |
| 481 | // Dynamic object creation |
| 482 | CElementLibrarySet* _pElementLibrarySet; |
| 483 | |
| 484 | // XML parsing, object creation handling |
| Patrick Benavoli | 95ac034 | 2011-11-07 20:32:51 +0100 | [diff] [blame] | 485 | string _strXmlConfigurationFilePath; // Configuration file path |
| 486 | string _strXmlConfigurationFolderPath; // Root folder for configuration file |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 487 | string _strSchemaFolderLocation; // Place where schemas stand |
| 488 | |
| 489 | // Subsystem plugin location |
| Guillaume Denneulin | a4ec15d | 2012-02-17 14:38:14 +0100 | [diff] [blame] | 490 | const CSubsystemPlugins* _pSubsystemPlugins; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 491 | |
| Renaud de Chivre | 1b8b3ca | 2013-12-13 15:09:44 +0100 | [diff] [blame] | 492 | // Remote processor library handle |
| 493 | void *_handleLibRemoteProcessor; |
| 494 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 495 | // Whole system structure checksum |
| 496 | uint8_t _uiStructureChecksum; |
| 497 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 498 | // Command Handler |
| 499 | CCommandHandler* _pCommandHandler; |
| 500 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 501 | // Remote Processor Server |
| 502 | IRemoteProcessorServerInterface* _pRemoteProcessorServer; |
| 503 | |
| 504 | // Parser description array |
| Patrick Benavoli | 592ae56 | 2011-09-05 16:53:58 +0200 | [diff] [blame] | 505 | static const SRemoteCommandParserItem gastRemoteCommandParserItems[]; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 506 | |
| 507 | // Parser description array size |
| 508 | static const uint32_t guiNbRemoteCommandParserItems; |
| 509 | |
| 510 | // Maximum command usage length |
| 511 | uint32_t _uiMaxCommandUsageLength; |
| 512 | |
| Patrick Benavoli | 065264a | 2011-11-20 15:46:41 +0100 | [diff] [blame] | 513 | // Blackboard access mutex |
| 514 | pthread_mutex_t _blackboardMutex; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 515 | |
| 516 | // Logging |
| 517 | ILogger* _pLogger; |
| Patrick Benavoli | 592ae56 | 2011-09-05 16:53:58 +0200 | [diff] [blame] | 518 | mutable uint32_t _uiLogDepth; |
| Kevin Rocard | ecf9310 | 2013-07-10 18:28:10 +0200 | [diff] [blame] | 519 | |
| 520 | /** If set to true, missing subsystem will abort parameterMgr start. |
| 521 | * If set to false, missing subsystem will fallback on virtual subsystem. |
| 522 | */ |
| 523 | bool _bFailOnMissingSubsystem; |
| Kevin Rocard | d6909eb | 2013-07-18 09:13:51 +0200 | [diff] [blame] | 524 | /** If set to true, unparsable or discording domains will abort parameterMgr start. |
| 525 | * If set to false, unparsable or discording domains |
| 526 | * will continue the parameterMgr start with no domains. |
| 527 | */ |
| 528 | bool _bFailOnFailedSettingsLoad; |
| Mattijs Korpershoek | cce85f6 | 2014-04-08 14:10:03 +0200 | [diff] [blame] | 529 | |
| 530 | /** |
| 531 | * If set to true, parameterMgr will report an error |
| 532 | * when being unable to validate .xml files |
| 533 | * If set to false, no .xml/xsd validation will happen (default behaviour) |
| 534 | */ |
| 535 | bool _bValidateSchemasOnStart; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 536 | }; |
| 537 | |