blob: 18256cfa5256eac9686a88c939619e873949cef9 [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 "Element.h"
33
34#include <list>
35
36class CConfigurableDomain;
37class CSyncerSet;
38class ISyncer;
39class CSubsystem;
40class CConfigurationAccessContext;
41class CParameterAccessContext;
Frédéric Boisnard9620e442012-05-30 16:15:02 +020042class CAreaConfiguration;
Patrick Benavoli68a91282011-08-31 11:23:23 +020043
44class CConfigurableElement : public CElement
45{
46 friend class CConfigurableDomain;
Patrick Benavoli63499d42011-10-24 18:50:03 +020047 friend class CDomainConfiguration;
Sebastien Gonzalved9526492014-02-20 22:28:03 +010048 typedef std::list<const CConfigurableDomain*>::const_iterator ConfigurableDomainListConstIterator;
Patrick Benavoli68a91282011-08-31 11:23:23 +020049public:
Sebastien Gonzalved9526492014-02-20 22:28:03 +010050 CConfigurableElement(const std::string& strName = "");
Patrick Benavoli68a91282011-08-31 11:23:23 +020051 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 Gonzalved9526492014-02-20 22:28:03 +010067 void listBelongingDomains(std::string& strResult, bool bVertical = true) const;
Patrick Benavoli68a91282011-08-31 11:23:23 +020068
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 Gonzalved9526492014-02-20 22:28:03 +010076 void listAssociatedDomains(std::string& strResult, bool bVertical = true) const;
Patrick Benavoli911844b2014-07-23 01:27:00 +020077 size_t getBelongingDomainCount() const;
Patrick Benavoli68a91282011-08-31 11:23:23 +020078
79 // Elements with no domains
Sebastien Gonzalved9526492014-02-20 22:28:03 +010080 void listRogueElements(std::string& strResult) const;
Patrick Benavoli68a91282011-08-31 11:23:23 +020081
Patrick Benavoli4bed9212011-10-27 14:18:00 +020082 // Belonging to no domains
83 bool isRogue() const;
84
Patrick Benavoli6ba361d2011-08-31 11:23:24 +020085 // Footprint as string
Sebastien Gonzalved9526492014-02-20 22:28:03 +010086 std::string getFootprintAsString() const;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +020087
Patrick Benavoli065264a2011-11-20 15:46:41 +010088 // Belonging subsystem
89 virtual const CSubsystem* getBelongingSubsystem() const;
90
91 // Check element is a parameter
92 virtual bool isParameter() const;
93
Frédéric Boisnard9620e442012-05-30 16:15:02 +020094 // AreaConfiguration creation
95 virtual CAreaConfiguration* createAreaConfiguration(const CSyncerSet* pSyncerSet) const;
96
Patrick Benavoli68a91282011-08-31 11:23:23 +020097 // Parameter access
Sebastien Gonzalved9526492014-02-20 22:28:03 +010098 virtual bool accessValue(CPathNavigator& pathNavigator, std::string& strValue, bool bSet, CParameterAccessContext& parameterAccessContext) const;
Frederic Boisnard6cae0ec2013-05-23 18:48:58 +020099
100 /**
101 * Get the list of all the ancestors that have a mapping.
102 *
Sebastien Gonzalved9526492014-02-20 22:28:03 +0100103 * The mapping is represented as a std::string of all the mapping data (key:value) defined in the
Frederic Boisnard6cae0ec2013-05-23 18:48:58 +0200104 * 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 Gonzalved9526492014-02-20 22:28:03 +0100113 virtual void getListOfElementsWithMapping(std::list<const CConfigurableElement*>&
Frederic Boisnard6cae0ec2013-05-23 18:48:58 +0200114 configurableElementPath) const;
115
Patrick Benavoli6ccab9d2011-11-10 23:21:01 +0100116 // Used for simulation and virtual subsystems
Patrick Benavoli68a91282011-08-31 11:23:23 +0200117 virtual void setDefaultValues(CParameterAccessContext& parameterAccessContext) const;
118
Patrick Benavoli2ecf9002011-08-31 11:23:24 +0200119 // Element properties
Sebastien Gonzalved9526492014-02-20 22:28:03 +0100120 virtual void showProperties(std::string& strResult) const;
Patrick Benavoli2ecf9002011-08-31 11:23:24 +0200121
Patrick Benavoli68a91282011-08-31 11:23:23 +0200122 // XML configuration settings parsing
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200123 virtual bool serializeXmlSettings(CXmlElement& xmlConfigurationSettingsElementContent, CConfigurationAccessContext& configurationAccessContext) const;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200124protected:
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 Boisnard6cae0ec2013-05-23 18:48:58 +0200131
Patrick Benavoli68a91282011-08-31 11:23:23 +0200132private:
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 Gonzalved9526492014-02-20 22:28:03 +0100141 void getBelongingDomains(std::list<const CConfigurableDomain*>& configurableDomainList) const;
142 void listDomains(const std::list<const CConfigurableDomain*>& configurableDomainList, std::string& strResult, bool bVertical) const;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200143
Patrick Benavoli68a91282011-08-31 11:23:23 +0200144 // 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 Gonzalved9526492014-02-20 22:28:03 +0100151 std::list<const CConfigurableDomain*> _configurableDomainList;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200152};
153