blob: 043800952fa4e43e77510717da79210b57a13698 [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>
37
38class CConfigurableElement;
39class CDomainConfiguration;
40class CParameterBlackboard;
41
42class CConfigurableDomain : public CBinarySerializableElement
43{
44 typedef list<CConfigurableElement*>::const_iterator ConfigurableElementListIterator;
45public:
46 CConfigurableDomain(const string& strName);
47 virtual ~CConfigurableDomain();
48
49 // Configuration Management
50 bool createConfiguration(const string& strName, const CParameterBlackboard* pMainBlackboard, string& strError);
51 bool deleteConfiguration(const string& strName, string& strError);
52 bool renameConfiguration(const string& strName, const string& strNewName, string& strError);
53 bool restoreConfiguration(const string& strName, CParameterBlackboard* pMainBlackboard, bool bAutoSync, string& strError);
54 bool saveConfiguration(const string& strName, const CParameterBlackboard* pMainBlackboard, string& strError);
55
56 // Last applied configuration
57 string getLastAppliedConfigurationName() const;
58
59 // Associated Configurable elements
60 void gatherConfigurableElements(set<const CConfigurableElement*>& configurableElementSet) const;
61 void listAssociatedToElements(string& strResult) const;
62
63 // Configurable elements association
64 bool addConfigurableElement(CConfigurableElement* pConfigurableElement, const CParameterBlackboard* pMainBlackboard, string& strError);
65 bool removeConfigurableElement(CConfigurableElement* pConfigurableElement, string& strError);
66
67 // Domain splitting
68 bool split(CConfigurableElement* pConfigurableElement, string& strError);
69
70 // Ensure validity on whole domain from main blackboard
71 void validate(const CParameterBlackboard* pMainBlackboard);
72
73 // Configuration application if required
74 void apply(CParameterBlackboard* pParameterBlackboard, CSyncerSet& syncerSet, bool bForced);
75
76 // Return applicable configuration validity for given configurable element
77 bool isApplicableConfigurationValid(const CConfigurableElement* pConfigurableElement) const;
78
79 // Presence of application condition on any configuration
80 bool hasRules() const;
81
82 // From IXmlSink
83 virtual bool fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext);
84
85 // From IXmlSource
86 virtual void toXml(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const;
87
88 // Class kind
89 virtual string getKind() const;
90private:
91 // Returns true if children dynamic creation is to be dealt with (here, will allow child deletion upon clean)
92 virtual bool childrenAreDynamic() const;
93
94 // Ensure validity on areas related to configurable element
95 void validateAreas(const CConfigurableElement* pConfigurableElement, const CParameterBlackboard* pMainBlackboard);
96
97 // Attempt validation for all configurable element's areas, relying on already existing valid configuration inside domain
98 void autoValidateAll();
99
100 // Attempt validation for one configurable element's areas, relying on already existing valid configuration inside domain
101 void autoValidateAreas(const CConfigurableElement* pConfigurableElement);
102
103 // Attempt configuration validation for all configurable elements' areas, relying on already existing valid configuration inside domain
104 bool autoValidateConfiguration(CDomainConfiguration* pDomainConfiguration);
105
106 // Search for a valid configuration for given configurable element
107 const CDomainConfiguration* findValidDomainConfiguration(const CConfigurableElement* pConfigurableElement) const;
108
109 // Search for an applicable configuration
110 const CDomainConfiguration* findApplicableDomainConfiguration() const;
111
112 // In case configurable element was removed
113 void computeSyncSet();
114
115 // Check configurable element already attached
116 bool containsConfigurableElement(const CConfigurableElement* pConfigurableCandidateElement) const;
117
118 // Merge any descended configurable element to this one
119 void mergeAlreadyAssociatedDescendantConfigurableElements(CConfigurableElement* pNewConfigurableElement);
120 void mergeConfigurations(CConfigurableElement* pToConfigurableElement, CConfigurableElement* pFromConfigurableElement);
121
122 // Configurable elements association
123 void doAddConfigurableElement(CConfigurableElement* pConfigurableElement);
124 void doRemoveConfigurableElement(CConfigurableElement* pConfigurableElement, bool bRecomputeSyncSet);
125
126 // XML parsing
127 bool parseDomainConfigurations(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext);
128 bool parseConfigurableElements(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext);
129 bool parseConfigurableElementConfigurations(const CConfigurableElement* pConfigurableElement, CXmlElement& xmlConfigurableElementElement, CXmlSerializingContext& serializingContext);
130 bool serializeConfigurableElementConfiguration(CDomainConfiguration* pDomainConfiguration, const CConfigurableElement* pConfigurableElement, CXmlElement& xmlConfigurationSettingsElement, CXmlSerializingContext& serializingContext, bool bSerializeOut);
131
132 // XML composing
133 void composeDomainConfigurations(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const;
134 void composeConfigurableElements(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const;
135 void composeConfigurableElementConfigurations(const CConfigurableElement* pConfigurableElement, CXmlElement& xmlConfigurableElementElement, CXmlSerializingContext& serializingContext) const;
136
137 // Configurable elements
138 list<CConfigurableElement*> _configurableElementList;
139
140 // Syncer set used to ensure propoer synchronization of restored configurable elements
141 CSyncerSet _syncerSet;
142
143 // Last applied configuration
144 const CDomainConfiguration* _pLastAppliedConfiguration;
145};
146