blob: 604b821e443c919afc90249ed01f7323e70fb02b [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>
35
Patrick Benavoli68a91282011-08-31 11:23:23 +020036
37class CParameterBlackboard;
38class CConfigurableElement;
39class CSyncerSet;
Patrick Benavoli0bd50542011-11-29 11:10:27 +010040class CConfigurableDomain;
41class CSelectionCriteriaDefinition;
Patrick Benavoli68a91282011-08-31 11:23:23 +020042
43class CConfigurableDomains : public CBinarySerializableElement
44{
45public:
Patrick Benavoli95ac0342011-11-07 20:32:51 +010046 CConfigurableDomains();
Patrick Benavoli68a91282011-08-31 11:23:23 +020047
48 // Configuration/Domains handling
49 /// Domains
50 bool createDomain(const string& strName, string& strError);
51 bool deleteDomain(const string& strName, string& strError);
Kevin Rocard170f0a42012-06-18 13:56:05 +020052 void deleteAllDomains();
Patrick Benavoli68a91282011-08-31 11:23:23 +020053 bool renameDomain(const string& strName, const string& strNewName, string& strError);
Patrick Benavoli63499d42011-10-24 18:50:03 +020054 bool setSequenceAwareness(const string& strDomain, bool bSequenceAware, string& strError);
55 bool getSequenceAwareness(const string& strDomain, bool& bSequenceAware, string& strError) const;
Patrick Benavoli68a91282011-08-31 11:23:23 +020056 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 Benavoli63499d42011-10-24 18:50:03 +020060 void listDomains(string& strResult) const;
Patrick Benavoli68a91282011-08-31 11:23:23 +020061 /// 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 Rocardace81f82012-12-11 16:19:17 +010066 bool restoreConfiguration(const string& strDomain, const string& strConfiguration, CParameterBlackboard* pMainBlackboard, bool bAutoSync, list<string>& lstrError) const;
Patrick Benavoli68a91282011-08-31 11:23:23 +020067 bool saveConfiguration(const string& strDomain, const string& strConfiguration, const CParameterBlackboard* pMainBlackboard, string& strError);
Patrick Benavoli63499d42011-10-24 18:50:03 +020068 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 Benavoli0bd50542011-11-29 11:10:27 +010070 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 Benavoli68a91282011-08-31 11:23:23 +020073
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 Boisnarde42dacd2013-02-25 15:56:56 +010081 // 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 Benavoli68a91282011-08-31 11:23:23 +020089 // 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 Denneulinf2fd15a2012-12-20 17:53:29 +010099 void apply(CParameterBlackboard* pParameterBlackboard, CSyncerSet& syncerSet, bool bForce) const;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200100
101 // Class kind
102 virtual string getKind() const;
103private:
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 Benavoli0bd50542011-11-29 11:10:27 +0100108 // Domain retrieval
109 CConfigurableDomain* findConfigurableDomain(const string& strDomain, string& strError);
110 const CConfigurableDomain* findConfigurableDomain(const string& strDomain, string& strError) const;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200111};
112