blob: 7c49011d788ccbe50835c4970c50e2d7ee9082bd [file] [log] [blame]
David Wagnerb76c9d62014-02-05 18:30:24 +01001/*
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 Benavoli68a91282011-08-31 11:23:23 +020029 */
30#pragma once
31
32#include "BinarySerializableElement.h"
33#include <list>
34
35class CConfigurableElement;
36class CAreaConfiguration;
37class CParameterBlackboard;
38class CConfigurationAccessContext;
39class CCompoundRule;
Patrick Benavoli63499d42011-10-24 18:50:03 +020040class CSyncerSet;
Patrick Benavoli0bd50542011-11-29 11:10:27 +010041class CSelectionCriteriaDefinition;
Patrick Benavoli68a91282011-08-31 11:23:23 +020042
43class CDomainConfiguration : public CBinarySerializableElement
44{
45 enum ChildElementType {
46 ECompoundRule
47 };
48 typedef list<CAreaConfiguration*>::const_iterator AreaConfigurationListIterator;
49public:
50 CDomainConfiguration(const string& strName);
51 virtual ~CDomainConfiguration();
52
53 // Configurable Elements association
Patrick Benavoli63499d42011-10-24 18:50:03 +020054 void addConfigurableElement(const CConfigurableElement* pConfigurableElement, const CSyncerSet* pSyncerSet);
Patrick Benavoli68a91282011-08-31 11:23:23 +020055 void removeConfigurableElement(const CConfigurableElement* pConfigurableElement);
56
Patrick Benavoli63499d42011-10-24 18:50:03 +020057 // Sequence management
58 bool setElementSequence(const vector<string>& astrNewElementSequence, string& strError);
59 void getElementSequence(string& strResult) const;
60
Patrick Benavoli0bd50542011-11-29 11:10:27 +010061 // 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 Boisnarde42dacd2013-02-25 15:56:56 +010066 // Get Blackboard for an element of the domain
67 CParameterBlackboard* getBlackboard(const CConfigurableElement* pConfigurableElement) const;
68
Patrick Benavoli68a91282011-08-31 11:23:23 +020069 // Save data from current
70 void save(const CParameterBlackboard* pMainBlackboard);
71 // Apply data to current
Kevin Rocardace81f82012-12-11 16:19:17 +010072 bool restore(CParameterBlackboard* pMainBlackboard, bool bSync, list<string>* plstrError = NULL) const;
Patrick Benavoli68a91282011-08-31 11:23:23 +020073 // 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 Benavoli63499d42011-10-24 18:50:03 +020091 bool parseSettings(CXmlElement& xmlConfigurationSettingsElement, CXmlSerializingContext& serializingContext);
92 void composeSettings(CXmlElement& xmlConfigurationSettingsElement, CXmlSerializingContext& serializingContext) const;
Patrick Benavoli68a91282011-08-31 11:23:23 +020093
Patrick Benavoli68a91282011-08-31 11:23:23 +020094 // 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 Boisnarde42dacd2013-02-25 15:56:56 +0100102
Patrick Benavoli68a91282011-08-31 11:23:23 +0200103private:
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 Benavoli63499d42011-10-24 18:50:03 +0200106 // XML configuration settings serializing
107 bool serializeConfigurableElementSettings(CAreaConfiguration* pAreaConfiguration, CXmlElement& xmlConfigurableElementSettingsElement, CXmlSerializingContext& serializingContext, bool bSerializeOut);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200108 // AreaConfiguration retrieval from configurable element
109 CAreaConfiguration* getAreaConfiguration(const CConfigurableElement* pConfigurableElement) const;
Patrick Benavoli63499d42011-10-24 18:50:03 +0200110 // 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 Benavoli68a91282011-08-31 11:23:23 +0200120
121 // Rule
122 const CCompoundRule* getRule() const;
Patrick Benavoli0bd50542011-11-29 11:10:27 +0100123 CCompoundRule* getRule();
124 void setRule(CCompoundRule* pRule);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200125
126 // AreaConfigurations
127 list<CAreaConfiguration*> _areaConfigurationList;
Patrick Benavoli63499d42011-10-24 18:50:03 +0200128 list<CAreaConfiguration*> _orderedAreaConfigurationList;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200129};