Kevin Rocard | 93250d1 | 2012-07-19 17:48:30 +0200 | [diff] [blame] | 1 | /* |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 2 | * 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 Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 22 | * CREATED: 2011-06-01 |
| 23 | * UPDATED: 2011-07-27 |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 24 | */ |
| 25 | #pragma once |
| 26 | |
| 27 | #include "ConfigurableElement.h" |
| 28 | #include "Mapper.h" |
| 29 | #include "MappingContext.h" |
| 30 | #include <stack> |
| 31 | #include <vector> |
| 32 | |
| 33 | class CInstanceDefinition; |
| 34 | class CComponentLibrary; |
| 35 | class CSubsystemObject; |
| 36 | class CSubsystemObjectCreator; |
| 37 | |
| 38 | class CSubsystem : public CConfigurableElement, private IMapper |
| 39 | { |
| 40 | // Subsystem objects iterator |
| 41 | typedef list<CSubsystemObject*>::const_iterator SubsystemObjectListIterator; |
| 42 | public: |
| 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 Denneulin | f2fd15a | 2012-12-20 17:53:29 +0100 | [diff] [blame] | 52 | // Susbsystem sanity |
| 53 | virtual bool isAlive() const; |
| 54 | |
| 55 | // Resynchronization after subsystem restart needed |
| 56 | virtual bool needResync(bool bClear); |
| 57 | |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 58 | // XML configuration settings parsing |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 59 | virtual bool serializeXmlSettings(CXmlElement& xmlConfigurationSettingsElementContent, CConfigurationAccessContext& configurationAccessContext) const; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 60 | |
| 61 | // from CElement |
| 62 | virtual string getKind() const; |
| 63 | protected: |
| 64 | // Parameter access |
Patrick Benavoli | 065264a | 2011-11-20 15:46:41 +0100 | [diff] [blame] | 65 | virtual bool accessValue(CPathNavigator& pathNavigator, string& strValue, bool bSet, CParameterAccessContext& parameterAccessContext) const; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 66 | virtual void logValue(string& strValue, CErrorContext& errorContext) const; |
Patrick Benavoli | 6ccab9d | 2011-11-10 23:21:01 +0100 | [diff] [blame] | 67 | // Used for simulation and virtual subsystems |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 68 | 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 Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 74 | void addSubsystemObjectFactory(CSubsystemObjectCreator* pSubsystemObjectCreator); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 75 | private: |
JhinX Lee | 4ebc098 | 2012-07-12 17:50:07 +0200 | [diff] [blame] | 76 | CSubsystem(const CSubsystem&); |
| 77 | CSubsystem& operator=(const CSubsystem&); |
| 78 | |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 79 | // Belonging subsystem |
| 80 | virtual const CSubsystem* getBelongingSubsystem() const; |
| 81 | |
| 82 | // Mapping execution |
| 83 | bool mapSubsystemElements(string& strError); |
| 84 | |
Kevin Rocard | 3414f99 | 2013-04-02 19:49:40 +0200 | [diff] [blame] | 85 | /** |
| 86 | * Generic subsystem mapping error handling |
| 87 | * |
| 88 | * Format an human readable error string from a key and a message in case of mapping error |
| 89 | * |
| 90 | * @param[out] strError The formated error string |
| 91 | * @param[in] strKey The key on which the error refers |
| 92 | * @param[in] strMessage The error message |
| 93 | * @param[in] pInstanceConfigurableElement The element on wich the error refers |
| 94 | */ |
| 95 | void getMappingError(string& strError, const string& strKey, const string& strMessage, |
| 96 | const CInstanceConfigurableElement* pInstanceConfigurableElement); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 97 | |
Kevin Rocard | 084cafb | 2013-01-28 17:02:08 +0100 | [diff] [blame] | 98 | /** |
| 99 | * Handle a configurable element mapping. |
| 100 | * |
| 101 | * Add context mappings to the context and instantiate a subsystem object if needed. |
| 102 | * |
| 103 | * @param[in:out] pInstanceConfigurableElement The configurable element |
| 104 | * @param[out] bKeepDiving Keep diving for mapping keys |
| 105 | Is set to true if a subsystem object (tree leave) has been instantiated. |
| 106 | Undetermined on error |
| 107 | * @param[out] strError String filled with an human readable error on error, |
| 108 | left unmodified otherwise |
| 109 | * |
| 110 | * @return true on success, false on failure |
| 111 | */ |
Patrick Benavoli | d3a86bf | 2011-11-07 19:33:30 +0100 | [diff] [blame] | 112 | virtual bool mapBegin(CInstanceConfigurableElement* pInstanceConfigurableElement, bool& bKeepDiving, string& strError); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 113 | virtual void mapEnd(); |
| 114 | |
| 115 | // Mapping generic context handling |
| 116 | bool handleMappingContext(const CInstanceConfigurableElement* pInstanceConfigurableElement, CMappingContext& context, string& strError); |
Kevin Rocard | 084cafb | 2013-01-28 17:02:08 +0100 | [diff] [blame] | 117 | |
| 118 | /** |
| 119 | * Looks if a subsystem object needs to be instantiated for the given configurable |
| 120 | * element, then instantiate it if needed. |
| 121 | * |
| 122 | * @param[in:out] pInstanceConfigurableElement The configurable element to check |
| 123 | * for instanciation |
| 124 | * @param[in] context The mapping values container |
| 125 | * @param[out] bHasCreatedSubsystemObject If a subsystem object has been instantiated. |
| 126 | Undetermined on error |
| 127 | * @param[out] strError String filled with an human readable error on error, |
| 128 | left unmodified otherwise |
| 129 | * |
| 130 | * @return true on success, false on failure |
| 131 | */ |
| 132 | bool handleSubsystemObjectCreation(CInstanceConfigurableElement* pInstanceConfigurableElement, |
| 133 | CMappingContext& context, bool& bHasCreatedSubsystemObject, string& strError); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 134 | |
| 135 | // Subsystem context mapping keys |
| 136 | vector<string> _contextMappingKeyArray; |
| 137 | |
| 138 | // Subsystem object creator map |
| 139 | vector<CSubsystemObjectCreator*> _subsystemObjectCreatorArray; |
| 140 | |
| 141 | // Subsystem sync objects (house keeping) |
| 142 | list<CSubsystemObject*> _subsystemObjectList; |
| 143 | |
| 144 | // Mapping Context stack |
| 145 | stack<CMappingContext> _contextStack; |
| 146 | |
| 147 | // Subelements |
| 148 | CComponentLibrary* _pComponentLibrary; |
| 149 | CInstanceDefinition* _pInstanceDefinition; |
| 150 | |
| 151 | // Endianness |
| 152 | bool _bBigEndian; |
| 153 | }; |