Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1 | /* <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 Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 37 | #include <map> |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 38 | |
| 39 | class CConfigurableElement; |
| 40 | class CDomainConfiguration; |
| 41 | class CParameterBlackboard; |
Patrick Benavoli | 0bd5054 | 2011-11-29 11:10:27 +0100 | [diff] [blame^] | 42 | class CSelectionCriteriaDefinition; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 43 | |
| 44 | class CConfigurableDomain : public CBinarySerializableElement |
| 45 | { |
| 46 | typedef list<CConfigurableElement*>::const_iterator ConfigurableElementListIterator; |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 47 | typedef map<const CConfigurableElement*, CSyncerSet*>::const_iterator ConfigurableElementToSyncerSetMapIterator; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 48 | public: |
| 49 | CConfigurableDomain(const string& strName); |
| 50 | virtual ~CConfigurableDomain(); |
| 51 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 52 | // Sequence awareness |
| 53 | void setSequenceAwareness(bool bSequenceAware); |
| 54 | bool getSequenceAwareness() const; |
| 55 | |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 56 | // Configuration Management |
| 57 | bool createConfiguration(const string& strName, const CParameterBlackboard* pMainBlackboard, string& strError); |
| 58 | bool deleteConfiguration(const string& strName, string& strError); |
| 59 | bool renameConfiguration(const string& strName, const string& strNewName, string& strError); |
Patrick Benavoli | 0bd5054 | 2011-11-29 11:10:27 +0100 | [diff] [blame^] | 60 | bool restoreConfiguration(const string& strName, CParameterBlackboard* pMainBlackboard, bool bAutoSync, string& strError) const; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 61 | bool saveConfiguration(const string& strName, const CParameterBlackboard* pMainBlackboard, string& strError); |
Patrick Benavoli | 0bd5054 | 2011-11-29 11:10:27 +0100 | [diff] [blame^] | 62 | bool setElementSequence(const string& strConfiguration, const vector<string>& astrNewElementSequence, string& strError); |
| 63 | bool getElementSequence(const string& strConfiguration, string& strResult) const; |
| 64 | bool setApplicationRule(const string& strConfiguration, const string& strApplicationRule, const CSelectionCriteriaDefinition* pSelectionCriteriaDefinition, string& strError); |
| 65 | bool clearApplicationRule(const string& strConfiguration, string& strError); |
| 66 | bool getApplicationRule(const string& strConfiguration, string& strResult) const; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 67 | |
| 68 | // Last applied configuration |
| 69 | string getLastAppliedConfigurationName() const; |
| 70 | |
| 71 | // Associated Configurable elements |
| 72 | void gatherConfigurableElements(set<const CConfigurableElement*>& configurableElementSet) const; |
| 73 | void listAssociatedToElements(string& strResult) const; |
| 74 | |
| 75 | // Configurable elements association |
| 76 | bool addConfigurableElement(CConfigurableElement* pConfigurableElement, const CParameterBlackboard* pMainBlackboard, string& strError); |
| 77 | bool removeConfigurableElement(CConfigurableElement* pConfigurableElement, string& strError); |
| 78 | |
| 79 | // Domain splitting |
| 80 | bool split(CConfigurableElement* pConfigurableElement, string& strError); |
| 81 | |
| 82 | // Ensure validity on whole domain from main blackboard |
| 83 | void validate(const CParameterBlackboard* pMainBlackboard); |
| 84 | |
| 85 | // Configuration application if required |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 86 | bool apply(CParameterBlackboard* pParameterBlackboard, CSyncerSet& syncerSet, bool bForced, string& strError) const; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 87 | |
| 88 | // Return applicable configuration validity for given configurable element |
| 89 | bool isApplicableConfigurationValid(const CConfigurableElement* pConfigurableElement) const; |
| 90 | |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 91 | // From IXmlSink |
| 92 | virtual bool fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext); |
| 93 | |
| 94 | // From IXmlSource |
| 95 | virtual void toXml(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const; |
| 96 | |
| 97 | // Class kind |
| 98 | virtual string getKind() const; |
Patrick Benavoli | 0bd5054 | 2011-11-29 11:10:27 +0100 | [diff] [blame^] | 99 | protected: |
| 100 | // Content dumping |
| 101 | virtual void logValue(string& strValue, CErrorContext& errorContext) const; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 102 | private: |
| 103 | // Returns true if children dynamic creation is to be dealt with (here, will allow child deletion upon clean) |
| 104 | virtual bool childrenAreDynamic() const; |
| 105 | |
| 106 | // Ensure validity on areas related to configurable element |
| 107 | void validateAreas(const CConfigurableElement* pConfigurableElement, const CParameterBlackboard* pMainBlackboard); |
| 108 | |
| 109 | // Attempt validation for all configurable element's areas, relying on already existing valid configuration inside domain |
| 110 | void autoValidateAll(); |
| 111 | |
| 112 | // Attempt validation for one configurable element's areas, relying on already existing valid configuration inside domain |
| 113 | void autoValidateAreas(const CConfigurableElement* pConfigurableElement); |
| 114 | |
| 115 | // Attempt configuration validation for all configurable elements' areas, relying on already existing valid configuration inside domain |
| 116 | bool autoValidateConfiguration(CDomainConfiguration* pDomainConfiguration); |
| 117 | |
| 118 | // Search for a valid configuration for given configurable element |
| 119 | const CDomainConfiguration* findValidDomainConfiguration(const CConfigurableElement* pConfigurableElement) const; |
| 120 | |
| 121 | // Search for an applicable configuration |
| 122 | const CDomainConfiguration* findApplicableDomainConfiguration() const; |
| 123 | |
| 124 | // In case configurable element was removed |
| 125 | void computeSyncSet(); |
| 126 | |
| 127 | // Check configurable element already attached |
| 128 | bool containsConfigurableElement(const CConfigurableElement* pConfigurableCandidateElement) const; |
| 129 | |
| 130 | // Merge any descended configurable element to this one |
| 131 | void mergeAlreadyAssociatedDescendantConfigurableElements(CConfigurableElement* pNewConfigurableElement); |
| 132 | void mergeConfigurations(CConfigurableElement* pToConfigurableElement, CConfigurableElement* pFromConfigurableElement); |
| 133 | |
| 134 | // Configurable elements association |
| 135 | void doAddConfigurableElement(CConfigurableElement* pConfigurableElement); |
| 136 | void doRemoveConfigurableElement(CConfigurableElement* pConfigurableElement, bool bRecomputeSyncSet); |
| 137 | |
| 138 | // XML parsing |
| 139 | bool parseDomainConfigurations(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext); |
| 140 | bool parseConfigurableElements(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext); |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 141 | bool parseSettings(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 142 | |
| 143 | // XML composing |
| 144 | void composeDomainConfigurations(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const; |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 145 | void composeConfigurableElements(CXmlElement& xmlElement) const; |
| 146 | void composeSettings(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const; |
| 147 | |
| 148 | // Syncer set retrieval from configurable element |
| 149 | CSyncerSet* getSyncerSet(const CConfigurableElement* pConfigurableElement) const; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 150 | |
Patrick Benavoli | 0bd5054 | 2011-11-29 11:10:27 +0100 | [diff] [blame^] | 151 | // Configuration retrieval |
| 152 | CDomainConfiguration* findConfiguration(const string& strConfiguration, string& strError); |
| 153 | const CDomainConfiguration* findConfiguration(const string& strConfiguration, string& strError) const; |
| 154 | |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 155 | // Configurable elements |
| 156 | list<CConfigurableElement*> _configurableElementList; |
| 157 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 158 | // Associated syncer sets |
| 159 | map<const CConfigurableElement*, CSyncerSet*> _configurableElementToSyncerSetMap; |
| 160 | |
| 161 | // Sequence awareness |
| 162 | bool _bSequenceAware; |
| 163 | |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 164 | // Syncer set used to ensure propoer synchronization of restored configurable elements |
| 165 | CSyncerSet _syncerSet; |
| 166 | |
| 167 | // Last applied configuration |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 168 | mutable const CDomainConfiguration* _pLastAppliedConfiguration; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 169 | }; |
| 170 | |