blob: ddad2d2b52e64eb6ea7c5d18913dacf06987d82b [file] [log] [blame]
Frédéric Boisnarde42dacd2013-02-25 15:56:56 +01001/*
Patrick Benavoli68a91282011-08-31 11:23:23 +02002 * INTEL CONFIDENTIAL
3 * Copyright © 2011 Intel
4 * Corporation All Rights Reserved.
5 *
6 * The source code contained or described herein and all documents related to
7 * the source code ("Material") are owned by Intel Corporation or its suppliers
8 * or licensors. Title to the Material remains with Intel Corporation or its
9 * suppliers and licensors. The Material contains trade secrets and proprietary
10 * and confidential information of Intel or its suppliers and licensors. The
11 * Material is protected by worldwide copyright and trade secret laws and
12 * treaty provisions. No part of the Material may be used, copied, reproduced,
13 * modified, published, uploaded, posted, transmitted, distributed, or
14 * disclosed in any way without Intel’s prior express written permission.
15 *
16 * No license under any patent, copyright, trade secret or other intellectual
17 * property right is granted to or conferred upon you by disclosure or delivery
18 * of the Materials, either expressly, by implication, inducement, estoppel or
19 * otherwise. Any license under such intellectual property rights must be
20 * express and approved by Intel in writing.
21 *
Patrick Benavoli68a91282011-08-31 11:23:23 +020022 * CREATED: 2011-06-01
23 * UPDATED: 2011-07-27
Patrick Benavoli68a91282011-08-31 11:23:23 +020024 */
25#pragma once
26
27#include "BinarySerializableElement.h"
28#include "SyncerSet.h"
29#include <list>
30#include <set>
Patrick Benavoli63499d42011-10-24 18:50:03 +020031#include <map>
Patrick Benavoli68a91282011-08-31 11:23:23 +020032
33class CConfigurableElement;
34class CDomainConfiguration;
35class CParameterBlackboard;
Patrick Benavoli0bd50542011-11-29 11:10:27 +010036class CSelectionCriteriaDefinition;
Patrick Benavoli68a91282011-08-31 11:23:23 +020037
38class CConfigurableDomain : public CBinarySerializableElement
39{
40 typedef list<CConfigurableElement*>::const_iterator ConfigurableElementListIterator;
Patrick Benavoli63499d42011-10-24 18:50:03 +020041 typedef map<const CConfigurableElement*, CSyncerSet*>::const_iterator ConfigurableElementToSyncerSetMapIterator;
Patrick Benavoli68a91282011-08-31 11:23:23 +020042public:
43 CConfigurableDomain(const string& strName);
44 virtual ~CConfigurableDomain();
45
Patrick Benavoli63499d42011-10-24 18:50:03 +020046 // Sequence awareness
47 void setSequenceAwareness(bool bSequenceAware);
48 bool getSequenceAwareness() const;
49
Patrick Benavoli68a91282011-08-31 11:23:23 +020050 // Configuration Management
51 bool createConfiguration(const string& strName, const CParameterBlackboard* pMainBlackboard, string& strError);
52 bool deleteConfiguration(const string& strName, string& strError);
53 bool renameConfiguration(const string& strName, const string& strNewName, string& strError);
Kevin Rocardace81f82012-12-11 16:19:17 +010054 bool restoreConfiguration(const string& strName, CParameterBlackboard* pMainBlackboard, bool bAutoSync, list<string>& strError) const;
Patrick Benavoli68a91282011-08-31 11:23:23 +020055 bool saveConfiguration(const string& strName, const CParameterBlackboard* pMainBlackboard, string& strError);
Patrick Benavoli0bd50542011-11-29 11:10:27 +010056 bool setElementSequence(const string& strConfiguration, const vector<string>& astrNewElementSequence, string& strError);
57 bool getElementSequence(const string& strConfiguration, string& strResult) const;
58 bool setApplicationRule(const string& strConfiguration, const string& strApplicationRule, const CSelectionCriteriaDefinition* pSelectionCriteriaDefinition, string& strError);
59 bool clearApplicationRule(const string& strConfiguration, string& strError);
60 bool getApplicationRule(const string& strConfiguration, string& strResult) const;
Patrick Benavoli68a91282011-08-31 11:23:23 +020061
Frédéric Boisnard8b243f52012-09-06 18:03:20 +020062 // Last applied configuration name
Patrick Benavoli68a91282011-08-31 11:23:23 +020063 string getLastAppliedConfigurationName() const;
64
Frédéric Boisnard8b243f52012-09-06 18:03:20 +020065 // Pending configuration name
66 string getPendingConfigurationName() const;
67
Patrick Benavoli68a91282011-08-31 11:23:23 +020068 // Associated Configurable elements
69 void gatherConfigurableElements(set<const CConfigurableElement*>& configurableElementSet) const;
70 void listAssociatedToElements(string& strResult) const;
71
72 // Configurable elements association
73 bool addConfigurableElement(CConfigurableElement* pConfigurableElement, const CParameterBlackboard* pMainBlackboard, string& strError);
74 bool removeConfigurableElement(CConfigurableElement* pConfigurableElement, string& strError);
75
Frédéric Boisnarde42dacd2013-02-25 15:56:56 +010076 // Blackboard Configuration and Base Offset retrieval
77 CParameterBlackboard* findConfigurationBlackboard(const string& strConfiguration,
78 const CConfigurableElement* pConfigurableElement,
79 uint32_t& uiBaseOffset,
80 bool& bIsLastApplied,
81 string& strError) const;
82
Patrick Benavoli68a91282011-08-31 11:23:23 +020083 // Domain splitting
84 bool split(CConfigurableElement* pConfigurableElement, string& strError);
85
86 // Ensure validity on whole domain from main blackboard
87 void validate(const CParameterBlackboard* pMainBlackboard);
88
89 // Configuration application if required
Guillaume Denneulinf2fd15a2012-12-20 17:53:29 +010090 void apply(CParameterBlackboard* pParameterBlackboard, CSyncerSet* pSyncerSet, bool bForced) const;
Patrick Benavoli68a91282011-08-31 11:23:23 +020091
92 // Return applicable configuration validity for given configurable element
93 bool isApplicableConfigurationValid(const CConfigurableElement* pConfigurableElement) const;
94
Patrick Benavoli68a91282011-08-31 11:23:23 +020095 // From IXmlSink
96 virtual bool fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext);
97
98 // From IXmlSource
99 virtual void toXml(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const;
100
101 // Class kind
102 virtual string getKind() const;
Frédéric Boisnard8b243f52012-09-06 18:03:20 +0200103
Patrick Benavoli0bd50542011-11-29 11:10:27 +0100104protected:
105 // Content dumping
106 virtual void logValue(string& strValue, CErrorContext& errorContext) const;
Frédéric Boisnard8b243f52012-09-06 18:03:20 +0200107
Patrick Benavoli68a91282011-08-31 11:23:23 +0200108private:
Frédéric Boisnard8b243f52012-09-06 18:03:20 +0200109 // Get pending configuration
110 const CDomainConfiguration* getPendingConfiguration() const;
111
112 // Search for an applicable configuration
113 const CDomainConfiguration* findApplicableDomainConfiguration() const;
114
Patrick Benavoli68a91282011-08-31 11:23:23 +0200115 // Returns true if children dynamic creation is to be dealt with (here, will allow child deletion upon clean)
116 virtual bool childrenAreDynamic() const;
117
118 // Ensure validity on areas related to configurable element
119 void validateAreas(const CConfigurableElement* pConfigurableElement, const CParameterBlackboard* pMainBlackboard);
120
121 // Attempt validation for all configurable element's areas, relying on already existing valid configuration inside domain
122 void autoValidateAll();
123
124 // Attempt validation for one configurable element's areas, relying on already existing valid configuration inside domain
125 void autoValidateAreas(const CConfigurableElement* pConfigurableElement);
126
127 // Attempt configuration validation for all configurable elements' areas, relying on already existing valid configuration inside domain
128 bool autoValidateConfiguration(CDomainConfiguration* pDomainConfiguration);
129
130 // Search for a valid configuration for given configurable element
131 const CDomainConfiguration* findValidDomainConfiguration(const CConfigurableElement* pConfigurableElement) const;
132
Patrick Benavoli68a91282011-08-31 11:23:23 +0200133
134 // In case configurable element was removed
135 void computeSyncSet();
136
137 // Check configurable element already attached
138 bool containsConfigurableElement(const CConfigurableElement* pConfigurableCandidateElement) const;
139
140 // Merge any descended configurable element to this one
141 void mergeAlreadyAssociatedDescendantConfigurableElements(CConfigurableElement* pNewConfigurableElement);
142 void mergeConfigurations(CConfigurableElement* pToConfigurableElement, CConfigurableElement* pFromConfigurableElement);
143
144 // Configurable elements association
Frédéric Boisnard9620e442012-05-30 16:15:02 +0200145 void doAddConfigurableElement(CConfigurableElement* pConfigurableElement, const CParameterBlackboard* pMainBlackboard = NULL);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200146 void doRemoveConfigurableElement(CConfigurableElement* pConfigurableElement, bool bRecomputeSyncSet);
147
148 // XML parsing
149 bool parseDomainConfigurations(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext);
150 bool parseConfigurableElements(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext);
Patrick Benavoli63499d42011-10-24 18:50:03 +0200151 bool parseSettings(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200152
153 // XML composing
154 void composeDomainConfigurations(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const;
Patrick Benavoli63499d42011-10-24 18:50:03 +0200155 void composeConfigurableElements(CXmlElement& xmlElement) const;
156 void composeSettings(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const;
157
158 // Syncer set retrieval from configurable element
159 CSyncerSet* getSyncerSet(const CConfigurableElement* pConfigurableElement) const;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200160
Patrick Benavoli0bd50542011-11-29 11:10:27 +0100161 // Configuration retrieval
162 CDomainConfiguration* findConfiguration(const string& strConfiguration, string& strError);
163 const CDomainConfiguration* findConfiguration(const string& strConfiguration, string& strError) const;
164
Patrick Benavoli68a91282011-08-31 11:23:23 +0200165 // Configurable elements
166 list<CConfigurableElement*> _configurableElementList;
167
Patrick Benavoli63499d42011-10-24 18:50:03 +0200168 // Associated syncer sets
169 map<const CConfigurableElement*, CSyncerSet*> _configurableElementToSyncerSetMap;
170
171 // Sequence awareness
172 bool _bSequenceAware;
173
Patrick Benavoli68a91282011-08-31 11:23:23 +0200174 // Syncer set used to ensure propoer synchronization of restored configurable elements
175 CSyncerSet _syncerSet;
176
177 // Last applied configuration
Patrick Benavoli63499d42011-10-24 18:50:03 +0200178 mutable const CDomainConfiguration* _pLastAppliedConfiguration;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200179};
180