| 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 "Element.h" |
| 33 | |
| 34 | #include <list> |
| 35 | |
| 36 | class CConfigurableDomain; |
| 37 | class CSyncerSet; |
| 38 | class ISyncer; |
| 39 | class CSubsystem; |
| 40 | class CConfigurationAccessContext; |
| 41 | class CParameterAccessContext; |
| Frédéric Boisnard | 9620e44 | 2012-05-30 16:15:02 +0200 | [diff] [blame] | 42 | class CAreaConfiguration; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 43 | |
| 44 | class CConfigurableElement : public CElement |
| 45 | { |
| 46 | friend class CConfigurableDomain; |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 47 | friend class CDomainConfiguration; |
| Sebastien Gonzalve | d952649 | 2014-02-20 22:28:03 +0100 | [diff] [blame] | 48 | typedef std::list<const CConfigurableDomain*>::const_iterator ConfigurableDomainListConstIterator; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 49 | public: |
| Sebastien Gonzalve | d952649 | 2014-02-20 22:28:03 +0100 | [diff] [blame] | 50 | CConfigurableElement(const std::string& strName = ""); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 51 | virtual ~CConfigurableElement(); |
| 52 | |
| 53 | // Offset in main blackboard |
| 54 | void setOffset(uint32_t uiOffset); |
| 55 | uint32_t getOffset() const; |
| 56 | |
| 57 | // Allocation |
| 58 | virtual uint32_t getFootPrint() const; |
| 59 | |
| 60 | // Syncer set (me, ascendant or descendant ones) |
| 61 | void fillSyncerSet(CSyncerSet& syncerSet) const; |
| 62 | |
| 63 | // Belonging domain |
| 64 | bool belongsTo(const CConfigurableDomain* pConfigurableDomain) const; |
| 65 | |
| 66 | // Belonging domains |
| Sebastien Gonzalve | d952649 | 2014-02-20 22:28:03 +0100 | [diff] [blame] | 67 | void listBelongingDomains(std::string& strResult, bool bVertical = true) const; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 68 | |
| 69 | // Matching check for domain association |
| 70 | bool hasNoDomainAssociated() const; |
| 71 | |
| 72 | // Matching check for no valid associated domains |
| 73 | bool hasNoValidDomainAssociated() const; |
| 74 | |
| 75 | // Owning domains |
| Sebastien Gonzalve | d952649 | 2014-02-20 22:28:03 +0100 | [diff] [blame] | 76 | void listAssociatedDomains(std::string& strResult, bool bVertical = true) const; |
| Patrick Benavoli | 911844b | 2014-07-23 01:27:00 +0200 | [diff] [blame^] | 77 | size_t getBelongingDomainCount() const; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 78 | |
| 79 | // Elements with no domains |
| Sebastien Gonzalve | d952649 | 2014-02-20 22:28:03 +0100 | [diff] [blame] | 80 | void listRogueElements(std::string& strResult) const; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 81 | |
| Patrick Benavoli | 4bed921 | 2011-10-27 14:18:00 +0200 | [diff] [blame] | 82 | // Belonging to no domains |
| 83 | bool isRogue() const; |
| 84 | |
| Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 85 | // Footprint as string |
| Sebastien Gonzalve | d952649 | 2014-02-20 22:28:03 +0100 | [diff] [blame] | 86 | std::string getFootprintAsString() const; |
| Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 87 | |
| Patrick Benavoli | 065264a | 2011-11-20 15:46:41 +0100 | [diff] [blame] | 88 | // Belonging subsystem |
| 89 | virtual const CSubsystem* getBelongingSubsystem() const; |
| 90 | |
| 91 | // Check element is a parameter |
| 92 | virtual bool isParameter() const; |
| 93 | |
| Frédéric Boisnard | 9620e44 | 2012-05-30 16:15:02 +0200 | [diff] [blame] | 94 | // AreaConfiguration creation |
| 95 | virtual CAreaConfiguration* createAreaConfiguration(const CSyncerSet* pSyncerSet) const; |
| 96 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 97 | // Parameter access |
| Sebastien Gonzalve | d952649 | 2014-02-20 22:28:03 +0100 | [diff] [blame] | 98 | virtual bool accessValue(CPathNavigator& pathNavigator, std::string& strValue, bool bSet, CParameterAccessContext& parameterAccessContext) const; |
| Frederic Boisnard | 6cae0ec | 2013-05-23 18:48:58 +0200 | [diff] [blame] | 99 | |
| 100 | /** |
| 101 | * Get the list of all the ancestors that have a mapping. |
| 102 | * |
| Sebastien Gonzalve | d952649 | 2014-02-20 22:28:03 +0100 | [diff] [blame] | 103 | * The mapping is represented as a std::string of all the mapping data (key:value) defined in the |
| Frederic Boisnard | 6cae0ec | 2013-05-23 18:48:58 +0200 | [diff] [blame] | 104 | * context of the element. |
| 105 | * In this class, the method is generic and calls its parent getListOfElementsWithMappings(...) |
| 106 | * method. |
| 107 | * |
| 108 | * @param[in:out] configurableElementPath List of all the ConfigurableElements found |
| 109 | * that have a mapping. Elements are added at the end of the list, so the root Element will be |
| 110 | * the last one. |
| 111 | * |
| 112 | */ |
| Sebastien Gonzalve | d952649 | 2014-02-20 22:28:03 +0100 | [diff] [blame] | 113 | virtual void getListOfElementsWithMapping(std::list<const CConfigurableElement*>& |
| Frederic Boisnard | 6cae0ec | 2013-05-23 18:48:58 +0200 | [diff] [blame] | 114 | configurableElementPath) const; |
| 115 | |
| Patrick Benavoli | 6ccab9d | 2011-11-10 23:21:01 +0100 | [diff] [blame] | 116 | // Used for simulation and virtual subsystems |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 117 | virtual void setDefaultValues(CParameterAccessContext& parameterAccessContext) const; |
| 118 | |
| Patrick Benavoli | 2ecf900 | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 119 | // Element properties |
| Sebastien Gonzalve | d952649 | 2014-02-20 22:28:03 +0100 | [diff] [blame] | 120 | virtual void showProperties(std::string& strResult) const; |
| Patrick Benavoli | 2ecf900 | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 121 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 122 | // XML configuration settings parsing |
| Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 123 | virtual bool serializeXmlSettings(CXmlElement& xmlConfigurationSettingsElementContent, CConfigurationAccessContext& configurationAccessContext) const; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 124 | protected: |
| 125 | // Syncer (me or ascendant) |
| 126 | virtual ISyncer* getSyncer() const; |
| 127 | // Syncer set (descendant) |
| 128 | virtual void fillSyncerSetFromDescendant(CSyncerSet& syncerSet) const; |
| 129 | // Configuration Domain local search |
| 130 | bool containsConfigurableDomain(const CConfigurableDomain* pConfigurableDomain) const; |
| Frederic Boisnard | 6cae0ec | 2013-05-23 18:48:58 +0200 | [diff] [blame] | 131 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 132 | private: |
| 133 | // Configurable domain association |
| 134 | void addAttachedConfigurableDomain(const CConfigurableDomain* pConfigurableDomain); |
| 135 | void removeAttachedConfigurableDomain(const CConfigurableDomain* pConfigurableDomain); |
| 136 | |
| 137 | // Belonging domain ascending search |
| 138 | bool belongsToDomainAscending(const CConfigurableDomain* pConfigurableDomain) const; |
| 139 | |
| 140 | // Belonging domains |
| Sebastien Gonzalve | d952649 | 2014-02-20 22:28:03 +0100 | [diff] [blame] | 141 | void getBelongingDomains(std::list<const CConfigurableDomain*>& configurableDomainList) const; |
| 142 | void listDomains(const std::list<const CConfigurableDomain*>& configurableDomainList, std::string& strResult, bool bVertical) const; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 143 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 144 | // Check parent is still of current type (by structure knowledge) |
| 145 | bool isOfConfigurableElementType(const CElement* pParent) const; |
| 146 | |
| 147 | // Offset in main blackboard |
| 148 | uint32_t _uiOffset; |
| 149 | |
| 150 | // Associated configurable domains |
| Sebastien Gonzalve | d952649 | 2014-02-20 22:28:03 +0100 | [diff] [blame] | 151 | std::list<const CConfigurableDomain*> _configurableDomainList; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 152 | }; |
| 153 | |