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