blob: dd90822aa64fe4c1c1301c991273e3dfed30ec22 [file] [log] [blame]
Frederic Boisnard6cae0ec2013-05-23 18:48:58 +02001/*
2 * INTEL CONFIDENTIAL
3 * Copyright © 2013 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 *
22 */
23#pragma once
24
25#include "SubsystemObject.h"
26
27class CFormattedSubsystemObject : public CSubsystemObject
28{
29public:
30 /**
31 * Builds a new CFormattedSubsystemObject instance, without any mapping information.
32 *
33 * @param[in] pInstanceConfigurableElement Instance of the element linked to the SubsytemObject.
34 */
35 CFormattedSubsystemObject(CInstanceConfigurableElement* pInstanceConfigurableElement);
36
37 /**
38 * Builds a new CFormattedSubsystemObject instance, using a simple mapping value without Amends.
39 *
40 * @param[in] pInstanceConfigurableElement Instance of the element linked to the SubsytemObject.
41 * @param[in] strFormattedMapping A string corresponding to the mapping of the element. The
42 * string does not contain any Amend (%) and does not need to be formatted.
43 */
44 CFormattedSubsystemObject(CInstanceConfigurableElement* pInstanceConfigurableElement,
45 const string& strFormattedMapping);
46
47 /**
48 * Builds a new CFormattedSubsystemObject instance, using a mapping value containing Amends.
49 *
50 * @param[in] pInstanceConfigurableElement Instance of the element linked to the SubsytemObject.
51 * @param[in] strMappingValue A string corresponding to the mapping of the element. The
52 * string contains Amend (%) and needs to be formatted with information from the context.
53 * @param[in] uiFirstAmendKey Index of the first Amend key
54 * @param[in] uiNbAmendKeys Number of Amends
55 * @param[in] context Contains values associated to Amend keys
56 */
57 CFormattedSubsystemObject(CInstanceConfigurableElement* pInstanceConfigurableElement,
58 const string& strMappingValue,
59 uint32_t uiFirstAmendKey,
60 uint32_t uiNbAmendKeys,
61 const CMappingContext& context);
62 virtual ~CFormattedSubsystemObject();
63
64 /**
65 * Returns the formatted mapping value associated to the element.
66 *
67 * @return A string containing the mapping
68 */
69 virtual string getFormattedMappingValue() const;
70
71private:
72
73 /**
74 * Check if the index of Amend key is valid.
75 *
76 * @param uiAmendKey Index of the Amend key
77 *
78 * @return true if the index of the Amend key is > 0 and <= 9.
79 */
80 static bool isAmendKeyValid(uint32_t uiAmendKey);
81
82 /**
83 * Generic mapping formatting
84 *
85 * Format a string from mapping data and its context, replacing amendments by their value
86 *
87 * @param[in] strMappingValue The input mapping string containing amendments
88 * @param[in] context uiFirstAmendKey The index of the first Amend key in the key list of the
89 * context
90 * @param[in] uiNbAmendKeys Number of Amend keys in the context
91 * @param[in] context The context containing Amend values
92 *
93 * @return The formatted string, corresponding to the input strMappingValue where %n have been
94 * replaced by their value
95 */
96 static string formatMappingValue(const string& strMappingValue,
97 uint32_t uiFirstAmendKey,
98 uint32_t uiNbAmendKeys,
99 const CMappingContext& context);
100
101 /**
102 * string containing the formatted mapping value
103 */
104 string _strFormattedMappingValue;
105};