2008-10-16 22:20:31 +00:00
|
|
|
// This code is in the public domain -- castano@gmail.com
|
|
|
|
|
|
|
|
#ifndef NV_CORE_LIBRARY_H
|
|
|
|
#define NV_CORE_LIBRARY_H
|
|
|
|
|
2010-03-16 22:35:20 +00:00
|
|
|
#include "nvcore.h"
|
2008-10-16 22:20:31 +00:00
|
|
|
|
|
|
|
#if NV_OS_WIN32
|
|
|
|
#define LIBRARY_NAME(name) #name ".dll"
|
|
|
|
#elif NV_OS_DARWIN
|
|
|
|
#define NV_LIBRARY_NAME(name) "lib" #name ".dylib"
|
|
|
|
#else
|
|
|
|
#define NV_LIBRARY_NAME(name) "lib" #name ".so"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
NVCORE_API void * nvLoadLibrary(const char * name);
|
|
|
|
NVCORE_API void nvUnloadLibrary(void * lib);
|
|
|
|
NVCORE_API void * nvBindSymbol(void * lib, const char * symbol);
|
|
|
|
|
|
|
|
class NVCORE_CLASS Library
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Library(const char * name)
|
|
|
|
{
|
|
|
|
handle = nvLoadLibrary(name);
|
|
|
|
}
|
|
|
|
~Library()
|
|
|
|
{
|
|
|
|
if (isValid())
|
|
|
|
{
|
|
|
|
nvUnloadLibrary(handle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isValid() const
|
|
|
|
{
|
|
|
|
return handle != NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void * bindSymbol(const char * symbol)
|
|
|
|
{
|
|
|
|
return nvBindSymbol(handle, symbol);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
void * handle;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // NV_CORE_LIBRARY_H
|