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>
|
2017-06-18 20:37:45 +08:00
|
|
|
#include "begin_code.h"
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
#include "end_code.h"
|