| 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 "ParameterBlackboard.h" |
| 33 | #include "BinaryStream.h" |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 34 | #include "SyncerSet.h" |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 35 | |
| 36 | using namespace std; |
| 37 | |
| 38 | class CConfigurableElement; |
| 39 | class CXmlElement; |
| 40 | class CConfigurationAccessContext; |
| 41 | |
| 42 | class CAreaConfiguration |
| 43 | { |
| 44 | public: |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 45 | CAreaConfiguration(const CConfigurableElement* pConfigurableElement, const CSyncerSet* pSyncerSet); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 46 | |
| Sebastien Gonzalve | d7e4844 | 2013-03-12 14:30:27 +0100 | [diff] [blame] | 47 | /* FIXME this was missing and probably buggy*/ |
| 48 | virtual ~CAreaConfiguration() {} |
| 49 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 50 | // Save data from current |
| 51 | void save(const CParameterBlackboard* pMainBlackboard); |
| 52 | |
| 53 | // Apply data to current |
| Kevin Rocard | ace81f8 | 2012-12-11 16:19:17 +0100 | [diff] [blame] | 54 | bool restore(CParameterBlackboard* pMainBlackboard, bool bSync, list<string>* plstrError) const; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 55 | |
| 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 Boisnard | 9620e44 | 2012-05-30 16:15:02 +0200 | [diff] [blame] | 69 | virtual void copyToOuter(CAreaConfiguration* pToAreaConfiguration) const; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 70 | |
| 71 | // Configuration splitting |
| Frédéric Boisnard | 9620e44 | 2012-05-30 16:15:02 +0200 | [diff] [blame] | 72 | virtual void copyFromOuter(const CAreaConfiguration* pFromAreaConfiguration); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 73 | |
| 74 | // XML configuration settings parsing/composing |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 75 | bool serializeXmlSettings(CXmlElement& xmlConfigurableElementSettingsElementContent, CConfigurationAccessContext& configurationAccessContext); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 76 | |
| 77 | // Serialization |
| 78 | void serialize(CBinaryStream& binaryStream); |
| 79 | |
| 80 | // Data size |
| 81 | uint32_t getSize() const; |
| Frédéric Boisnard | 9620e44 | 2012-05-30 16:15:02 +0200 | [diff] [blame] | 82 | |
| Frédéric Boisnard | e42dacd | 2013-02-25 15:56:56 +0100 | [diff] [blame] | 83 | // Fetch the Configuration Blackboard |
| 84 | CParameterBlackboard& getBlackboard(); |
| 85 | const CParameterBlackboard& getBlackboard() const; |
| 86 | |
| Frédéric Boisnard | 9620e44 | 2012-05-30 16:15:02 +0200 | [diff] [blame] | 87 | protected: |
| 88 | CAreaConfiguration(const CConfigurableElement* pConfigurableElement, const CSyncerSet* pSyncerSet, uint32_t uiSize); |
| 89 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 90 | private: |
| Frédéric Boisnard | 9620e44 | 2012-05-30 16:15:02 +0200 | [diff] [blame] | 91 | // Blackboard copies |
| 92 | virtual void copyTo(CParameterBlackboard* pToBlackboard, uint32_t uiOffset) const; |
| 93 | virtual void copyFrom(const CParameterBlackboard* pFromBlackboard, uint32_t uiOffset); |
| 94 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 95 | // Store validity |
| 96 | void setValid(bool bValid); |
| 97 | |
| Frédéric Boisnard | 9620e44 | 2012-05-30 16:15:02 +0200 | [diff] [blame] | 98 | protected: |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 99 | // Associated configurable element |
| 100 | const CConfigurableElement* _pConfigurableElement; |
| 101 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 102 | // Configurable element settings |
| 103 | CParameterBlackboard _blackboard; |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 104 | |
| Frédéric Boisnard | 9620e44 | 2012-05-30 16:15:02 +0200 | [diff] [blame] | 105 | private: |
| 106 | // Syncer set (required for immediate synchronization) |
| 107 | const CSyncerSet* _pSyncerSet; |
| 108 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 109 | // Area configuration validity (invalid area configurations can't be restored) |
| 110 | bool _bValid; |
| 111 | }; |
| 112 | |