Files
compute-runtime/shared/source/os_interface/os_library.h
Mateusz Hoppe 4df533f63a Use full path when loading SourceLevelDebugger library
Change-Id: I27f7ee2b8944b9890ab4b141c06e9c2f0a8dffb1
Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
2020-11-01 18:18:38 +01:00

44 lines
968 B
C++

/*
* Copyright (C) 2017-2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include <string>
#include <type_traits>
namespace NEO {
struct ConvertibleProcAddr {
template <typename T>
operator T *() const {
static_assert(std::is_function<T>::value, "Cannot convert to non-function and non-void* type");
return reinterpret_cast<T *>(ptr);
}
operator void *() const {
return ptr;
}
void *ptr = nullptr;
};
class OsLibrary {
protected:
OsLibrary() = default;
public:
virtual ~OsLibrary() = default;
static OsLibrary *load(const std::string &name);
static const std::string createFullSystemPath(const std::string &name);
ConvertibleProcAddr operator[](const std::string &name) {
return ConvertibleProcAddr{getProcAddress(name)};
}
virtual void *getProcAddress(const std::string &procName) = 0;
virtual bool isLoaded() = 0;
};
} // namespace NEO