Declaration of the SimTK::Plugin class providing platform-independent handling of dynamically-loaded libraries.
More...
Go to the source code of this file.
|
class | SimTK::Plugin |
| This is the base class for representing a runtime-linked dynamic library, also known as a "plugin", in a platform-independent manner. More...
|
|
|
| SimTK |
| This is the top-level SimTK namespace into which all SimTK names are placed to avoid collision with other symbols.
|
|
Declaration of the SimTK::Plugin class providing platform-independent handling of dynamically-loaded libraries.
◆ SimTK_PLUGIN_XXX_MAKE_HOLDER
#define SimTK_PLUGIN_XXX_MAKE_HOLDER |
( |
|
FuncName | ) |
|
Value:struct FuncName##__Holder__ { \
FuncName##__Holder__() : fp(0) {} \
bool loadSym(void* h, std::string& msg) const { \
if(!fp) fp =(FuncName##__Type__) \
Plugin::getSymbolAddress(h, #FuncName, msg); \
return (fp!=0); \
} \
mutable FuncName##__Type__ fp; \
} FuncName##__Ref__
◆ SimTK_PLUGIN_XXX_MAKE_BODY
#define SimTK_PLUGIN_XXX_MAKE_BODY |
( |
|
FuncName | ) |
|
Value:if (!FuncName##__Ref__.loadSym(m_handle,m_lastMessage)) \
throw std::runtime_error \
("Plugin function " #FuncName " not found: " + m_lastMessage); \
return FuncName##__Ref__.fp
◆ SimTK_PLUGIN_XXX_MAKE_SYMTEST
#define SimTK_PLUGIN_XXX_MAKE_SYMTEST |
( |
|
Symbol | ) |
|
Value:bool has_##Symbol() const { \
return Symbol##__Ref__.loadSym(m_handle,m_lastMessage); \
}
◆ SimTK_PLUGIN_DEFINE_SYMBOL
#define SimTK_PLUGIN_DEFINE_SYMBOL |
( |
|
Type, |
|
|
|
SymName |
|
) |
| |
Value:typedef Type SymName##__Type__; \
SimTK_PLUGIN_XXX_MAKE_HOLDER(SymName); \
const Type& SymName() const { \
if (!SymName##__Ref__.loadSym(m_handle,m_lastMessage)) \
throw std::runtime_error \
("Plugin symbol " #SymName " not found: " + m_lastMessage); \
return *(SymName##__Ref__.fp); \
}
◆ SimTK_PLUGIN_DEFINE_FUNCTION
#define SimTK_PLUGIN_DEFINE_FUNCTION |
( |
|
RetType, |
|
|
|
FuncName |
|
) |
| |
Value:typedef RetType (*FuncName##__Type__)(); \
SimTK_PLUGIN_XXX_MAKE_HOLDER(FuncName); \
RetType FuncName() const { \
SimTK_PLUGIN_XXX_MAKE_BODY(FuncName)(); \
} \
SimTK_PLUGIN_XXX_MAKE_SYMTEST(FuncName)
◆ SimTK_PLUGIN_DEFINE_FUNCTION1
#define SimTK_PLUGIN_DEFINE_FUNCTION1 |
( |
|
RetType, |
|
|
|
FuncName, |
|
|
|
Arg1 |
|
) |
| |
Value:typedef RetType (*FuncName##__Type__)(Arg1); \
SimTK_PLUGIN_XXX_MAKE_HOLDER(FuncName); \
RetType FuncName(Arg1 a1) const { \
SimTK_PLUGIN_XXX_MAKE_BODY(FuncName)(a1); \
} \
SimTK_PLUGIN_XXX_MAKE_SYMTEST(FuncName)
◆ SimTK_PLUGIN_DEFINE_FUNCTION2
#define SimTK_PLUGIN_DEFINE_FUNCTION2 |
( |
|
RetType, |
|
|
|
FuncName, |
|
|
|
Arg1, |
|
|
|
Arg2 |
|
) |
| |
Value:typedef RetType (*FuncName##__Type__)(Arg1,Arg2); \
SimTK_PLUGIN_XXX_MAKE_HOLDER(FuncName); \
RetType FuncName(Arg1 a1, Arg2 a2) const { \
SimTK_PLUGIN_XXX_MAKE_BODY(FuncName)(a1,a2); \
} \
SimTK_PLUGIN_XXX_MAKE_SYMTEST(FuncName)