blob: 29e92cbc32236bd5196dbe40fe97f10abea9163b [file] [log] [blame]
Kevin Rocard93250d12012-07-19 17:48:30 +02001/*
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);
Patrick Benavoli0bd50542011-11-29 11:10:27 +010054 bool restoreConfiguration(const string& strName, CParameterBlackboard* pMainBlackboard, bool bAutoSync, 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
76 // Domain splitting
77 bool split(CConfigurableElement* pConfigurableElement, string& strError);
78
79 // Ensure validity on whole domain from main blackboard
80 void validate(const CParameterBlackboard* pMainBlackboard);
81
82 // Configuration application if required
Patrick Benavoli63499d42011-10-24 18:50:03 +020083 bool apply(CParameterBlackboard* pParameterBlackboard, CSyncerSet& syncerSet, bool bForced, string& strError) const;
Patrick Benavoli68a91282011-08-31 11:23:23 +020084
85 // Return applicable configuration validity for given configurable element
86 bool isApplicableConfigurationValid(const CConfigurableElement* pConfigurableElement) const;
87
Patrick Benavoli68a91282011-08-31 11:23:23 +020088 // From IXmlSink
89 virtual bool fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext);
90
91 // From IXmlSource
92 virtual void toXml(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const;
93
94 // Class kind
95 virtual string getKind() const;
Frédéric Boisnard8b243f52012-09-06 18:03:20 +020096
Patrick Benavoli0bd50542011-11-29 11:10:27 +010097protected:
98 // Content dumping
99 virtual void logValue(string& strValue, CErrorContext& errorContext) const;
Frédéric Boisnard8b243f52012-09-06 18:03:20 +0200100
Patrick Benavoli68a91282011-08-31 11:23:23 +0200101private:
Frédéric Boisnard8b243f52012-09-06 18:03:20 +0200102 // Get pending configuration
103 const CDomainConfiguration* getPendingConfiguration() const;
104
105 // Search for an applicable configuration
106 const CDomainConfiguration* findApplicableDomainConfiguration() const;
107
Patrick Benavoli68a91282011-08-31 11:23:23 +0200108 // Returns true if children dynamic creation is to be dealt with (here, will allow child deletion upon clean)
109 virtual bool childrenAreDynamic() const;
110
111 // Ensure validity on areas related to configurable element
112 void validateAreas(const CConfigurableElement* pConfigurableElement, const CParameterBlackboard* pMainBlackboard);
113
114 // Attempt validation for all configurable element's areas, relying on already existing valid configuration inside domain
115 void autoValidateAll();
116
117 // Attempt validation for one configurable element's areas, relying on already existing valid configuration inside domain
118 void autoValidateAreas(const CConfigurableElement* pConfigurableElement);
119
120 // Attempt configuration validation for all configurable elements' areas, relying on already existing valid configuration inside domain
121 bool autoValidateConfiguration(CDomainConfiguration* pDomainConfiguration);
122
123 // Search for a valid configuration for given configurable element
124 const CDomainConfiguration* findValidDomainConfiguration(const CConfigurableElement* pConfigurableElement) const;
125
Patrick Benavoli68a91282011-08-31 11:23:23 +0200126
127 // In case configurable element was removed
128 void computeSyncSet();
129
130 // Check configurable element already attached
131 bool containsConfigurableElement(const CConfigurableElement* pConfigurableCandidateElement) const;
132
133 // Merge any descended configurable element to this one
134 void mergeAlreadyAssociatedDescendantConfigurableElements(CConfigurableElement* pNewConfigurableElement);
135 void mergeConfigurations(CConfigurableElement* pToConfigurableElement, CConfigurableElement* pFromConfigurableElement);
136
137 // Configurable elements association
Frédéric Boisnard9620e442012-05-30 16:15:02 +0200138 void doAddConfigurableElement(CConfigurableElement* pConfigurableElement, const CParameterBlackboard* pMainBlackboard = NULL);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200139 void doRemoveConfigurableElement(CConfigurableElement* pConfigurableElement, bool bRecomputeSyncSet);
140
141 // XML parsing
142 bool parseDomainConfigurations(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext);
143 bool parseConfigurableElements(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext);
Patrick Benavoli63499d42011-10-24 18:50:03 +0200144 bool parseSettings(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200145
146 // XML composing
147 void composeDomainConfigurations(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const;
Patrick Benavoli63499d42011-10-24 18:50:03 +0200148 void composeConfigurableElements(CXmlElement& xmlElement) const;
149 void composeSettings(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const;
150
151 // Syncer set retrieval from configurable element
152 CSyncerSet* getSyncerSet(const CConfigurableElement* pConfigurableElement) const;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200153
Patrick Benavoli0bd50542011-11-29 11:10:27 +0100154 // Configuration retrieval
155 CDomainConfiguration* findConfiguration(const string& strConfiguration, string& strError);
156 const CDomainConfiguration* findConfiguration(const string& strConfiguration, string& strError) const;
157
Patrick Benavoli68a91282011-08-31 11:23:23 +0200158 // Configurable elements
159 list<CConfigurableElement*> _configurableElementList;
160
Patrick Benavoli63499d42011-10-24 18:50:03 +0200161 // Associated syncer sets
162 map<const CConfigurableElement*, CSyncerSet*> _configurableElementToSyncerSetMap;
163
164 // Sequence awareness
165 bool _bSequenceAware;
166
Patrick Benavoli68a91282011-08-31 11:23:23 +0200167 // Syncer set used to ensure propoer synchronization of restored configurable elements
168 CSyncerSet _syncerSet;
169
170 // Last applied configuration
Patrick Benavoli63499d42011-10-24 18:50:03 +0200171 mutable const CDomainConfiguration* _pLastAppliedConfiguration;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200172};
173