Kevin Rocard | 93250d1 | 2012-07-19 17:48:30 +0200 | [diff] [blame] | 1 | /* |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 2 | * 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 Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 22 | * CREATED: 2011-06-01 |
| 23 | * UPDATED: 2011-07-27 |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 24 | */ |
| 25 | #pragma once |
| 26 | |
| 27 | #include "BinarySerializableElement.h" |
| 28 | #include "SyncerSet.h" |
| 29 | #include <list> |
| 30 | #include <set> |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 31 | #include <map> |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 32 | |
| 33 | class CConfigurableElement; |
| 34 | class CDomainConfiguration; |
| 35 | class CParameterBlackboard; |
Patrick Benavoli | 0bd5054 | 2011-11-29 11:10:27 +0100 | [diff] [blame] | 36 | class CSelectionCriteriaDefinition; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 37 | |
| 38 | class CConfigurableDomain : public CBinarySerializableElement |
| 39 | { |
| 40 | typedef list<CConfigurableElement*>::const_iterator ConfigurableElementListIterator; |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 41 | typedef map<const CConfigurableElement*, CSyncerSet*>::const_iterator ConfigurableElementToSyncerSetMapIterator; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 42 | public: |
| 43 | CConfigurableDomain(const string& strName); |
| 44 | virtual ~CConfigurableDomain(); |
| 45 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 46 | // Sequence awareness |
| 47 | void setSequenceAwareness(bool bSequenceAware); |
| 48 | bool getSequenceAwareness() const; |
| 49 | |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 50 | // 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 Rocard | ace81f8 | 2012-12-11 16:19:17 +0100 | [diff] [blame^] | 54 | bool restoreConfiguration(const string& strName, CParameterBlackboard* pMainBlackboard, bool bAutoSync, list<string>& strError) const; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 55 | bool saveConfiguration(const string& strName, const CParameterBlackboard* pMainBlackboard, string& strError); |
Patrick Benavoli | 0bd5054 | 2011-11-29 11:10:27 +0100 | [diff] [blame] | 56 | 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 Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 61 | |
Frédéric Boisnard | 8b243f5 | 2012-09-06 18:03:20 +0200 | [diff] [blame] | 62 | // Last applied configuration name |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 63 | string getLastAppliedConfigurationName() const; |
| 64 | |
Frédéric Boisnard | 8b243f5 | 2012-09-06 18:03:20 +0200 | [diff] [blame] | 65 | // Pending configuration name |
| 66 | string getPendingConfigurationName() const; |
| 67 | |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 68 | // 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 |
Kevin Rocard | ace81f8 | 2012-12-11 16:19:17 +0100 | [diff] [blame^] | 83 | void apply(CParameterBlackboard* pParameterBlackboard, CSyncerSet& syncerSet, bool bForced) const; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 84 | |
| 85 | // Return applicable configuration validity for given configurable element |
| 86 | bool isApplicableConfigurationValid(const CConfigurableElement* pConfigurableElement) const; |
| 87 | |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 88 | // 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 Boisnard | 8b243f5 | 2012-09-06 18:03:20 +0200 | [diff] [blame] | 96 | |
Patrick Benavoli | 0bd5054 | 2011-11-29 11:10:27 +0100 | [diff] [blame] | 97 | protected: |
| 98 | // Content dumping |
| 99 | virtual void logValue(string& strValue, CErrorContext& errorContext) const; |
Frédéric Boisnard | 8b243f5 | 2012-09-06 18:03:20 +0200 | [diff] [blame] | 100 | |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 101 | private: |
Frédéric Boisnard | 8b243f5 | 2012-09-06 18:03:20 +0200 | [diff] [blame] | 102 | // Get pending configuration |
| 103 | const CDomainConfiguration* getPendingConfiguration() const; |
| 104 | |
| 105 | // Search for an applicable configuration |
| 106 | const CDomainConfiguration* findApplicableDomainConfiguration() const; |
| 107 | |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 108 | // 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 Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 126 | |
| 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 Boisnard | 9620e44 | 2012-05-30 16:15:02 +0200 | [diff] [blame] | 138 | void doAddConfigurableElement(CConfigurableElement* pConfigurableElement, const CParameterBlackboard* pMainBlackboard = NULL); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 139 | 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 Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 144 | bool parseSettings(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 145 | |
| 146 | // XML composing |
| 147 | void composeDomainConfigurations(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const; |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 148 | 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 Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 153 | |
Patrick Benavoli | 0bd5054 | 2011-11-29 11:10:27 +0100 | [diff] [blame] | 154 | // Configuration retrieval |
| 155 | CDomainConfiguration* findConfiguration(const string& strConfiguration, string& strError); |
| 156 | const CDomainConfiguration* findConfiguration(const string& strConfiguration, string& strError) const; |
| 157 | |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 158 | // Configurable elements |
| 159 | list<CConfigurableElement*> _configurableElementList; |
| 160 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 161 | // Associated syncer sets |
| 162 | map<const CConfigurableElement*, CSyncerSet*> _configurableElementToSyncerSetMap; |
| 163 | |
| 164 | // Sequence awareness |
| 165 | bool _bSequenceAware; |
| 166 | |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 167 | // Syncer set used to ensure propoer synchronization of restored configurable elements |
| 168 | CSyncerSet _syncerSet; |
| 169 | |
| 170 | // Last applied configuration |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 171 | mutable const CDomainConfiguration* _pLastAppliedConfiguration; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 172 | }; |
| 173 | |