27 #ifndef INCLUDED_PluginRegistration_h_GUID_4F5D6422_2977_40A9_8BA0_F86FD6245CE9
28 #define INCLUDED_PluginRegistration_h_GUID_4F5D6422_2977_40A9_8BA0_F86FD6245CE9
37 #include <boost/utility/enable_if.hpp>
38 #include <boost/type_traits/is_pointer.hpp>
39 #include <boost/type_traits/remove_pointer.hpp>
40 #include <boost/static_assert.hpp>
74 ctx, &::osvr::util::generic_deleter<T>, static_cast<void *>(obj));
76 throw std::runtime_error(
"registerObjectForDeletion failed!");
81 #ifndef OSVR_DOXYGEN_EXTERNAL
87 inline OSVR_ReturnCode registerHardwareDetectCallbackImpl(
89 typename boost::enable_if<boost::is_pointer<T> >::type * = NULL) {
90 typedef typename boost::remove_pointer<T>::type FunctorType;
95 static_cast<void *>(functor));
100 template <
typename T>
101 inline OSVR_ReturnCode registerHardwareDetectCallbackImpl(
103 typename boost::disable_if<boost::is_pointer<T> >::type * = NULL) {
104 #ifdef OSVR_HAVE_BOOST_IS_COPY_CONSTRUCTIBLE
105 BOOST_STATIC_ASSERT_MSG(boost::is_copy_constructible<T>::value,
106 "Hardware detect callback functors must be "
107 "either passed as a pointer or be "
108 "copy-constructible");
110 T *functorCopy =
new T(functor);
111 return registerHardwareDetectCallbackImpl(ctx, functorCopy);
116 template <
typename T>
117 inline OSVR_ReturnCode registerDriverInstantiationCallbackImpl(
119 typename boost::enable_if<boost::is_pointer<T> >::type * = NULL) {
120 typedef typename boost::remove_pointer<T>::type FunctorType;
125 FunctorType, util::this_last_t>::call,
126 static_cast<void *>(functor));
130 template <
typename T>
131 inline OSVR_ReturnCode registerDriverInstantiationCallbackImpl(
133 typename boost::disable_if<boost::is_pointer<T> >::type * = NULL) {
134 #ifdef OSVR_HAVE_BOOST_IS_COPY_CONSTRUCTIBLE
135 BOOST_STATIC_ASSERT_MSG(
136 boost::is_copy_constructible<T>::value,
137 "Driver instantiation callback functors must be "
138 "either passed as a pointer or be "
139 "copy-constructible");
141 T *functorCopy =
new T(functor);
142 return registerDriverInstantiationCallbackImpl(ctx, driverName,
162 template <
typename T>
165 OSVR_ReturnCode ret =
166 detail::registerHardwareDetectCallbackImpl(ctx, functor);
168 throw std::runtime_error(
"registerHardwareDetectCallback failed!");
189 template <
typename T>
191 const char driverName[],
193 OSVR_ReturnCode ret = detail::registerDriverInstantiationCallbackImpl(
194 ctx, driverName, functor);
196 throw std::runtime_error(
197 "registerDriverInstantiationCallback failed!");
203 const char *message) {
210 #endif // INCLUDED_PluginRegistration_h_GUID_4F5D6422_2977_40A9_8BA0_F86FD6245CE9
Header providing a templated deleter function.
OSVR_ReturnCode osvrPluginRegisterHardwareDetectCallback(OSVR_PluginRegContext ctx, OSVR_HardwareDetectCallback detectCallback, void *userData=NULL)
Register a callback in your plugin to be notified when hardware should be detected again...
Header wrapping for when we just use it with static ass...
The main namespace for all C++ elements of the framework, internal and external.
Tag type indicating the last parameter of the function contains the "this" pointer.
void registerHardwareDetectCallback(OSVR_PluginRegContext ctx, T functor)
Registers a function object to be called when the core requests a hardware detection.
OSVR_ReturnCode osvrRegisterDriverInstantiationCallback(OSVR_PluginRegContext ctx, const char *name, OSVR_DriverInstantiationCallback cb, void *userData=NULL)
Register an instantiation callback (constructor) for a driver type. The given constructor may be call...
OSVR_ReturnCode(* OSVR_HardwareDetectCallback)(OSVR_PluginRegContext ctx, void *userData)
Function type of a Hardware Detect callback.
Header providing templated functions to automate the process of calling a C++ member function (specif...
T * registerObjectForDeletion(OSVR_PluginRegContext ctx, T *obj)
Registers an object to be destroyed with delete when the plugin is unloaded.
void registerDriverInstantiationCallback(OSVR_PluginRegContext ctx, const char driverName[], T functor)
Registers a function object to be called when the server is told to instantiate a driver by name with...
#define OSVR_RETURN_SUCCESS
The "success" value for an OSVR_ReturnCode.
void osvrPluginLog(OSVR_PluginRegContext ctx, OSVR_LogLevel severity, const char *message)
Log a message to the plugin's log channel.
OSVR_ReturnCode(* OSVR_DriverInstantiationCallback)(OSVR_PluginRegContext ctx, const char *params, void *userData)
Function type of a driver instantiation callback.
OSVR_LogLevel
Log message severity levels.
Struct containing a single static function member named "call" that serves as a converter from a func...
OSVR_ReturnCode osvrPluginRegisterDataWithDeleteCallback(OSVR_PluginRegContext ctx, OSVR_PluginDataDeleteCallback deleteCallback, void *pluginData)
Register plugin data along with an appropriate deleter callback.
OSVR_EXTERN_C_BEGIN typedef void * OSVR_PluginRegContext
A context pointer passed in to your plugin's entry point and other locations of control flow transfer...