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 interface for library containing functions.
22 *//*--------------------------------------------------------------------*/
24 #include "tcuFunctionLibrary.hpp"
31 FunctionLibrary::FunctionLibrary (void)
35 FunctionLibrary::~FunctionLibrary (void)
39 // StaticFunctionLibrary
41 StaticFunctionLibrary::StaticFunctionLibrary (const Entry* entries, int numEntries)
43 for (int entryNdx = 0; entryNdx < numEntries; entryNdx++)
44 m_functions.insert(std::make_pair(std::string(entries[entryNdx].name), entries[entryNdx].ptr));
47 StaticFunctionLibrary::~StaticFunctionLibrary (void)
51 deFunctionPtr StaticFunctionLibrary::getFunction (const char* funcName) const
53 std::map<std::string, deFunctionPtr>::const_iterator iter = m_functions.find(funcName);
55 if (iter == m_functions.end())
61 // DynamicFunctionLibrary
63 DynamicFunctionLibrary::DynamicFunctionLibrary (const char* fileName)
64 : m_dynamicLibrary(fileName)
68 DynamicFunctionLibrary::~DynamicFunctionLibrary (void)
72 deFunctionPtr DynamicFunctionLibrary::getFunction (const char* funcName) const
74 return m_dynamicLibrary.getFunction(funcName);
77 // CompositeFunctionLibrary
79 CompositeFunctionLibrary::CompositeFunctionLibrary (const FunctionLibrary* libraries, int numLibraries)
80 : m_libraries (libraries)
81 , m_numLibraries (numLibraries)
85 CompositeFunctionLibrary::~CompositeFunctionLibrary (void)
89 deFunctionPtr CompositeFunctionLibrary::getFunction (const char* name) const
91 for (int ndx = 0; ndx < m_numLibraries; ndx++)
93 const deFunctionPtr ptr = m_libraries[ndx].getFunction(name);