blob: ff194c28c9aa8c2060a144bb84fead605ceb6fcc [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
62 // Last applied configuration
63 string getLastAppliedConfigurationName() const;
64
65 // Associated Configurable elements
66 void gatherConfigurableElements(set<const CConfigurableElement*>& configurableElementSet) const;
67 void listAssociatedToElements(string& strResult) const;
68
69 // Configurable elements association
70 bool addConfigurableElement(CConfigurableElement* pConfigurableElement, const CParameterBlackboard* pMainBlackboard, string& strError);
71 bool removeConfigurableElement(CConfigurableElement* pConfigurableElement, string& strError);
72
73 // Domain splitting
74 bool split(CConfigurableElement* pConfigurableElement, string& strError);
75
76 // Ensure validity on whole domain from main blackboard
77 void validate(const CParameterBlackboard* pMainBlackboard);
78
79 // Configuration application if required
Patrick Benavoli63499d42011-10-24 18:50:03 +020080 bool apply(CParameterBlackboard* pParameterBlackboard, CSyncerSet& syncerSet, bool bForced, string& strError) const;
Patrick Benavoli68a91282011-08-31 11:23:23 +020081
82 // Return applicable configuration validity for given configurable element
83 bool isApplicableConfigurationValid(const CConfigurableElement* pConfigurableElement) const;
84
Patrick Benavoli68a91282011-08-31 11:23:23 +020085 // From IXmlSink
86 virtual bool fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext);
87
88 // From IXmlSource
89 virtual void toXml(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const;
90
91 // Class kind
92 virtual string getKind() const;
Patrick Benavoli0bd50542011-11-29 11:10:27 +010093protected:
94 // Content dumping
95 virtual void logValue(string& strValue, CErrorContext& errorContext) const;
Patrick Benavoli68a91282011-08-31 11:23:23 +020096private:
97 // Returns true if children dynamic creation is to be dealt with (here, will allow child deletion upon clean)
98 virtual bool childrenAreDynamic() const;
99
100 // Ensure validity on areas related to configurable element
101 void validateAreas(const CConfigurableElement* pConfigurableElement, const CParameterBlackboard* pMainBlackboard);
102
103 // Attempt validation for all configurable element's areas, relying on already existing valid configuration inside domain
104 void autoValidateAll();
105
106 // Attempt validation for one configurable element's areas, relying on already existing valid configuration inside domain
107 void autoValidateAreas(const CConfigurableElement* pConfigurableElement);
108
109 // Attempt configuration validation for all configurable elements' areas, relying on already existing valid configuration inside domain
110 bool autoValidateConfiguration(CDomainConfiguration* pDomainConfiguration);
111
112 // Search for a valid configuration for given configurable element
113 const CDomainConfiguration* findValidDomainConfiguration(const CConfigurableElement* pConfigurableElement) const;
114
115 // Search for an applicable configuration
116 const CDomainConfiguration* findApplicableDomainConfiguration() const;
117
118 // In case configurable element was removed
119 void computeSyncSet();
120
121 // Check configurable element already attached
122 bool containsConfigurableElement(const CConfigurableElement* pConfigurableCandidateElement) const;
123
124 // Merge any descended configurable element to this one
125 void mergeAlreadyAssociatedDescendantConfigurableElements(CConfigurableElement* pNewConfigurableElement);
126 void mergeConfigurations(CConfigurableElement* pToConfigurableElement, CConfigurableElement* pFromConfigurableElement);
127
128 // Configurable elements association
Frédéric Boisnard9620e442012-05-30 16:15:02 +0200129 void doAddConfigurableElement(CConfigurableElement* pConfigurableElement, const CParameterBlackboard* pMainBlackboard = NULL);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200130 void doRemoveConfigurableElement(CConfigurableElement* pConfigurableElement, bool bRecomputeSyncSet);
131
132 // XML parsing
133 bool parseDomainConfigurations(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext);
134 bool parseConfigurableElements(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext);
Patrick Benavoli63499d42011-10-24 18:50:03 +0200135 bool parseSettings(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200136
137 // XML composing
138 void composeDomainConfigurations(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const;
Patrick Benavoli63499d42011-10-24 18:50:03 +0200139 void composeConfigurableElements(CXmlElement& xmlElement) const;
140 void composeSettings(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const;
141
142 // Syncer set retrieval from configurable element
143 CSyncerSet* getSyncerSet(const CConfigurableElement* pConfigurableElement) const;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200144
Patrick Benavoli0bd50542011-11-29 11:10:27 +0100145 // Configuration retrieval
146 CDomainConfiguration* findConfiguration(const string& strConfiguration, string& strError);
147 const CDomainConfiguration* findConfiguration(const string& strConfiguration, string& strError) const;
148
Patrick Benavoli68a91282011-08-31 11:23:23 +0200149 // Configurable elements
150 list<CConfigurableElement*> _configurableElementList;
151
Patrick Benavoli63499d42011-10-24 18:50:03 +0200152 // Associated syncer sets
153 map<const CConfigurableElement*, CSyncerSet*> _configurableElementToSyncerSetMap;
154
155 // Sequence awareness
156 bool _bSequenceAware;
157
Patrick Benavoli68a91282011-08-31 11:23:23 +0200158 // Syncer set used to ensure propoer synchronization of restored configurable elements
159 CSyncerSet _syncerSet;
160
161 // Last applied configuration
Patrick Benavoli63499d42011-10-24 18:50:03 +0200162 mutable const CDomainConfiguration* _pLastAppliedConfiguration;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200163};
164