blob: 87ed41c45693a25289fa9ab6971e4b53307c4050 [file] [log] [blame]
Patrick Benavoli68a91282011-08-31 11:23:23 +02001/* <auto_header>
2 * <FILENAME>
3 *
4 * INTEL CONFIDENTIAL
5 * Copyright © 2011 Intel
6 * Corporation All Rights Reserved.
7 *
8 * The source code contained or described herein and all documents related to
9 * the source code ("Material") are owned by Intel Corporation or its suppliers
10 * or licensors. Title to the Material remains with Intel Corporation or its
11 * suppliers and licensors. The Material contains trade secrets and proprietary
12 * and confidential information of Intel or its suppliers and licensors. The
13 * Material is protected by worldwide copyright and trade secret laws and
14 * treaty provisions. No part of the Material may be used, copied, reproduced,
15 * modified, published, uploaded, posted, transmitted, distributed, or
16 * disclosed in any way without Intel’s prior express written permission.
17 *
18 * No license under any patent, copyright, trade secret or other intellectual
19 * property right is granted to or conferred upon you by disclosure or delivery
20 * of the Materials, either expressly, by implication, inducement, estoppel or
21 * otherwise. Any license under such intellectual property rights must be
22 * express and approved by Intel in writing.
23 *
24 * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com)
25 * CREATED: 2011-06-01
26 * UPDATED: 2011-07-27
27 *
28 *
29 * </auto_header>
30 */
31#pragma once
32
33#include "BinarySerializableElement.h"
34#include "SyncerSet.h"
35#include <list>
36#include <set>
Patrick Benavoli63499d42011-10-24 18:50:03 +020037#include <map>
Patrick Benavoli68a91282011-08-31 11:23:23 +020038
39class CConfigurableElement;
40class CDomainConfiguration;
41class CParameterBlackboard;
42
43class CConfigurableDomain : public CBinarySerializableElement
44{
45 typedef list<CConfigurableElement*>::const_iterator ConfigurableElementListIterator;
Patrick Benavoli63499d42011-10-24 18:50:03 +020046 typedef map<const CConfigurableElement*, CSyncerSet*>::const_iterator ConfigurableElementToSyncerSetMapIterator;
Patrick Benavoli68a91282011-08-31 11:23:23 +020047public:
48 CConfigurableDomain(const string& strName);
49 virtual ~CConfigurableDomain();
50
Patrick Benavoli63499d42011-10-24 18:50:03 +020051 // Sequence awareness
52 void setSequenceAwareness(bool bSequenceAware);
53 bool getSequenceAwareness() const;
54
Patrick Benavoli68a91282011-08-31 11:23:23 +020055 // Configuration Management
56 bool createConfiguration(const string& strName, const CParameterBlackboard* pMainBlackboard, string& strError);
57 bool deleteConfiguration(const string& strName, string& strError);
58 bool renameConfiguration(const string& strName, const string& strNewName, string& strError);
59 bool restoreConfiguration(const string& strName, CParameterBlackboard* pMainBlackboard, bool bAutoSync, string& strError);
60 bool saveConfiguration(const string& strName, const CParameterBlackboard* pMainBlackboard, string& strError);
Patrick Benavoli63499d42011-10-24 18:50:03 +020061 bool setElementSequence(const string& strName, const vector<string>& astrNewElementSequence, string& strError);
62 bool getElementSequence(const string& strName, string& strResult) const;
Patrick Benavoli68a91282011-08-31 11:23:23 +020063
64 // Last applied configuration
65 string getLastAppliedConfigurationName() const;
66
67 // Associated Configurable elements
68 void gatherConfigurableElements(set<const CConfigurableElement*>& configurableElementSet) const;
69 void listAssociatedToElements(string& strResult) const;
70
71 // Configurable elements association
72 bool addConfigurableElement(CConfigurableElement* pConfigurableElement, const CParameterBlackboard* pMainBlackboard, string& strError);
73 bool removeConfigurableElement(CConfigurableElement* pConfigurableElement, string& strError);
74
75 // Domain splitting
76 bool split(CConfigurableElement* pConfigurableElement, string& strError);
77
78 // Ensure validity on whole domain from main blackboard
79 void validate(const CParameterBlackboard* pMainBlackboard);
80
81 // Configuration application if required
Patrick Benavoli63499d42011-10-24 18:50:03 +020082 bool apply(CParameterBlackboard* pParameterBlackboard, CSyncerSet& syncerSet, bool bForced, string& strError) const;
Patrick Benavoli68a91282011-08-31 11:23:23 +020083
84 // Return applicable configuration validity for given configurable element
85 bool isApplicableConfigurationValid(const CConfigurableElement* pConfigurableElement) const;
86
87 // Presence of application condition on any configuration
88 bool hasRules() const;
89
90 // From IXmlSink
91 virtual bool fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext);
92
93 // From IXmlSource
94 virtual void toXml(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const;
95
96 // Class kind
97 virtual string getKind() const;
98private:
99 // Returns true if children dynamic creation is to be dealt with (here, will allow child deletion upon clean)
100 virtual bool childrenAreDynamic() const;
101
102 // Ensure validity on areas related to configurable element
103 void validateAreas(const CConfigurableElement* pConfigurableElement, const CParameterBlackboard* pMainBlackboard);
104
105 // Attempt validation for all configurable element's areas, relying on already existing valid configuration inside domain
106 void autoValidateAll();
107
108 // Attempt validation for one configurable element's areas, relying on already existing valid configuration inside domain
109 void autoValidateAreas(const CConfigurableElement* pConfigurableElement);
110
111 // Attempt configuration validation for all configurable elements' areas, relying on already existing valid configuration inside domain
112 bool autoValidateConfiguration(CDomainConfiguration* pDomainConfiguration);
113
114 // Search for a valid configuration for given configurable element
115 const CDomainConfiguration* findValidDomainConfiguration(const CConfigurableElement* pConfigurableElement) const;
116
117 // Search for an applicable configuration
118 const CDomainConfiguration* findApplicableDomainConfiguration() const;
119
120 // In case configurable element was removed
121 void computeSyncSet();
122
123 // Check configurable element already attached
124 bool containsConfigurableElement(const CConfigurableElement* pConfigurableCandidateElement) const;
125
126 // Merge any descended configurable element to this one
127 void mergeAlreadyAssociatedDescendantConfigurableElements(CConfigurableElement* pNewConfigurableElement);
128 void mergeConfigurations(CConfigurableElement* pToConfigurableElement, CConfigurableElement* pFromConfigurableElement);
129
130 // Configurable elements association
131 void doAddConfigurableElement(CConfigurableElement* pConfigurableElement);
132 void doRemoveConfigurableElement(CConfigurableElement* pConfigurableElement, bool bRecomputeSyncSet);
133
134 // XML parsing
135 bool parseDomainConfigurations(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext);
136 bool parseConfigurableElements(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext);
Patrick Benavoli63499d42011-10-24 18:50:03 +0200137 bool parseSettings(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200138
139 // XML composing
140 void composeDomainConfigurations(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const;
Patrick Benavoli63499d42011-10-24 18:50:03 +0200141 void composeConfigurableElements(CXmlElement& xmlElement) const;
142 void composeSettings(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const;
143
144 // Syncer set retrieval from configurable element
145 CSyncerSet* getSyncerSet(const CConfigurableElement* pConfigurableElement) const;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200146
147 // Configurable elements
148 list<CConfigurableElement*> _configurableElementList;
149
Patrick Benavoli63499d42011-10-24 18:50:03 +0200150 // Associated syncer sets
151 map<const CConfigurableElement*, CSyncerSet*> _configurableElementToSyncerSetMap;
152
153 // Sequence awareness
154 bool _bSequenceAware;
155
Patrick Benavoli68a91282011-08-31 11:23:23 +0200156 // Syncer set used to ensure propoer synchronization of restored configurable elements
157 CSyncerSet _syncerSet;
158
159 // Last applied configuration
Patrick Benavoli63499d42011-10-24 18:50:03 +0200160 mutable const CDomainConfiguration* _pLastAppliedConfiguration;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200161};
162