blob: 8016cb944384ed0768110c8654232eac188236b3 [file] [log] [blame]
David Wagnerb76c9d62014-02-05 18:30:24 +01001/*
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 Benavoli68a91282011-08-31 11:23:23 +020029 */
30#pragma once
31
32#include "BinarySerializableElement.h"
33#include <set>
Kevin Rocardace81f82012-12-11 16:19:17 +010034#include <list>
Sebastien Gonzalved9526492014-02-20 22:28:03 +010035#include <string>
Kevin Rocardace81f82012-12-11 16:19:17 +010036
Patrick Benavoli68a91282011-08-31 11:23:23 +020037
38class CParameterBlackboard;
39class CConfigurableElement;
40class CSyncerSet;
Patrick Benavoli0bd50542011-11-29 11:10:27 +010041class CConfigurableDomain;
42class CSelectionCriteriaDefinition;
Patrick Benavoli68a91282011-08-31 11:23:23 +020043
44class CConfigurableDomains : public CBinarySerializableElement
45{
46public:
Patrick Benavoli95ac0342011-11-07 20:32:51 +010047 CConfigurableDomains();
Patrick Benavoli68a91282011-08-31 11:23:23 +020048
49 // Configuration/Domains handling
50 /// Domains
Sebastien Gonzalved9526492014-02-20 22:28:03 +010051 bool createDomain(const std::string& strName, std::string& strError);
52 bool deleteDomain(const std::string& strName, std::string& strError);
Kevin Rocard170f0a42012-06-18 13:56:05 +020053 void deleteAllDomains();
Sebastien Gonzalved9526492014-02-20 22:28:03 +010054 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 Benavoli68a91282011-08-31 11:23:23 +020062 /// Configurations
Sebastien Gonzalved9526492014-02-20 22:28:03 +010063 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 Benavoli68a91282011-08-31 11:23:23 +020074
75 // Last applied configurations
Sebastien Gonzalved9526492014-02-20 22:28:03 +010076 void listLastAppliedConfigurations(std::string& strResult) const;
Patrick Benavoli68a91282011-08-31 11:23:23 +020077
78 // Configurable element - domain association
Sebastien Gonzalved9526492014-02-20 22:28:03 +010079 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 Benavoli68a91282011-08-31 11:23:23 +020081
Frédéric Boisnarde42dacd2013-02-25 15:56:56 +010082 // Configuration Blackboard for element
Sebastien Gonzalved9526492014-02-20 22:28:03 +010083 CParameterBlackboard* findConfigurationBlackboard(const std::string& strDomain,
84 const std::string& strConfiguration,
Frédéric Boisnarde42dacd2013-02-25 15:56:56 +010085 const CConfigurableElement* pConfigurableElement,
86 uint32_t& uiBaseOffset,
87 bool& bIsLastApplied,
Sebastien Gonzalved9526492014-02-20 22:28:03 +010088 std::string& strError) const;
Frédéric Boisnarde42dacd2013-02-25 15:56:56 +010089
David Wagnered744eb2014-12-04 18:38:52 +010090 const CConfigurableDomain* findConfigurableDomain(const std::string& strDomain,
91 std::string& strError) const;
92
Patrick Benavoli68a91282011-08-31 11:23:23 +020093 // Binary settings load/store
Sebastien Gonzalved9526492014-02-20 22:28:03 +010094 bool serializeSettings(const std::string& strBinarySettingsFilePath, bool bOut, uint8_t uiStructureChecksum, std::string& strError);
Patrick Benavoli68a91282011-08-31 11:23:23 +020095
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 Denneulinf2fd15a2012-12-20 17:53:29 +0100103 void apply(CParameterBlackboard* pParameterBlackboard, CSyncerSet& syncerSet, bool bForce) const;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200104
105 // Class kind
Sebastien Gonzalved9526492014-02-20 22:28:03 +0100106 virtual std::string getKind() const;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200107private:
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 Gonzalved9526492014-02-20 22:28:03 +0100111 void gatherAllOwnedConfigurableElements(std::set<const CConfigurableElement*>& configurableElementSet) const;
Patrick Benavoli0bd50542011-11-29 11:10:27 +0100112 // Domain retrieval
Sebastien Gonzalved9526492014-02-20 22:28:03 +0100113 CConfigurableDomain* findConfigurableDomain(const std::string& strDomain, std::string& strError);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200114};
115