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 "ComponentLibrary.h" 3168a912857707864bbaaff9808717813105072a6ePatrick Benavoli#include "ComponentType.h" 3268a912857707864bbaaff9808717813105072a6ePatrick Benavoli#include <assert.h> 3368a912857707864bbaaff9808717813105072a6ePatrick Benavoli 3468a912857707864bbaaff9808717813105072a6ePatrick Benavolibool CComponentLibrary::childrenAreDynamic() const 3568a912857707864bbaaff9808717813105072a6ePatrick Benavoli{ 3668a912857707864bbaaff9808717813105072a6ePatrick Benavoli return true; 3768a912857707864bbaaff9808717813105072a6ePatrick Benavoli} 3868a912857707864bbaaff9808717813105072a6ePatrick Benavoli 39d9526499d6ab53b7d13d1434f748f6f2161c2e0aSebastien Gonzalvestd::string CComponentLibrary::getKind() const 4068a912857707864bbaaff9808717813105072a6ePatrick Benavoli{ 4168a912857707864bbaaff9808717813105072a6ePatrick Benavoli return "ComponentLibrary"; 4268a912857707864bbaaff9808717813105072a6ePatrick Benavoli} 4368a912857707864bbaaff9808717813105072a6ePatrick Benavoli 449368eea42a1afb01dd44110582f997115b50e742François Gaffieconst CComponentType *CComponentLibrary::getComponentType(const std::string &strName) const 4568a912857707864bbaaff9808717813105072a6ePatrick Benavoli{ 469368eea42a1afb01dd44110582f997115b50e742François Gaffie return static_cast<const CComponentType *>(findChild(strName)); 4768a912857707864bbaaff9808717813105072a6ePatrick Benavoli} 4868a912857707864bbaaff9808717813105072a6ePatrick Benavoli 499368eea42a1afb01dd44110582f997115b50e742François Gaffiebool CComponentLibrary::fromXml(const CXmlElement &xmlElement, 509368eea42a1afb01dd44110582f997115b50e742François Gaffie CXmlSerializingContext &serializingContext) 513ba083ee0b0ff7e01caeb3bc7395377071e20fe6Guillaume Denneulin{ 523ba083ee0b0ff7e01caeb3bc7395377071e20fe6Guillaume Denneulin CXmlElement childElement; 533ba083ee0b0ff7e01caeb3bc7395377071e20fe6Guillaume Denneulin 543ba083ee0b0ff7e01caeb3bc7395377071e20fe6Guillaume Denneulin CXmlElement::CChildIterator it(xmlElement); 553ba083ee0b0ff7e01caeb3bc7395377071e20fe6Guillaume Denneulin 563ba083ee0b0ff7e01caeb3bc7395377071e20fe6Guillaume Denneulin // XML populate all component libraries 573ba083ee0b0ff7e01caeb3bc7395377071e20fe6Guillaume Denneulin while (it.next(childElement)) { 583ba083ee0b0ff7e01caeb3bc7395377071e20fe6Guillaume Denneulin 593ba083ee0b0ff7e01caeb3bc7395377071e20fe6Guillaume Denneulin // Filter component library/type set elements 603ba083ee0b0ff7e01caeb3bc7395377071e20fe6Guillaume Denneulin if (childElement.getType() == "ComponentLibrary" || 613ba083ee0b0ff7e01caeb3bc7395377071e20fe6Guillaume Denneulin childElement.getType() == "ComponentTypeSet") { 623ba083ee0b0ff7e01caeb3bc7395377071e20fe6Guillaume Denneulin 633ba083ee0b0ff7e01caeb3bc7395377071e20fe6Guillaume Denneulin if (!fromXml(childElement, serializingContext)) { 643ba083ee0b0ff7e01caeb3bc7395377071e20fe6Guillaume Denneulin 653ba083ee0b0ff7e01caeb3bc7395377071e20fe6Guillaume Denneulin return false; 663ba083ee0b0ff7e01caeb3bc7395377071e20fe6Guillaume Denneulin } 673ba083ee0b0ff7e01caeb3bc7395377071e20fe6Guillaume Denneulin } else { 683ba083ee0b0ff7e01caeb3bc7395377071e20fe6Guillaume Denneulin // Regular child creation and populating 699368eea42a1afb01dd44110582f997115b50e742François Gaffie CElement *pChild = createChild(childElement, serializingContext); 703ba083ee0b0ff7e01caeb3bc7395377071e20fe6Guillaume Denneulin 713ba083ee0b0ff7e01caeb3bc7395377071e20fe6Guillaume Denneulin if (!pChild || !pChild->fromXml(childElement, serializingContext)) { 723ba083ee0b0ff7e01caeb3bc7395377071e20fe6Guillaume Denneulin 733ba083ee0b0ff7e01caeb3bc7395377071e20fe6Guillaume Denneulin return false; 743ba083ee0b0ff7e01caeb3bc7395377071e20fe6Guillaume Denneulin } 753ba083ee0b0ff7e01caeb3bc7395377071e20fe6Guillaume Denneulin } 763ba083ee0b0ff7e01caeb3bc7395377071e20fe6Guillaume Denneulin } 773ba083ee0b0ff7e01caeb3bc7395377071e20fe6Guillaume Denneulin 783ba083ee0b0ff7e01caeb3bc7395377071e20fe6Guillaume Denneulin return true; 793ba083ee0b0ff7e01caeb3bc7395377071e20fe6Guillaume Denneulin} 80