blob: 0b808ad10f040f6da1890c2354ec9ecf6cfaac4b [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
Guillaume Denneulinf2fd15a2012-12-20 17:53:29 +010052 // Susbsystem sanity
53 virtual bool isAlive() const;
54
55 // Resynchronization after subsystem restart needed
56 virtual bool needResync(bool bClear);
57
Patrick Benavoli68a91282011-08-31 11:23:23 +020058 // XML configuration settings parsing
Patrick Benavoli6ba361d2011-08-31 11:23:24 +020059 virtual bool serializeXmlSettings(CXmlElement& xmlConfigurationSettingsElementContent, CConfigurationAccessContext& configurationAccessContext) const;
Patrick Benavoli68a91282011-08-31 11:23:23 +020060
61 // from CElement
62 virtual string getKind() const;
63protected:
64 // Parameter access
Patrick Benavoli065264a2011-11-20 15:46:41 +010065 virtual bool accessValue(CPathNavigator& pathNavigator, string& strValue, bool bSet, CParameterAccessContext& parameterAccessContext) const;
Patrick Benavoli68a91282011-08-31 11:23:23 +020066 virtual void logValue(string& strValue, CErrorContext& errorContext) const;
Patrick Benavoli6ccab9d2011-11-10 23:21:01 +010067 // Used for simulation and virtual subsystems
Patrick Benavoli68a91282011-08-31 11:23:23 +020068 virtual void setDefaultValues(CParameterAccessContext& parameterAccessContext) const;
69
70 /// Functionality intendedn for derived Subsystems
71 // Subsystem context mapping keys publication
72 void addContextMappingKey(const string& strMappingKey);
73 // Subsystem object creator publication (strong reference)
Patrick Benavoli6ba361d2011-08-31 11:23:24 +020074 void addSubsystemObjectFactory(CSubsystemObjectCreator* pSubsystemObjectCreator);
Patrick Benavoli68a91282011-08-31 11:23:23 +020075private:
JhinX Lee4ebc0982012-07-12 17:50:07 +020076 CSubsystem(const CSubsystem&);
77 CSubsystem& operator=(const CSubsystem&);
78
Patrick Benavoli68a91282011-08-31 11:23:23 +020079 // Belonging subsystem
80 virtual const CSubsystem* getBelongingSubsystem() const;
81
82 // Mapping execution
83 bool mapSubsystemElements(string& strError);
84
85 // Generic subsystem mapping error handling
86 void getMappingError(string& strError, const string& strKey, const string& strMessage, const CInstanceConfigurableElement* pInstanceConfigurableElement);
87
88 // From IMapper
Patrick Benavolid3a86bf2011-11-07 19:33:30 +010089 virtual bool mapBegin(CInstanceConfigurableElement* pInstanceConfigurableElement, bool& bKeepDiving, string& strError);
Patrick Benavoli68a91282011-08-31 11:23:23 +020090 virtual void mapEnd();
91
92 // Mapping generic context handling
93 bool handleMappingContext(const CInstanceConfigurableElement* pInstanceConfigurableElement, CMappingContext& context, string& strError);
94 // Subsystem object creation handling
95 bool handleSubsystemObjectCreation(CInstanceConfigurableElement* pInstanceConfigurableElement, CMappingContext& context, string& strError);
96
97 // Subsystem context mapping keys
98 vector<string> _contextMappingKeyArray;
99
100 // Subsystem object creator map
101 vector<CSubsystemObjectCreator*> _subsystemObjectCreatorArray;
102
103 // Subsystem sync objects (house keeping)
104 list<CSubsystemObject*> _subsystemObjectList;
105
106 // Mapping Context stack
107 stack<CMappingContext> _contextStack;
108
109 // Subelements
110 CComponentLibrary* _pComponentLibrary;
111 CInstanceDefinition* _pInstanceDefinition;
112
113 // Endianness
114 bool _bBigEndian;
115};