blob: 5dbe3a0730a875dcafd2a81eb7195115b2ed2e88 [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#include "Subsystem.h"
31#include "ComponentLibrary.h"
32#include "InstanceDefinition.h"
33#include "XmlParameterSerializingContext.h"
34#include "ParameterAccessContext.h"
35#include "ConfigurationAccessContext.h"
36#include "SubsystemObjectCreator.h"
Frederic Boisnard6cae0ec2013-05-23 18:48:58 +020037#include "MappingData.h"
Patrick Benavoli68a91282011-08-31 11:23:23 +020038#include <assert.h>
Frederic Boisnard6cae0ec2013-05-23 18:48:58 +020039#include <sstream>
Patrick Benavoli68a91282011-08-31 11:23:23 +020040
David Wagner01c74952014-03-05 10:55:15 +010041#define base CConfigurableElementWithMapping
Patrick Benavoli68a91282011-08-31 11:23:23 +020042
Sebastien Gonzalved9526492014-02-20 22:28:03 +010043using std::string;
44using std::list;
45using std::ostringstream;
46
David Wagner01c74952014-03-05 10:55:15 +010047CSubsystem::CSubsystem(const string& strName) : base(strName), _pComponentLibrary(new CComponentLibrary), _pInstanceDefinition(new CInstanceDefinition), _bBigEndian(false), _pMappingData(NULL)
Patrick Benavoli68a91282011-08-31 11:23:23 +020048{
49 // Note: A subsystem contains instance components
50 // InstanceDefintion and ComponentLibrary objects are then not chosen to be children
51 // They'll be delt with locally
52}
53
54CSubsystem::~CSubsystem()
55{
56 // Remove subsystem objects
57 SubsystemObjectListIterator subsystemObjectIt;
58
59 for (subsystemObjectIt = _subsystemObjectList.begin(); subsystemObjectIt != _subsystemObjectList.end(); ++subsystemObjectIt) {
60
61 delete *subsystemObjectIt;
62 }
63
64 // Remove susbsystem creators
65 uint32_t uiIndex;
66
67 for (uiIndex = 0; uiIndex < _subsystemObjectCreatorArray.size(); uiIndex++) {
68
69 delete _subsystemObjectCreatorArray[uiIndex];
70 }
71
72 // Order matters!
73 delete _pInstanceDefinition;
74 delete _pComponentLibrary;
David Wagner01c74952014-03-05 10:55:15 +010075
76 delete _pMappingData;
Patrick Benavoli68a91282011-08-31 11:23:23 +020077}
78
79string CSubsystem::getKind() const
80{
81 return "Subsystem";
82}
83
84// Susbsystem Endianness
85bool CSubsystem::isBigEndian() const
86{
87 return _bBigEndian;
88}
89
Guillaume Denneulinf2fd15a2012-12-20 17:53:29 +010090// Susbsystem sanity
91bool CSubsystem::isAlive() const
92{
93 return true;
94}
95
96// Resynchronization after subsystem restart needed
97bool CSubsystem::needResync(bool bClear)
98{
99 (void)bClear;
100
101 return false;
102}
103
Patrick Benavoli68a91282011-08-31 11:23:23 +0200104// From IXmlSink
105bool CSubsystem::fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext)
106{
107 // Context
108 CXmlParameterSerializingContext& parameterBuildContext = static_cast<CXmlParameterSerializingContext&>(serializingContext);
109
110 // Install temporary component library for further component creation
111 parameterBuildContext.setComponentLibrary(_pComponentLibrary);
112
113 CXmlElement childElement;
114
David Wagner01c74952014-03-05 10:55:15 +0100115 // Manage mapping attribute
116 if (xmlElement.hasAttribute("Mapping")) {
117
118 _pMappingData = new CMappingData;
119 if (!_pMappingData->fromXml(xmlElement, serializingContext)) {
120
121 return false;
122 }
123 }
124
Patrick Benavoli68a91282011-08-31 11:23:23 +0200125 // XML populate ComponentLibrary
126 xmlElement.getChildElement("ComponentLibrary", childElement);
127
128 if (!_pComponentLibrary->fromXml(childElement, serializingContext)) {
129
130 return false;
131 }
132
133 // XML populate InstanceDefintion
134 xmlElement.getChildElement("InstanceDefintion", childElement);
135 if (!_pInstanceDefinition->fromXml(childElement, serializingContext)) {
136
137 return false;
138 }
139
140 // Create components
141 _pInstanceDefinition->createInstances(this);
142
143 // Execute mapping to create subsystem mapping entities
144 string strError;
145 if (!mapSubsystemElements(strError)) {
146
147 serializingContext.setError(strError);
148
149 return false;
150 }
151
152 // Endianness
153 _bBigEndian = xmlElement.getAttributeBoolean("Endianness", "Big");
154
155 return true;
156}
157
158// XML configuration settings parsing
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200159bool CSubsystem::serializeXmlSettings(CXmlElement& xmlConfigurationSettingsElementContent, CConfigurationAccessContext& configurationAccessContext) const
Patrick Benavoli68a91282011-08-31 11:23:23 +0200160{
161 // Fix Endianness
162 configurationAccessContext.setBigEndianSubsystem(_bBigEndian);
163
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200164 return base::serializeXmlSettings(xmlConfigurationSettingsElementContent, configurationAccessContext);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200165}
166
167
168bool CSubsystem::mapSubsystemElements(string& strError)
169{
170 // Default mapping context
David Wagner01c74952014-03-05 10:55:15 +0100171 CMappingContext context(_contextMappingKeyArray.size());
172 // Add Subsystem-level mapping data, which will be propagated to all children
173 handleMappingContext(this, context, strError);
174
175 _contextStack.push(context);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200176
177 // Map all instantiated subelements in subsystem
Patrick Benavoli911844b2014-07-23 01:27:00 +0200178 size_t uiNbChildren = getNbChildren();
179 size_t uiChild;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200180
181 for (uiChild = 0; uiChild < uiNbChildren; uiChild++) {
182
183 CInstanceConfigurableElement* pInstanceConfigurableChildElement = static_cast<CInstanceConfigurableElement*>(getChild(uiChild));
184
185 if (!pInstanceConfigurableChildElement->map(*this, strError)) {
186
187 return false;
188 }
189 }
190 return true;
191}
192
193// Parameter access
Patrick Benavoli065264a2011-11-20 15:46:41 +0100194bool CSubsystem::accessValue(CPathNavigator& pathNavigator, string& strValue, bool bSet, CParameterAccessContext& parameterAccessContext) const
Patrick Benavoli68a91282011-08-31 11:23:23 +0200195{
Patrick Benavoli68a91282011-08-31 11:23:23 +0200196 // Deal with Endianness
Patrick Benavoli065264a2011-11-20 15:46:41 +0100197 parameterAccessContext.setBigEndianSubsystem(_bBigEndian);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200198
Patrick Benavoli065264a2011-11-20 15:46:41 +0100199 return base::accessValue(pathNavigator, strValue, bSet, parameterAccessContext);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200200}
201
Frederic Boisnard6cae0ec2013-05-23 18:48:58 +0200202// Formats the mapping of the ConfigurableElements
203string CSubsystem::formatMappingDataList(
204 const list<const CConfigurableElement*>& configurableElementPath) const
205{
206 // The list is parsed in reverse order because it has been filled from the leaf to the trunk
207 // of the tree. When formatting the mapping, we want to start from the subsystem level
208 ostringstream ossStream;
209 list<const CConfigurableElement*>::const_reverse_iterator it;
210 for (it = configurableElementPath.rbegin(); it != configurableElementPath.rend(); ++it) {
211
212 const CInstanceConfigurableElement* pInstanceConfigurableElement =
213 static_cast<const CInstanceConfigurableElement*>(*it);
214
215 ossStream << pInstanceConfigurableElement->getFormattedMapping() << ", ";
216 }
217 return ossStream.str();
218}
219
220// Find the CSubystemObject containing a specific CInstanceConfigurableElement
221const CSubsystemObject* CSubsystem::findSubsystemObjectFromConfigurableElement(
222 const CInstanceConfigurableElement* pInstanceConfigurableElement) const {
223
224 const CSubsystemObject* pSubsystemObject = NULL;
225
226 list<CSubsystemObject*>::const_iterator it;
227 for (it = _subsystemObjectList.begin(); it != _subsystemObjectList.end(); ++it) {
228
229 // Check if one of the SubsystemObjects is associated with a ConfigurableElement
230 // corresponding to the expected one
231 pSubsystemObject = *it;
232 if (pSubsystemObject->getConfigurableElement() == pInstanceConfigurableElement) {
233
234 break;
235 }
236 }
237
238 return pSubsystemObject;
239}
240
Frédéric Boisnard487ce852013-07-19 17:17:52 +0200241void CSubsystem::findSubsystemLevelMappingKeyValue(
Frederic Boisnard6cae0ec2013-05-23 18:48:58 +0200242 const CInstanceConfigurableElement* pInstanceConfigurableElement,
243 string& strMappingKey,
244 string& strMappingValue) const
245{
246 // Find creator to get key name
Sebastien Gonzalved9526492014-02-20 22:28:03 +0100247 std::vector<CSubsystemObjectCreator*>::const_iterator it;
Frederic Boisnard6cae0ec2013-05-23 18:48:58 +0200248 for (it = _subsystemObjectCreatorArray.begin();
249 it != _subsystemObjectCreatorArray.end(); ++it) {
250
251 const CSubsystemObjectCreator* pSubsystemObjectCreator = *it;
252
253 strMappingKey = pSubsystemObjectCreator->getMappingKey();
254
255 // Check if the ObjectCreator MappingKey corresponds to the element mapping data
256 const string* pStrValue;
257 if (pInstanceConfigurableElement->getMappingData(strMappingKey, pStrValue)) {
258
259 strMappingValue = *pStrValue;
260 return;
261 }
262 }
263 assert(0);
264}
265
266// Formats the mapping data as a comma separated list of key value pairs
267string CSubsystem::getFormattedSubsystemMappingData(
268 const CInstanceConfigurableElement* pInstanceConfigurableElement) const
269{
270 // Find the SubsystemObject related to pInstanceConfigurableElement
271 const CSubsystemObject* pSubsystemObject = findSubsystemObjectFromConfigurableElement(
272 pInstanceConfigurableElement);
273
274 // Exit if node does not correspond to a SubsystemObject
275 if (pSubsystemObject == NULL) {
276
277 return "";
278 }
279
280 // Find SubsystemCreator mapping key
281 string strMappingKey;
282 string strMappingValue; // mapping value where amends are not replaced by their value
Frédéric Boisnard487ce852013-07-19 17:17:52 +0200283 findSubsystemLevelMappingKeyValue(pInstanceConfigurableElement, strMappingKey, strMappingValue);
Frederic Boisnard6cae0ec2013-05-23 18:48:58 +0200284
285 // Find SubSystemObject mapping value (with amends replaced by their value)
286 return strMappingKey + ":" + pSubsystemObject->getFormattedMappingValue();
287}
288
289string CSubsystem::getMapping(list<const CConfigurableElement*>& configurableElementPath) const
290{
291 if (configurableElementPath.empty()) {
292
293 return "";
294 }
295
296 // Get the first element, which is the element containing the amended mapping
297 const CInstanceConfigurableElement* pInstanceConfigurableElement =
298 static_cast<const CInstanceConfigurableElement*>(configurableElementPath.front());
299 configurableElementPath.pop_front();
300 // Now the list only contains elements whose mapping are related to the context
301
302 // Format context mapping data
303 string strValue = formatMappingDataList(configurableElementPath);
304
305 // Print the mapping of the first node, which corresponds to a SubsystemObject
306 strValue += getFormattedSubsystemMappingData(pInstanceConfigurableElement);
307
308 return strValue;
309}
310
Patrick Benavoli68a91282011-08-31 11:23:23 +0200311void CSubsystem::logValue(string& strValue, CErrorContext& errorContext) const
312{
Patrick Benavoli065264a2011-11-20 15:46:41 +0100313 CParameterAccessContext& parameterAccessContext = static_cast<CParameterAccessContext&>(errorContext);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200314
315 // Deal with Endianness
Patrick Benavoli065264a2011-11-20 15:46:41 +0100316 parameterAccessContext.setBigEndianSubsystem(_bBigEndian);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200317
318 return base::logValue(strValue, errorContext);
319}
320
Patrick Benavoli6ccab9d2011-11-10 23:21:01 +0100321// Used for simulation and virtual subsystems
Patrick Benavoli68a91282011-08-31 11:23:23 +0200322void CSubsystem::setDefaultValues(CParameterAccessContext& parameterAccessContext) const
323{
324 // Deal with Endianness
325 parameterAccessContext.setBigEndianSubsystem(_bBigEndian);
326
327 base::setDefaultValues(parameterAccessContext);
328}
329
330// Belonging subsystem
331const CSubsystem* CSubsystem::getBelongingSubsystem() const
332{
333 return this;
334}
335
336// Subsystem context mapping keys publication
337void CSubsystem::addContextMappingKey(const string& strMappingKey)
338{
339 _contextMappingKeyArray.push_back(strMappingKey);
340}
341
342// Subsystem object creator publication (strong reference)
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200343void CSubsystem::addSubsystemObjectFactory(CSubsystemObjectCreator* pSubsystemObjectCreator)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200344{
345 _subsystemObjectCreatorArray.push_back(pSubsystemObjectCreator);
346}
347
Frederic Boisnard6cae0ec2013-05-23 18:48:58 +0200348// Generic error handling from derived subsystem classes
David Wagner01c74952014-03-05 10:55:15 +0100349string CSubsystem::getMappingError(
350 const string& strKey,
351 const string& strMessage,
352 const CConfigurableElementWithMapping* pConfigurableElementWithMapping) const
Frederic Boisnard6cae0ec2013-05-23 18:48:58 +0200353{
354 return getName() + " " + getKind() + " " +
355 "mapping:\n" + strKey + " " +
356 "error: \"" + strMessage + "\" " +
David Wagner01c74952014-03-05 10:55:15 +0100357 "for element " + pConfigurableElementWithMapping->getPath();
358}
359
360
361bool CSubsystem::getMappingData(const std::string& strKey, const std::string*& pStrValue) const
362{
363 if (_pMappingData) {
364
365 return _pMappingData->getValue(strKey, pStrValue);
366 }
367 return false;
Frederic Boisnard6cae0ec2013-05-23 18:48:58 +0200368}
369
Patrick Benavoli68a91282011-08-31 11:23:23 +0200370// Mapping generic context handling
Frederic Boisnard6cae0ec2013-05-23 18:48:58 +0200371bool CSubsystem::handleMappingContext(
David Wagner01c74952014-03-05 10:55:15 +0100372 const CConfigurableElementWithMapping* pConfigurableElementWithMapping,
Frederic Boisnard6cae0ec2013-05-23 18:48:58 +0200373 CMappingContext& context,
374 string& strError) const
Patrick Benavoli68a91282011-08-31 11:23:23 +0200375{
376 // Feed context with found mapping data
377 uint32_t uiItem;
378
Renaud de Chivre46966e02013-09-02 10:48:36 +0200379 for (uiItem = 0; uiItem < _contextMappingKeyArray.size(); uiItem++) {
Patrick Benavoli68a91282011-08-31 11:23:23 +0200380
Renaud de Chivre46966e02013-09-02 10:48:36 +0200381 const string& strKey = _contextMappingKeyArray[uiItem];
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200382 const string* pStrValue;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200383
David Wagner01c74952014-03-05 10:55:15 +0100384 if (pConfigurableElementWithMapping->getMappingData(strKey, pStrValue)) {
Patrick Benavoli68a91282011-08-31 11:23:23 +0200385 // Assign item to context
Renaud de Chivre46966e02013-09-02 10:48:36 +0200386 if (!context.setItem(uiItem, &strKey, pStrValue)) {
Patrick Benavoli68a91282011-08-31 11:23:23 +0200387
David Wagner01c74952014-03-05 10:55:15 +0100388 strError = getMappingError(strKey, "Already set", pConfigurableElementWithMapping);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200389
390 return false;
391 }
392 }
393 }
394 return true;
395}
396
Kevin Rocard084cafb2013-01-28 17:02:08 +0100397// Subsystem object creation handling
398bool CSubsystem::handleSubsystemObjectCreation(
399 CInstanceConfigurableElement* pInstanceConfigurableElement,
400 CMappingContext& context, bool& bHasCreatedSubsystemObject, string& strError)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200401{
402 uint32_t uiItem;
Kevin Rocard084cafb2013-01-28 17:02:08 +0100403 bHasCreatedSubsystemObject = false;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200404
405 for (uiItem = 0; uiItem < _subsystemObjectCreatorArray.size(); uiItem++) {
406
Kevin Rocard3414f992013-04-02 19:49:40 +0200407 const CSubsystemObjectCreator* pSubsystemObjectCreator =
408 _subsystemObjectCreatorArray[uiItem];
Patrick Benavoli68a91282011-08-31 11:23:23 +0200409
410 // Mapping key
411 string strKey = pSubsystemObjectCreator->getMappingKey();
412 // Object id
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200413 const string* pStrValue;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200414
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200415 if (pInstanceConfigurableElement->getMappingData(strKey, pStrValue)) {
Patrick Benavoli68a91282011-08-31 11:23:23 +0200416
Kevin Rocard3414f992013-04-02 19:49:40 +0200417 // First check context consistency
418 // (required ancestors must have been set prior to object creation)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200419 uint32_t uiAncestorKey;
420 uint32_t uiAncestorMask = pSubsystemObjectCreator->getAncestorMask();
421
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200422 for (uiAncestorKey = 0; uiAncestorKey < _contextMappingKeyArray.size(); uiAncestorKey++) {
Patrick Benavoli68a91282011-08-31 11:23:23 +0200423
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200424 if (!((1 << uiAncestorKey) & uiAncestorMask)) {
425 // Ancestor not required
426 continue;
427 }
428 // Check ancestor was provided
Patrick Benavoli68a91282011-08-31 11:23:23 +0200429 if (!context.iSet(uiAncestorKey)) {
430
Frederic Boisnard6cae0ec2013-05-23 18:48:58 +0200431 strError = getMappingError(strKey, _contextMappingKeyArray[uiAncestorKey] +
432 " not set", pInstanceConfigurableElement);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200433
434 return false;
435 }
436 }
437
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200438 // Then check configurable element size is correct
Kevin Rocard3414f992013-04-02 19:49:40 +0200439 if (pInstanceConfigurableElement->getFootPrint() >
440 pSubsystemObjectCreator->getMaxConfigurableElementSize()) {
Patrick Benavoli68a91282011-08-31 11:23:23 +0200441
Kevin Rocard3414f992013-04-02 19:49:40 +0200442 string strSizeError = "Size should not exceed " +
Kevin Rocardb80adac2015-02-03 19:04:10 +0100443 toString(pSubsystemObjectCreator->getMaxConfigurableElementSize());
Patrick Benavoli68a91282011-08-31 11:23:23 +0200444
Frederic Boisnard6cae0ec2013-05-23 18:48:58 +0200445 strError = getMappingError(strKey, strSizeError, pInstanceConfigurableElement);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200446
447 return false;
448 }
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200449
450 // Do create object and keep its track
Kevin Rocard3414f992013-04-02 19:49:40 +0200451 _subsystemObjectList.push_back(pSubsystemObjectCreator->objectCreate(
452 *pStrValue, pInstanceConfigurableElement, context));
Patrick Benavoli68a91282011-08-31 11:23:23 +0200453
Kevin Rocard084cafb2013-01-28 17:02:08 +0100454 // Indicate subsytem creation to caller
455 bHasCreatedSubsystemObject = true;
456
457 // The subsystem Object has been instantiated, no need to continue looking for an
458 // instantiation mapping
459 break;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200460 }
461 }
Patrick Benavoli68a91282011-08-31 11:23:23 +0200462
Kevin Rocard084cafb2013-01-28 17:02:08 +0100463 return true;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200464}
465
Patrick Benavoli68a91282011-08-31 11:23:23 +0200466// From IMapper
Kevin Rocard084cafb2013-01-28 17:02:08 +0100467// Handle a configurable element mapping
468bool CSubsystem::mapBegin(CInstanceConfigurableElement* pInstanceConfigurableElement,
469 bool& bKeepDiving, string& strError)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200470{
471 // Get current context
472 CMappingContext context = _contextStack.top();
473
Kevin Rocard084cafb2013-01-28 17:02:08 +0100474 // Add mapping in context
Renaud de Chivre46966e02013-09-02 10:48:36 +0200475 if (!handleMappingContext(pInstanceConfigurableElement, context,
Frederic Boisnard6cae0ec2013-05-23 18:48:58 +0200476 strError)) {
Kevin Rocard084cafb2013-01-28 17:02:08 +0100477
478 return false;
479 }
480
481 // Push context
482 _contextStack.push(context);
483
484 // Assume diving by default
485 bKeepDiving = true;
486
487 // Deal with ambiguous usage of parameter blocks
488 bool bShouldCreateSubsystemObject = true;
489
Patrick Benavoli68a91282011-08-31 11:23:23 +0200490 switch(pInstanceConfigurableElement->getType()) {
491
Kevin Rocard084cafb2013-01-28 17:02:08 +0100492 case CInstanceConfigurableElement::EComponent:
Kevin Rocard084cafb2013-01-28 17:02:08 +0100493 case CInstanceConfigurableElement::EParameterBlock:
494 // Subsystem object creation is optional in parameter blocks
495 bShouldCreateSubsystemObject = false;
496 // No break
497 case CInstanceConfigurableElement::EBitParameterBlock:
498 case CInstanceConfigurableElement::EParameter:
499 case CInstanceConfigurableElement::EStringParameter:
Patrick Benavoli68a91282011-08-31 11:23:23 +0200500
Kevin Rocard084cafb2013-01-28 17:02:08 +0100501 bool bHasCreatedSubsystemObject;
502
503 if (!handleSubsystemObjectCreation(pInstanceConfigurableElement, context,
504 bHasCreatedSubsystemObject, strError)) {
505
506 return false;
507 }
508 // Check for creation error
509 if (bShouldCreateSubsystemObject && !bHasCreatedSubsystemObject) {
510
Frederic Boisnard6cae0ec2013-05-23 18:48:58 +0200511 strError = getMappingError("Not found",
512 "Subsystem object mapping key is missing",
513 pInstanceConfigurableElement);
Kevin Rocard084cafb2013-01-28 17:02:08 +0100514 return false;
515 }
516 // Not created and no error, keep diving
517 bKeepDiving = !bHasCreatedSubsystemObject;
518
519 return true;
520
521 default:
522 assert(0);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200523 return false;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200524 }
Patrick Benavoli68a91282011-08-31 11:23:23 +0200525}
526
527void CSubsystem::mapEnd()
528{
529 // Unstack context
530 _contextStack.pop();
531}