David Wagner | b76c9d6 | 2014-02-05 18:30:24 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2011-2014, Intel Corporation |
| 3 | * All rights reserved. |
| 4 | * |
| 5 | * Redistribution and use in source and binary forms, with or without modification, |
| 6 | * are permitted provided that the following conditions are met: |
| 7 | * |
| 8 | * 1. Redistributions of source code must retain the above copyright notice, this |
| 9 | * list of conditions and the following disclaimer. |
| 10 | * |
| 11 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
| 12 | * this list of conditions and the following disclaimer in the documentation and/or |
| 13 | * other materials provided with the distribution. |
| 14 | * |
| 15 | * 3. Neither the name of the copyright holder nor the names of its contributors |
| 16 | * may be used to endorse or promote products derived from this software without |
| 17 | * specific prior written permission. |
| 18 | * |
| 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
| 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
| 23 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
| 26 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 29 | */ |
| 30 | #pragma once |
| 31 | |
| 32 | #include "BinarySerializableElement.h" |
| 33 | #include <list> |
| 34 | |
| 35 | class CConfigurableElement; |
| 36 | class CAreaConfiguration; |
| 37 | class CParameterBlackboard; |
| 38 | class CConfigurationAccessContext; |
| 39 | class CCompoundRule; |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 40 | class CSyncerSet; |
Patrick Benavoli | 0bd5054 | 2011-11-29 11:10:27 +0100 | [diff] [blame] | 41 | class CSelectionCriteriaDefinition; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 42 | |
| 43 | class CDomainConfiguration : public CBinarySerializableElement |
| 44 | { |
| 45 | enum ChildElementType { |
| 46 | ECompoundRule |
| 47 | }; |
| 48 | typedef list<CAreaConfiguration*>::const_iterator AreaConfigurationListIterator; |
| 49 | public: |
| 50 | CDomainConfiguration(const string& strName); |
| 51 | virtual ~CDomainConfiguration(); |
| 52 | |
| 53 | // Configurable Elements association |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 54 | void addConfigurableElement(const CConfigurableElement* pConfigurableElement, const CSyncerSet* pSyncerSet); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 55 | void removeConfigurableElement(const CConfigurableElement* pConfigurableElement); |
| 56 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 57 | // Sequence management |
| 58 | bool setElementSequence(const vector<string>& astrNewElementSequence, string& strError); |
| 59 | void getElementSequence(string& strResult) const; |
| 60 | |
Patrick Benavoli | 0bd5054 | 2011-11-29 11:10:27 +0100 | [diff] [blame] | 61 | // Application rule |
| 62 | bool setApplicationRule(const string& strApplicationRule, const CSelectionCriteriaDefinition* pSelectionCriteriaDefinition, string& strError); |
| 63 | void clearApplicationRule(); |
| 64 | void getApplicationRule(string& strResult) const; |
| 65 | |
Frédéric Boisnard | e42dacd | 2013-02-25 15:56:56 +0100 | [diff] [blame] | 66 | // Get Blackboard for an element of the domain |
| 67 | CParameterBlackboard* getBlackboard(const CConfigurableElement* pConfigurableElement) const; |
| 68 | |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 69 | // Save data from current |
| 70 | void save(const CParameterBlackboard* pMainBlackboard); |
| 71 | // Apply data to current |
Kevin Rocard | ace81f8 | 2012-12-11 16:19:17 +0100 | [diff] [blame] | 72 | bool restore(CParameterBlackboard* pMainBlackboard, bool bSync, list<string>* plstrError = NULL) const; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 73 | // Ensure validity for configurable element area configuration |
| 74 | void validate(const CConfigurableElement* pConfigurableElement, const CParameterBlackboard* pMainBlackboard); |
| 75 | // Ensure validity of all area configurations |
| 76 | void validate(const CParameterBlackboard* pMainBlackboard); |
| 77 | // Return configuration validity for given configurable element |
| 78 | bool isValid(const CConfigurableElement* pConfigurableElement) const; |
| 79 | // Ensure validity of configurable element's area configuration by copying in from a valid one |
| 80 | void validateAgainst(const CDomainConfiguration* pValidDomainConfiguration, const CConfigurableElement* pConfigurableElement); |
| 81 | // Ensure validity of all configurable element's area configuration by copying in from a valid ones |
| 82 | void validateAgainst(const CDomainConfiguration* pValidDomainConfiguration); |
| 83 | // Applicability checking |
| 84 | bool isApplicable() const; |
| 85 | // Merge existing configurations to given configurable element ones |
| 86 | void merge(CConfigurableElement* pToConfigurableElement, CConfigurableElement* pFromConfigurableElement); |
| 87 | // Domain splitting |
| 88 | void split(CConfigurableElement* pFromConfigurableElement); |
| 89 | |
| 90 | // XML configuration settings parsing/composing |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 91 | bool parseSettings(CXmlElement& xmlConfigurationSettingsElement, CXmlSerializingContext& serializingContext); |
| 92 | void composeSettings(CXmlElement& xmlConfigurationSettingsElement, CXmlSerializingContext& serializingContext) const; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 93 | |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 94 | // Serialization |
| 95 | virtual void binarySerialize(CBinaryStream& binaryStream); |
| 96 | |
| 97 | // Data size |
| 98 | virtual uint32_t getDataSize() const; |
| 99 | |
| 100 | // Class kind |
| 101 | virtual string getKind() const; |
Frédéric Boisnard | e42dacd | 2013-02-25 15:56:56 +0100 | [diff] [blame] | 102 | |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 103 | private: |
| 104 | // Returns true if children dynamic creation is to be dealt with (here, will allow child deletion upon clean) |
| 105 | virtual bool childrenAreDynamic() const; |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 106 | // XML configuration settings serializing |
| 107 | bool serializeConfigurableElementSettings(CAreaConfiguration* pAreaConfiguration, CXmlElement& xmlConfigurableElementSettingsElement, CXmlSerializingContext& serializingContext, bool bSerializeOut); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 108 | // AreaConfiguration retrieval from configurable element |
| 109 | CAreaConfiguration* getAreaConfiguration(const CConfigurableElement* pConfigurableElement) const; |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 110 | // AreaConfiguration retrieval from present area configurations |
| 111 | CAreaConfiguration* findAreaConfiguration(const string& strConfigurableElementPath) const; |
| 112 | // AreaConfiguration retrieval from given area configuration list |
| 113 | CAreaConfiguration* findAreaConfiguration(const string& strConfigurableElementPath, const list<CAreaConfiguration*>& areaConfigurationList) const; |
| 114 | // Area configuration ordering |
| 115 | void reorderAreaConfigurations(const list<CAreaConfiguration*>& areaConfigurationList); |
| 116 | // Find area configuration rank from regular list: for ordered list maintainance |
| 117 | uint32_t getAreaConfigurationRank(const CAreaConfiguration* pAreaConfiguration) const; |
| 118 | // Find area configuration from regular list based on rank: for ordered list maintainance |
| 119 | CAreaConfiguration* getAreaConfiguration(uint32_t uiAreaConfigurationRank) const; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 120 | |
| 121 | // Rule |
| 122 | const CCompoundRule* getRule() const; |
Patrick Benavoli | 0bd5054 | 2011-11-29 11:10:27 +0100 | [diff] [blame] | 123 | CCompoundRule* getRule(); |
| 124 | void setRule(CCompoundRule* pRule); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 125 | |
| 126 | // AreaConfigurations |
| 127 | list<CAreaConfiguration*> _areaConfigurationList; |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 128 | list<CAreaConfiguration*> _orderedAreaConfigurationList; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 129 | }; |