Simbody
Classes | Namespaces | Defines

Plugin.h File Reference

#include "SimTKcommon/internal/common.h"
#include "SimTKcommon/internal/Array.h"
#include <string>
#include <stdexcept>

Go to the source code of this file.

Classes

class  SimTK::Pathname
 This class encapsulates the handling of file and directory pathnames in a platform-independent manner. More...
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...

Namespaces

namespace  SimTK
 

This is the top-level SimTK namespace into which all SimTK names are placed to avoid collision with other symbols.


Defines

#define SimTK_PLUGIN_XXX_MAKE_HOLDER(FuncName)
#define SimTK_PLUGIN_XXX_MAKE_BODY(FuncName)
#define SimTK_PLUGIN_XXX_MAKE_SYMTEST(Symbol)
#define SimTK_PLUGIN_DEFINE_SYMBOL(Type, SymName)
#define SimTK_PLUGIN_DEFINE_FUNCTION(RetType, FuncName)
#define SimTK_PLUGIN_DEFINE_FUNCTION1(RetType, FuncName, Arg1)
#define SimTK_PLUGIN_DEFINE_FUNCTION2(RetType, FuncName, Arg1, Arg2)

Define Documentation

#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__
#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
#define SimTK_PLUGIN_XXX_MAKE_SYMTEST (   Symbol)
Value:
bool has_##Symbol() const {                          \
        return Symbol##__Ref__.loadSym(m_handle,m_lastMessage);   \
    }
#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);              \
    }
#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)
#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)
#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)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines