blob: 16c866e3b507e09b95540c007b91961367b2f6b7 [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 "ParameterBlackboard.h"
33#include "BinaryStream.h"
Patrick Benavoli63499d42011-10-24 18:50:03 +020034#include "SyncerSet.h"
Patrick Benavoli68a91282011-08-31 11:23:23 +020035
36using namespace std;
37
38class CConfigurableElement;
39class CXmlElement;
40class CConfigurationAccessContext;
41
42class CAreaConfiguration
43{
44public:
Patrick Benavoli63499d42011-10-24 18:50:03 +020045 CAreaConfiguration(const CConfigurableElement* pConfigurableElement, const CSyncerSet* pSyncerSet);
Patrick Benavoli68a91282011-08-31 11:23:23 +020046
Sebastien Gonzalved7e48442013-03-12 14:30:27 +010047 /* FIXME this was missing and probably buggy*/
48 virtual ~CAreaConfiguration() {}
49
Patrick Benavoli68a91282011-08-31 11:23:23 +020050 // Save data from current
51 void save(const CParameterBlackboard* pMainBlackboard);
52
53 // Apply data to current
Kevin Rocardace81f82012-12-11 16:19:17 +010054 bool restore(CParameterBlackboard* pMainBlackboard, bool bSync, list<string>* plstrError) const;
Patrick Benavoli68a91282011-08-31 11:23:23 +020055
56 // Ensure validity
57 void validate(const CParameterBlackboard* pMainBlackboard);
58
59 // Return validity
60 bool isValid() const;
61
62 // Ensure validity against given valid area configuration
63 void validateAgainst(const CAreaConfiguration* pValidAreaConfiguration);
64
65 // Compound handling
66 const CConfigurableElement* getConfigurableElement() const;
67
68 // Configuration merging
Frédéric Boisnard9620e442012-05-30 16:15:02 +020069 virtual void copyToOuter(CAreaConfiguration* pToAreaConfiguration) const;
Patrick Benavoli68a91282011-08-31 11:23:23 +020070
71 // Configuration splitting
Frédéric Boisnard9620e442012-05-30 16:15:02 +020072 virtual void copyFromOuter(const CAreaConfiguration* pFromAreaConfiguration);
Patrick Benavoli68a91282011-08-31 11:23:23 +020073
74 // XML configuration settings parsing/composing
Patrick Benavoli63499d42011-10-24 18:50:03 +020075 bool serializeXmlSettings(CXmlElement& xmlConfigurableElementSettingsElementContent, CConfigurationAccessContext& configurationAccessContext);
Patrick Benavoli68a91282011-08-31 11:23:23 +020076
77 // Serialization
78 void serialize(CBinaryStream& binaryStream);
79
80 // Data size
81 uint32_t getSize() const;
Frédéric Boisnard9620e442012-05-30 16:15:02 +020082
Frédéric Boisnarde42dacd2013-02-25 15:56:56 +010083 // Fetch the Configuration Blackboard
84 CParameterBlackboard& getBlackboard();
85 const CParameterBlackboard& getBlackboard() const;
86
Frédéric Boisnard9620e442012-05-30 16:15:02 +020087protected:
88 CAreaConfiguration(const CConfigurableElement* pConfigurableElement, const CSyncerSet* pSyncerSet, uint32_t uiSize);
89
Patrick Benavoli68a91282011-08-31 11:23:23 +020090private:
Frédéric Boisnard9620e442012-05-30 16:15:02 +020091 // Blackboard copies
92 virtual void copyTo(CParameterBlackboard* pToBlackboard, uint32_t uiOffset) const;
93 virtual void copyFrom(const CParameterBlackboard* pFromBlackboard, uint32_t uiOffset);
94
Patrick Benavoli68a91282011-08-31 11:23:23 +020095 // Store validity
96 void setValid(bool bValid);
97
Frédéric Boisnard9620e442012-05-30 16:15:02 +020098protected:
Patrick Benavoli63499d42011-10-24 18:50:03 +020099 // Associated configurable element
100 const CConfigurableElement* _pConfigurableElement;
101
Patrick Benavoli68a91282011-08-31 11:23:23 +0200102 // Configurable element settings
103 CParameterBlackboard _blackboard;
Patrick Benavoli63499d42011-10-24 18:50:03 +0200104
Frédéric Boisnard9620e442012-05-30 16:15:02 +0200105private:
106 // Syncer set (required for immediate synchronization)
107 const CSyncerSet* _pSyncerSet;
108
Patrick Benavoli68a91282011-08-31 11:23:23 +0200109 // Area configuration validity (invalid area configurations can't be restored)
110 bool _bValid;
111};
112