16 : m_libName(libName), m_libsLoader(libsLoader)
30 <<
"Start" << m_libName <<
"symbols resolving:" << m_symbols.size() <<
"symbols";
32 Q_ASSERT(m_symbols.size() == m_symbols.capacity());
34 auto cleanup =
qScopeGuard([
this]() { m_symbols = {}; });
36 auto libs = m_libsLoader();
38 qCWarning(qLcLibSymbolsRelolver) <<
"Couldn't load" << m_libName <<
"library";
42 std::vector<QFunctionPointer> functions(m_symbols.size());
44 auto resolveElement = [&libs](
const SymbolElement &element) {
45 return resolve(libs, element.name);
48 std::transform(m_symbols.begin(), m_symbols.end(), functions.begin(), resolveElement);
50 if (std::find(functions.begin(), functions.end(),
nullptr) != functions.end()) {
52 qCWarning(qLcLibSymbolsRelolver) <<
"Couldn't resolve" << m_libName <<
"symbols";
56 for (
size_t i = 0;
i < functions.size(); ++
i)
57 m_symbols[
i].setter(functions[
i]);
59 qCDebug(qLcLibSymbolsRelolver) << m_libName <<
"symbols resolved";
66 Q_ASSERT(m_symbols.size() < m_symbols.capacity());
68 m_symbols.push_back({
name, setter });
72 if (m_symbols.size() == m_symbols.capacity() && !m_state.
testAndSetRelease(Initial, Ready)
79 for (
auto &lib : libs)
85 auto load = [](
auto &lib) {
return lib->load(); };
86 if (std::all_of(libs.begin(), libs.end(),
load))
95 for (
auto &lib : libs)
99 qWarning() <<
"Cannot resolve symbol" << symbolName;
LibSymbolsResolver(const char *libName, size_t symbolsCount, LibsLoader libsLoader)
void(*)(QFunctionPointer) FunctionSetter
static void unload(const Libs &libs)
static bool tryLoad(const Libs &libs)
void registerSymbol(const char *name, FunctionSetter setter)
bool testAndSetRelaxed(T expectedValue, T newValue) noexcept
bool testAndSetAcquire(T expectedValue, T newValue) noexcept
bool testAndSetRelease(T expectedValue, T newValue) noexcept
Combined button and popup list for selecting options.
std::vector< std::unique_ptr< QLibrary > > Libs
constexpr size_t symbolsCount
#define Q_LOGGING_CATEGORY(name,...)
#define qCWarning(category,...)
#define qCDebug(category,...)
GLsizei const void * pointer
QScopeGuard< typename std::decay< F >::type > qScopeGuard(F &&f)
[qScopeGuard]
if(qFloatDistance(a, b)<(1<< 7))
[0]