1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program Tester Core
3 * ----------------------------------------
5 * Copyright 2014 The Android Open Source Project
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
21 * \brief Generic registry class for factories
22 *//*--------------------------------------------------------------------*/
24 #include "tcuFactoryRegistry.hpp"
31 AbstractFactory::AbstractFactory (void)
35 AbstractFactory::~AbstractFactory (void)
39 // GenericFactoryRegistry
41 GenericFactoryRegistry::GenericFactoryRegistry (void)
45 GenericFactoryRegistry::~GenericFactoryRegistry (void)
47 for (std::vector<AbstractFactory*>::const_iterator i = m_factories.begin(); i != m_factories.end(); ++i)
51 AbstractFactory* GenericFactoryRegistry::getFactoryByIndex (size_t index)
53 DE_ASSERT(index < m_factories.size());
54 return m_factories[index];
57 const AbstractFactory* GenericFactoryRegistry::getFactoryByIndex (size_t index) const
59 DE_ASSERT(index < m_factories.size());
60 return m_factories[index];
63 AbstractFactory* GenericFactoryRegistry::getFactoryByName (const std::string& name)
65 for (size_t index = 0; index < m_factories.size(); index++)
67 if (name == m_factories[index]->getName())
68 return m_factories[index];
74 const AbstractFactory* GenericFactoryRegistry::getFactoryByName (const std::string& name) const
76 for (size_t index = 0; index < m_factories.size(); index++)
78 if (name == m_factories[index]->getName())
79 return m_factories[index];
85 void GenericFactoryRegistry::registerFactory (AbstractFactory* factory)
87 DE_ASSERT(!getFactoryByName(factory->getName()));
88 m_factories.push_back(factory);
93 FactoryBase::FactoryBase (const std::string& name, const std::string& description)
95 , m_description (description)
99 FactoryBase::~FactoryBase (void)
103 const char* FactoryBase::getName (void) const
105 return m_name.c_str();
108 const char* FactoryBase::getDescription (void) const
110 return m_description.c_str();