1 #ifndef _TCUFUNCTIONLIBRARY_HPP
2 #define _TCUFUNCTIONLIBRARY_HPP
3 /*-------------------------------------------------------------------------
4 * drawElements Quality Program Tester Core
5 * ----------------------------------------
7 * Copyright 2014 The Android Open Source Project
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
23 * \brief Generic interface for library containing functions.
24 *//*--------------------------------------------------------------------*/
26 #include "tcuDefs.hpp"
27 #include "deDynamicLibrary.hpp"
36 // \note Returned function pointers have same lifetime as the library.
40 FunctionLibrary (void);
43 virtual ~FunctionLibrary (void);
44 virtual deFunctionPtr getFunction (const char* funcName) const = 0;
47 FunctionLibrary (const FunctionLibrary&);
48 FunctionLibrary& operator= (const FunctionLibrary&);
51 class StaticFunctionLibrary : public FunctionLibrary
60 StaticFunctionLibrary (const Entry* entries, int numEntries);
61 ~StaticFunctionLibrary (void);
63 deFunctionPtr getFunction (const char* funcName) const;
67 StaticFunctionLibrary (const StaticFunctionLibrary&);
68 StaticFunctionLibrary& operator= (const StaticFunctionLibrary&);
70 // \todo [2014-03-11 pyry] This could be implemented with const char* pointers and custom compare.
71 std::map<std::string, deFunctionPtr> m_functions;
74 class DynamicFunctionLibrary : public FunctionLibrary
77 DynamicFunctionLibrary (const char* fileName);
78 ~DynamicFunctionLibrary (void);
80 deFunctionPtr getFunction (const char* funcName) const;
83 DynamicFunctionLibrary (const DynamicFunctionLibrary&);
84 DynamicFunctionLibrary& operator= (const DynamicFunctionLibrary&);
86 de::DynamicLibrary m_dynamicLibrary;
89 class CompositeFunctionLibrary : public FunctionLibrary
92 CompositeFunctionLibrary (const FunctionLibrary* libraries, int numLibraries);
93 ~CompositeFunctionLibrary (void);
95 deFunctionPtr getFunction (const char* funcName) const;
98 const FunctionLibrary* const m_libraries;
99 const int m_numLibraries;
104 #endif // _TCUFUNCTIONLIBRARY_HPP