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 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>
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);
116 template <
typename T>
119 typename boost::enable_if<boost::is_pointer<T> >::type * = NULL) {
120 typedef typename boost::remove_pointer<T>::type FunctorType;
126 static_cast<void *>(functor));
130 template <
typename T>
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);
162 template <
typename T>
165 OSVR_ReturnCode ret =
168 throw std::runtime_error(
"registerHardwareDetectCallback failed!");
189 template <
typename T>
191 const char driverName[],
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 registerDriverInstantiationCallbackImpl(OSVR_PluginRegContext ctx, const char driverName[], T functor, typename boost::enable_if< boost::is_pointer< T > >::type *=NULL)
Traits-based overload to register an instantiation callback where we're given a pointer to a function...
Definition: PluginRegistration.h:117
Header wrapping <boost/type_traits/is_copy_constructible.hpp> for when we just use it with static ass...
OSVR_PLUGINKIT_EXPORT OSVR_ReturnCode osvrPluginRegisterDataWithDeleteCallback(OSVR_INOUT_PTR OSVR_PluginRegContext ctx, OSVR_IN OSVR_PluginDataDeleteCallback deleteCallback, OSVR_INOUT_PTR void *pluginData) OSVR_FUNC_NONNULL((1
Register plugin data along with an appropriate deleter callback.
OSVR_PLUGINKIT_EXPORT OSVR_ReturnCode osvrPluginRegisterHardwareDetectCallback(OSVR_INOUT_PTR OSVR_PluginRegContext ctx, OSVR_IN OSVR_HardwareDetectCallback detectCallback, OSVR_IN_OPT void *userData OSVR_CPP_ONLY(=NULL)) OSVR_FUNC_NONNULL((1))
Register a callback in your plugin to be notified when hardware should be detected again...
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
void registerHardwareDetectCallback(OSVR_PluginRegContext ctx, T functor)
Registers a function object to be called when the core requests a hardware detection.
Definition: PluginRegistration.h:163
OSVR_PLUGINKIT_EXPORT OSVR_ReturnCode OSVR_PLUGINKIT_EXPORT void osvrPluginLog(OSVR_INOUT_PTR OSVR_PluginRegContext ctx, OSVR_IN OSVR_LogLevel severity, OSVR_IN const char *message) OSVR_FUNC_NONNULL((1
Log a message to the plugin's log channel.
Definition: newuoa.h:1888
Header providing templated functions to automate the process of calling a C++ member function (specif...
OSVR_PLUGINKIT_EXPORT OSVR_ReturnCode osvrRegisterDriverInstantiationCallback(OSVR_INOUT_PTR OSVR_PluginRegContext ctx, OSVR_IN_STRZ const char *name, OSVR_IN_PTR OSVR_DriverInstantiationCallback cb, OSVR_IN_OPT void *userData OSVR_CPP_ONLY(=NULL)) OSVR_FUNC_NONNULL((1
Register an instantiation callback (constructor) for a driver type.
OSVR_ReturnCode(* OSVR_HardwareDetectCallback)(OSVR_PluginRegContext ctx, void *userData)
Function type of a Hardware Detect callback.
Definition: PluginCallbackTypesC.h:51
T * registerObjectForDeletion(OSVR_PluginRegContext ctx, T *obj)
Registers an object to be destroyed with delete when the plugin is unloaded.
Definition: PluginRegistration.h:72
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...
Definition: PluginRegistration.h:190
#define OSVR_RETURN_SUCCESS
The "success" value for an OSVR_ReturnCode.
Definition: ReturnCodesC.h:45
Struct containing a single static function member named "call" that serves as a converter from a func...
Definition: GenericCaller.h:241
OSVR_LogLevel
Log message severity levels.
Definition: LogLevelC.h:44
OSVR_ReturnCode(* OSVR_DriverInstantiationCallback)(OSVR_PluginRegContext ctx, const char *params, void *userData)
Function type of a driver instantiation callback.
Definition: PluginCallbackTypesC.h:55
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...
Definition: PluginRegContextC.h:47
Tag type indicating the last parameter of the function contains the "this" pointer.
Definition: GenericCaller.h:76
OSVR_ReturnCode registerHardwareDetectCallbackImpl(OSVR_PluginRegContext ctx, T functor, typename boost::enable_if< boost::is_pointer< T > >::type *=NULL)
Traits-based overload to register a hardware detect callback where we're given a pointer to a functio...
Definition: PluginRegistration.h:87