1b76c9d6de717a9a1cfd94e7a8eca7ee4a2035cd7David Wagner/*
2b76c9d6de717a9a1cfd94e7a8eca7ee4a2035cd7David Wagner * Copyright (c) 2011-2014, Intel Corporation
3b76c9d6de717a9a1cfd94e7a8eca7ee4a2035cd7David Wagner * All rights reserved.
4b76c9d6de717a9a1cfd94e7a8eca7ee4a2035cd7David Wagner *
5b76c9d6de717a9a1cfd94e7a8eca7ee4a2035cd7David Wagner * Redistribution and use in source and binary forms, with or without modification,
6b76c9d6de717a9a1cfd94e7a8eca7ee4a2035cd7David Wagner * are permitted provided that the following conditions are met:
7b76c9d6de717a9a1cfd94e7a8eca7ee4a2035cd7David Wagner *
8b76c9d6de717a9a1cfd94e7a8eca7ee4a2035cd7David Wagner * 1. Redistributions of source code must retain the above copyright notice, this
9b76c9d6de717a9a1cfd94e7a8eca7ee4a2035cd7David Wagner * list of conditions and the following disclaimer.
10b76c9d6de717a9a1cfd94e7a8eca7ee4a2035cd7David Wagner *
11b76c9d6de717a9a1cfd94e7a8eca7ee4a2035cd7David Wagner * 2. Redistributions in binary form must reproduce the above copyright notice,
12b76c9d6de717a9a1cfd94e7a8eca7ee4a2035cd7David Wagner * this list of conditions and the following disclaimer in the documentation and/or
13b76c9d6de717a9a1cfd94e7a8eca7ee4a2035cd7David Wagner * other materials provided with the distribution.
14b76c9d6de717a9a1cfd94e7a8eca7ee4a2035cd7David Wagner *
15b76c9d6de717a9a1cfd94e7a8eca7ee4a2035cd7David Wagner * 3. Neither the name of the copyright holder nor the names of its contributors
16b76c9d6de717a9a1cfd94e7a8eca7ee4a2035cd7David Wagner * may be used to endorse or promote products derived from this software without
17b76c9d6de717a9a1cfd94e7a8eca7ee4a2035cd7David Wagner * specific prior written permission.
18b76c9d6de717a9a1cfd94e7a8eca7ee4a2035cd7David Wagner *
19b76c9d6de717a9a1cfd94e7a8eca7ee4a2035cd7David Wagner * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20b76c9d6de717a9a1cfd94e7a8eca7ee4a2035cd7David Wagner * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21b76c9d6de717a9a1cfd94e7a8eca7ee4a2035cd7David Wagner * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22b76c9d6de717a9a1cfd94e7a8eca7ee4a2035cd7David Wagner * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
23b76c9d6de717a9a1cfd94e7a8eca7ee4a2035cd7David Wagner * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24b76c9d6de717a9a1cfd94e7a8eca7ee4a2035cd7David Wagner * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25b76c9d6de717a9a1cfd94e7a8eca7ee4a2035cd7David Wagner * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26b76c9d6de717a9a1cfd94e7a8eca7ee4a2035cd7David Wagner * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27b76c9d6de717a9a1cfd94e7a8eca7ee4a2035cd7David Wagner * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28b76c9d6de717a9a1cfd94e7a8eca7ee4a2035cd7David Wagner * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2968a912857707864bbaaff9808717813105072a6ePatrick Benavoli */
3068a912857707864bbaaff9808717813105072a6ePatrick Benavoli#include "SelectionCriteriaDefinition.h"
3168a912857707864bbaaff9808717813105072a6ePatrick Benavoli#include "SelectionCriterion.h"
3268a912857707864bbaaff9808717813105072a6ePatrick Benavoli
33d9526499d6ab53b7d13d1434f748f6f2161c2e0aSebastien Gonzalvestd::string CSelectionCriteriaDefinition::getKind() const
3468a912857707864bbaaff9808717813105072a6ePatrick Benavoli{
3568a912857707864bbaaff9808717813105072a6ePatrick Benavoli    return "SelectionCriteriaDefinition";
3668a912857707864bbaaff9808717813105072a6ePatrick Benavoli}
3768a912857707864bbaaff9808717813105072a6ePatrick Benavoli
3868a912857707864bbaaff9808717813105072a6ePatrick Benavoli// Selection Criterion creation
399368eea42a1afb01dd44110582f997115b50e742François GaffieCSelectionCriterion *CSelectionCriteriaDefinition::createSelectionCriterion(
409368eea42a1afb01dd44110582f997115b50e742François Gaffie    const std::string &strName, const CSelectionCriterionType *pType, core::log::Logger &logger)
4168a912857707864bbaaff9808717813105072a6ePatrick Benavoli{
429368eea42a1afb01dd44110582f997115b50e742François Gaffie    CSelectionCriterion *pSelectionCriterion = new CSelectionCriterion(strName, pType, logger);
4368a912857707864bbaaff9808717813105072a6ePatrick Benavoli
4468a912857707864bbaaff9808717813105072a6ePatrick Benavoli    addChild(pSelectionCriterion);
4568a912857707864bbaaff9808717813105072a6ePatrick Benavoli
4668a912857707864bbaaff9808717813105072a6ePatrick Benavoli    return pSelectionCriterion;
4768a912857707864bbaaff9808717813105072a6ePatrick Benavoli}
4868a912857707864bbaaff9808717813105072a6ePatrick Benavoli
4968a912857707864bbaaff9808717813105072a6ePatrick Benavoli// Selection Criterion access
509368eea42a1afb01dd44110582f997115b50e742François Gaffieconst CSelectionCriterion *CSelectionCriteriaDefinition::getSelectionCriterion(
519368eea42a1afb01dd44110582f997115b50e742François Gaffie    const std::string &strName) const
5268a912857707864bbaaff9808717813105072a6ePatrick Benavoli{
539368eea42a1afb01dd44110582f997115b50e742François Gaffie    return static_cast<const CSelectionCriterion *>(findChild(strName));
5468a912857707864bbaaff9808717813105072a6ePatrick Benavoli}
5568a912857707864bbaaff9808717813105072a6ePatrick Benavoli
569368eea42a1afb01dd44110582f997115b50e742François GaffieCSelectionCriterion *CSelectionCriteriaDefinition::getSelectionCriterion(const std::string &strName)
5768a912857707864bbaaff9808717813105072a6ePatrick Benavoli{
589368eea42a1afb01dd44110582f997115b50e742François Gaffie    return static_cast<CSelectionCriterion *>(findChild(strName));
5968a912857707864bbaaff9808717813105072a6ePatrick Benavoli}
606ba361d96bc2581667b3400f87ff89fae6449e1fPatrick Benavoli
616ba361d96bc2581667b3400f87ff89fae6449e1fPatrick Benavoli// List available criteria
629368eea42a1afb01dd44110582f997115b50e742François Gaffievoid CSelectionCriteriaDefinition::listSelectionCriteria(std::list<std::string> &lstrResult,
639368eea42a1afb01dd44110582f997115b50e742François Gaffie                                                         bool bWithTypeInfo,
649368eea42a1afb01dd44110582f997115b50e742François Gaffie                                                         bool bHumanReadable) const
656ba361d96bc2581667b3400f87ff89fae6449e1fPatrick Benavoli{
666ba361d96bc2581667b3400f87ff89fae6449e1fPatrick Benavoli    // Propagate
67911844b16c6b627f421bc3368de427de3ca9f60cPatrick Benavoli    size_t uiNbChildren = getNbChildren();
68911844b16c6b627f421bc3368de427de3ca9f60cPatrick Benavoli    size_t uiChild;
696ba361d96bc2581667b3400f87ff89fae6449e1fPatrick Benavoli
706ba361d96bc2581667b3400f87ff89fae6449e1fPatrick Benavoli    for (uiChild = 0; uiChild < uiNbChildren; uiChild++) {
716ba361d96bc2581667b3400f87ff89fae6449e1fPatrick Benavoli
729368eea42a1afb01dd44110582f997115b50e742François Gaffie        const CSelectionCriterion *pSelectionCriterion =
739368eea42a1afb01dd44110582f997115b50e742François Gaffie            static_cast<const CSelectionCriterion *>(getChild(uiChild));
746ba361d96bc2581667b3400f87ff89fae6449e1fPatrick Benavoli
759368eea42a1afb01dd44110582f997115b50e742François Gaffie        lstrResult.push_back(
769368eea42a1afb01dd44110582f997115b50e742François Gaffie            pSelectionCriterion->getFormattedDescription(bWithTypeInfo, bHumanReadable));
776ba361d96bc2581667b3400f87ff89fae6449e1fPatrick Benavoli    }
786ba361d96bc2581667b3400f87ff89fae6449e1fPatrick Benavoli}
796ba361d96bc2581667b3400f87ff89fae6449e1fPatrick Benavoli
80daaa63ce33fa4795403f9339bc872694c9ab6113Frédéric Boisnard// Reset the modified status of the children
81daaa63ce33fa4795403f9339bc872694c9ab6113Frédéric Boisnardvoid CSelectionCriteriaDefinition::resetModifiedStatus()
82daaa63ce33fa4795403f9339bc872694c9ab6113Frédéric Boisnard{
83daaa63ce33fa4795403f9339bc872694c9ab6113Frédéric Boisnard    // Propagate
84911844b16c6b627f421bc3368de427de3ca9f60cPatrick Benavoli    size_t uiNbChildren = getNbChildren();
85911844b16c6b627f421bc3368de427de3ca9f60cPatrick Benavoli    size_t uiChild;
869368eea42a1afb01dd44110582f997115b50e742François Gaffie    CSelectionCriterion *pSelectionCriterion;
87daaa63ce33fa4795403f9339bc872694c9ab6113Frédéric Boisnard
88daaa63ce33fa4795403f9339bc872694c9ab6113Frédéric Boisnard    for (uiChild = 0; uiChild < uiNbChildren; uiChild++) {
89daaa63ce33fa4795403f9339bc872694c9ab6113Frédéric Boisnard
909368eea42a1afb01dd44110582f997115b50e742François Gaffie        pSelectionCriterion = static_cast<CSelectionCriterion *>(getChild(uiChild));
91daaa63ce33fa4795403f9339bc872694c9ab6113Frédéric Boisnard
92daaa63ce33fa4795403f9339bc872694c9ab6113Frédéric Boisnard        pSelectionCriterion->resetModifiedStatus();
93daaa63ce33fa4795403f9339bc872694c9ab6113Frédéric Boisnard    }
94daaa63ce33fa4795403f9339bc872694c9ab6113Frédéric Boisnard}
95