MiniEngine/include/SDLWrapper/SharedLibrary.h

31 lines
795 B
C++
Raw Normal View History

2017-06-18 20:37:45 +08:00
#pragma once
#include "include.h"
#include <string>
#include <memory>
2017-07-02 08:43:25 +08:00
#include <functional>
2018-03-04 15:10:49 +08:00
namespace MiniEngine {
2017-06-18 20:37:45 +08:00
class SharedLibrary
{
public:
SharedLibrary();
SharedLibrary(const std::string& Filename);
~SharedLibrary()=default;
int load(const std::string& Filename);
int unload();
template<typename ReturnType,typename... Arguments>
std::function<ReturnType(Arguments...)> get(const std::string& FunctionName)
{
return std::function<ReturnType(Arguments...)>(reinterpret_cast<ReturnType(*)(Arguments...)>(get(FunctionName)));
}
void* get(const std::string& FunctionName) const;
void release();
private:
void* _get() const;
void _set(void*);
void _clear();
std::shared_ptr<void> _obj;
};
2018-03-04 15:10:49 +08:00
} /// End of namespace MiniEngine