blob: ecb6d4d750544a4a2ac66b8367c332908294ecc7 [file] [log] [blame]
Kevin Rocard93250d12012-07-19 17:48:30 +02001/*
Patrick Benavoli68a91282011-08-31 11:23:23 +02002 * INTEL CONFIDENTIAL
3 * Copyright © 2011 Intel
4 * Corporation All Rights Reserved.
5 *
6 * The source code contained or described herein and all documents related to
7 * the source code ("Material") are owned by Intel Corporation or its suppliers
8 * or licensors. Title to the Material remains with Intel Corporation or its
9 * suppliers and licensors. The Material contains trade secrets and proprietary
10 * and confidential information of Intel or its suppliers and licensors. The
11 * Material is protected by worldwide copyright and trade secret laws and
12 * treaty provisions. No part of the Material may be used, copied, reproduced,
13 * modified, published, uploaded, posted, transmitted, distributed, or
14 * disclosed in any way without Intel’s prior express written permission.
15 *
16 * No license under any patent, copyright, trade secret or other intellectual
17 * property right is granted to or conferred upon you by disclosure or delivery
18 * of the Materials, either expressly, by implication, inducement, estoppel or
19 * otherwise. Any license under such intellectual property rights must be
20 * express and approved by Intel in writing.
21 *
Patrick Benavoli68a91282011-08-31 11:23:23 +020022 * CREATED: 2011-06-01
23 * UPDATED: 2011-07-27
Patrick Benavoli68a91282011-08-31 11:23:23 +020024 */
25#pragma once
26
27#include "ConfigurableElement.h"
28#include "Mapper.h"
29#include "MappingContext.h"
30#include <stack>
31#include <vector>
32
33class CInstanceDefinition;
34class CComponentLibrary;
35class CSubsystemObject;
36class CSubsystemObjectCreator;
37
38class CSubsystem : public CConfigurableElement, private IMapper
39{
40 // Subsystem objects iterator
41 typedef list<CSubsystemObject*>::const_iterator SubsystemObjectListIterator;
42public:
43 CSubsystem(const string& strName);
44 virtual ~CSubsystem();
45
46 // From IXmlSink
47 virtual bool fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext);
48
49 // Susbsystem Endianness
50 bool isBigEndian() const;
51
52 // XML configuration settings parsing
Patrick Benavoli6ba361d2011-08-31 11:23:24 +020053 virtual bool serializeXmlSettings(CXmlElement& xmlConfigurationSettingsElementContent, CConfigurationAccessContext& configurationAccessContext) const;
Patrick Benavoli68a91282011-08-31 11:23:23 +020054
55 // from CElement
56 virtual string getKind() const;
57protected:
58 // Parameter access
Patrick Benavoli065264a2011-11-20 15:46:41 +010059 virtual bool accessValue(CPathNavigator& pathNavigator, string& strValue, bool bSet, CParameterAccessContext& parameterAccessContext) const;
Patrick Benavoli68a91282011-08-31 11:23:23 +020060 virtual void logValue(string& strValue, CErrorContext& errorContext) const;
Patrick Benavoli6ccab9d2011-11-10 23:21:01 +010061 // Used for simulation and virtual subsystems
Patrick Benavoli68a91282011-08-31 11:23:23 +020062 virtual void setDefaultValues(CParameterAccessContext& parameterAccessContext) const;
63
64 /// Functionality intendedn for derived Subsystems
65 // Subsystem context mapping keys publication
66 void addContextMappingKey(const string& strMappingKey);
67 // Subsystem object creator publication (strong reference)
Patrick Benavoli6ba361d2011-08-31 11:23:24 +020068 void addSubsystemObjectFactory(CSubsystemObjectCreator* pSubsystemObjectCreator);
Patrick Benavoli68a91282011-08-31 11:23:23 +020069private:
70 // Belonging subsystem
71 virtual const CSubsystem* getBelongingSubsystem() const;
72
73 // Mapping execution
74 bool mapSubsystemElements(string& strError);
75
76 // Generic subsystem mapping error handling
77 void getMappingError(string& strError, const string& strKey, const string& strMessage, const CInstanceConfigurableElement* pInstanceConfigurableElement);
78
79 // From IMapper
Patrick Benavolid3a86bf2011-11-07 19:33:30 +010080 virtual bool mapBegin(CInstanceConfigurableElement* pInstanceConfigurableElement, bool& bKeepDiving, string& strError);
Patrick Benavoli68a91282011-08-31 11:23:23 +020081 virtual void mapEnd();
82
83 // Mapping generic context handling
84 bool handleMappingContext(const CInstanceConfigurableElement* pInstanceConfigurableElement, CMappingContext& context, string& strError);
85 // Subsystem object creation handling
86 bool handleSubsystemObjectCreation(CInstanceConfigurableElement* pInstanceConfigurableElement, CMappingContext& context, string& strError);
87
88 // Subsystem context mapping keys
89 vector<string> _contextMappingKeyArray;
90
91 // Subsystem object creator map
92 vector<CSubsystemObjectCreator*> _subsystemObjectCreatorArray;
93
94 // Subsystem sync objects (house keeping)
95 list<CSubsystemObject*> _subsystemObjectList;
96
97 // Mapping Context stack
98 stack<CMappingContext> _contextStack;
99
100 // Subelements
101 CComponentLibrary* _pComponentLibrary;
102 CInstanceDefinition* _pInstanceDefinition;
103
104 // Endianness
105 bool _bBigEndian;
106};