blob: fafb53a0d639ea0254868e3fe6925398b2e2efb3 [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#include "SelectionCriteriaDefinition.h"
26#include "SelectionCriterion.h"
27
28CSelectionCriteriaDefinition::CSelectionCriteriaDefinition()
29{
30}
31
32string CSelectionCriteriaDefinition::getKind() const
33{
34 return "SelectionCriteriaDefinition";
35}
36
37// Selection Criterion creation
38CSelectionCriterion* CSelectionCriteriaDefinition::createSelectionCriterion(const string& strName, const CSelectionCriterionType* pSelectionCriterionType)
39{
Kevin Rocardace81f82012-12-11 16:19:17 +010040 log_info("Creating %s selection criterion \"%s\" - possible states : %s",
Kevin Rocard8d6e34b2012-12-03 14:45:29 +010041 pSelectionCriterionType->isTypeInclusive() ? "inclusive" : "exclusive",
42 strName.c_str(),
43 pSelectionCriterionType->listPossibleValues().c_str()
44 );
45
Patrick Benavoli68a91282011-08-31 11:23:23 +020046 CSelectionCriterion* pSelectionCriterion = new CSelectionCriterion(strName, pSelectionCriterionType);
47
48 addChild(pSelectionCriterion);
49
50 return pSelectionCriterion;
51}
52
53// Selection Criterion access
54const CSelectionCriterion* CSelectionCriteriaDefinition::getSelectionCriterion(const string& strName) const
55{
56 return static_cast<const CSelectionCriterion*>(findChild(strName));
57}
58
Patrick Benavolib71ccf72011-09-13 14:15:52 +020059CSelectionCriterion* CSelectionCriteriaDefinition::getSelectionCriterion(const string& strName)
Patrick Benavoli68a91282011-08-31 11:23:23 +020060{
Patrick Benavolib71ccf72011-09-13 14:15:52 +020061 return static_cast<CSelectionCriterion*>(findChild(strName));
Patrick Benavoli68a91282011-08-31 11:23:23 +020062}
Patrick Benavoli6ba361d2011-08-31 11:23:24 +020063
64// List available criteria
65void CSelectionCriteriaDefinition::listSelectionCriteria(string& strResult, bool bWithTypeInfo) const
66{
67 // Propagate
68 uint32_t uiNbChildren = getNbChildren();
69 uint32_t uiChild;
70
71 for (uiChild = 0; uiChild < uiNbChildren; uiChild++) {
72
73 const CSelectionCriterion* pSelectionCriterion = static_cast<const CSelectionCriterion*>(getChild(uiChild));
74
75 strResult += pSelectionCriterion->getFormattedDescription(bWithTypeInfo) + "\n";
76 }
77}
78
Frédéric Boisnarddaaa63c2012-08-27 15:48:15 +020079// Reset the modified status of the children
80void CSelectionCriteriaDefinition::resetModifiedStatus()
81{
82 // Propagate
83 uint32_t uiNbChildren = getNbChildren();
84 uint32_t uiChild;
85 CSelectionCriterion* pSelectionCriterion;
86
87 for (uiChild = 0; uiChild < uiNbChildren; uiChild++) {
88
89 pSelectionCriterion = static_cast<CSelectionCriterion*>(getChild(uiChild));
90
91 pSelectionCriterion->resetModifiedStatus();
92 }
93}