| 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 "BinarySerializableElement.h" |
| 33 | #include <set> |
| Kevin Rocard | ace81f8 | 2012-12-11 16:19:17 +0100 | [diff] [blame] | 34 | #include <list> |
| 35 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 36 | |
| 37 | class CParameterBlackboard; |
| 38 | class CConfigurableElement; |
| 39 | class CSyncerSet; |
| Patrick Benavoli | 0bd5054 | 2011-11-29 11:10:27 +0100 | [diff] [blame] | 40 | class CConfigurableDomain; |
| 41 | class CSelectionCriteriaDefinition; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 42 | |
| 43 | class CConfigurableDomains : public CBinarySerializableElement |
| 44 | { |
| 45 | public: |
| Patrick Benavoli | 95ac034 | 2011-11-07 20:32:51 +0100 | [diff] [blame] | 46 | CConfigurableDomains(); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 47 | |
| 48 | // Configuration/Domains handling |
| 49 | /// Domains |
| 50 | bool createDomain(const string& strName, string& strError); |
| 51 | bool deleteDomain(const string& strName, string& strError); |
| Kevin Rocard | 170f0a4 | 2012-06-18 13:56:05 +0200 | [diff] [blame] | 52 | void deleteAllDomains(); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 53 | bool renameDomain(const string& strName, const string& strNewName, string& strError); |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 54 | bool setSequenceAwareness(const string& strDomain, bool bSequenceAware, string& strError); |
| 55 | bool getSequenceAwareness(const string& strDomain, bool& bSequenceAware, string& strError) const; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 56 | bool listDomainElements(const string& strDomain, string& strResult) const; |
| 57 | bool split(const string& strDomain, CConfigurableElement* pConfigurableElement, string& strError); |
| 58 | void listAssociatedElements(string& strResult) const; |
| 59 | void listConflictingElements(string& strResult) const; |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 60 | void listDomains(string& strResult) const; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 61 | /// Configurations |
| 62 | bool listConfigurations(const string& strDomain, string& strResult) const; |
| 63 | bool createConfiguration(const string& strDomain, const string& strConfiguration, const CParameterBlackboard* pMainBlackboard, string& strError); |
| 64 | bool deleteConfiguration(const string& strDomain, const string& strConfiguration, string& strError); |
| 65 | bool renameConfiguration(const string& strDomain, const string& strConfigurationName, const string& strNewConfigurationName, string& strError); |
| Kevin Rocard | ace81f8 | 2012-12-11 16:19:17 +0100 | [diff] [blame] | 66 | bool restoreConfiguration(const string& strDomain, const string& strConfiguration, CParameterBlackboard* pMainBlackboard, bool bAutoSync, list<string>& lstrError) const; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 67 | bool saveConfiguration(const string& strDomain, const string& strConfiguration, const CParameterBlackboard* pMainBlackboard, string& strError); |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 68 | bool setElementSequence(const string& strDomain, const string& strConfiguration, const vector<string>& astrNewElementSequence, string& strError); |
| 69 | bool getElementSequence(const string& strDomain, const string& strConfiguration, string& strResult) const; |
| Patrick Benavoli | 0bd5054 | 2011-11-29 11:10:27 +0100 | [diff] [blame] | 70 | bool setApplicationRule(const string& strDomain, const string& strConfiguration, const string& strApplicationRule, const CSelectionCriteriaDefinition* pSelectionCriteriaDefinition, string& strError); |
| 71 | bool clearApplicationRule(const string& strDomain, const string& strConfiguration, string& strError); |
| 72 | bool getApplicationRule(const string& strDomain, const string& strConfiguration, string& strResult) const; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 73 | |
| 74 | // Last applied configurations |
| 75 | void listLastAppliedConfigurations(string& strResult) const; |
| 76 | |
| 77 | // Configurable element - domain association |
| 78 | bool addConfigurableElementToDomain(const string& strDomain, CConfigurableElement* pConfigurableElement, const CParameterBlackboard* pMainBlackboard, string& strError); |
| 79 | bool removeConfigurableElementFromDomain(const string& strDomain, CConfigurableElement* pConfigurableElement, string& strError); |
| 80 | |
| Frédéric Boisnard | e42dacd | 2013-02-25 15:56:56 +0100 | [diff] [blame] | 81 | // Configuration Blackboard for element |
| 82 | CParameterBlackboard* findConfigurationBlackboard(const string& strDomain, |
| 83 | const string& strConfiguration, |
| 84 | const CConfigurableElement* pConfigurableElement, |
| 85 | uint32_t& uiBaseOffset, |
| 86 | bool& bIsLastApplied, |
| 87 | string& strError) const; |
| 88 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 89 | // Binary settings load/store |
| 90 | bool serializeSettings(const string& strBinarySettingsFilePath, bool bOut, uint8_t uiStructureChecksum, string& strError); |
| 91 | |
| 92 | // From IXmlSource |
| 93 | virtual void toXml(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const; |
| 94 | |
| 95 | // Ensure validity on whole domains from main blackboard |
| 96 | void validate(const CParameterBlackboard* pMainBlackboard); |
| 97 | |
| 98 | // Configuration application if required |
| Guillaume Denneulin | f2fd15a | 2012-12-20 17:53:29 +0100 | [diff] [blame] | 99 | void apply(CParameterBlackboard* pParameterBlackboard, CSyncerSet& syncerSet, bool bForce) const; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 100 | |
| 101 | // Class kind |
| 102 | virtual string getKind() const; |
| 103 | private: |
| 104 | // Returns true if children dynamic creation is to be dealt with |
| 105 | virtual bool childrenAreDynamic() const; |
| 106 | // Gather owned configurable elements owned by any domain |
| 107 | void gatherAllOwnedConfigurableElements(set<const CConfigurableElement*>& configurableElementSet) const; |
| Patrick Benavoli | 0bd5054 | 2011-11-29 11:10:27 +0100 | [diff] [blame] | 108 | // Domain retrieval |
| 109 | CConfigurableDomain* findConfigurableDomain(const string& strDomain, string& strError); |
| 110 | const CConfigurableDomain* findConfigurableDomain(const string& strDomain, string& strError) const; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 111 | }; |
| 112 | |