OSVR-Core
PluginKit.h
Go to the documentation of this file.
1 
11 // Copyright 2014 Sensics, Inc.
12 //
13 // Licensed under the Apache License, Version 2.0 (the "License");
14 // you may not use this file except in compliance with the License.
15 // You may obtain a copy of the License at
16 //
17 // http://www.apache.org/licenses/LICENSE-2.0
18 //
19 // Unless required by applicable law or agreed to in writing, software
20 // distributed under the License is distributed on an "AS IS" BASIS,
21 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 // See the License for the specific language governing permissions and
23 // limitations under the License.
24 
25 #ifndef INCLUDED_PluginKit_h_GUID_1470B278_99B7_4F84_F99B_34FD9B817C89
26 #define INCLUDED_PluginKit_h_GUID_1470B278_99B7_4F84_F99B_34FD9B817C89
27 
28 // Internal Includes
31 #include <osvr/Util/LogLevelC.h>
32 
33 // Library/third-party includes
34 // - none
35 
36 // Standard includes
37 // - none
38 
39 namespace osvr {
40 
53 namespace pluginkit {
59  class PluginContext {
60  public:
62  PluginContext(OSVR_PluginRegContext ctx) : m_ctx(ctx) {}
63 
70  template <typename T> void registerHardwareDetectCallback(T functor) {
72  }
73 
82  template <typename T>
83  void registerDriverInstantiationCallback(const char driverName[],
84  T functor) {
86  m_ctx, driverName, functor);
87  }
88 
93  template <typename T> T *registerObjectForDeletion(T *obj) {
95  }
96 
101  void log(OSVR_LogLevel severity, const char* message) {
102  ::osvr::pluginkit::log(m_ctx, severity, message);
103  }
104 
105  private:
106  OSVR_PluginRegContext m_ctx;
107  };
108 
109 } // namespace pluginkit
110 } // namespace osvr
111 
112 #endif // INCLUDED_PluginKit_h_GUID_1470B278_99B7_4F84_F99B_34FD9B817C89
Header providing C++ interface wrappers around functionality in PluginRegistrationC.h.
Header.
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
void registerDriverInstantiationCallback(const char driverName[], T functor)
Register a driver instantiation callback.
Definition: PluginKit.h:83
C++ wrapper class for the opaque plugin context.
Definition: PluginKit.h:59
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
void log(OSVR_LogLevel severity, const char *message)
Log a message to the plugin-specific channel.
Definition: PluginKit.h:101
void registerHardwareDetectCallback(T functor)
Register a hardware detect callback.
Definition: PluginKit.h:70
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
OSVR_LogLevel
Log message severity levels.
Definition: LogLevelC.h:44
PluginContext(OSVR_PluginRegContext ctx)
Constructor of the context wrapper object.
Definition: PluginKit.h:62
OSVR_EXTERN_C_BEGIN typedef void * OSVR_PluginRegContext
A context pointer passed in to your plugin&#39;s entry point and other locations of control flow transfer...
Definition: PluginRegContextC.h:47
T * registerObjectForDeletion(T *obj)
Register the given object (assumed to be deletable by delete) to be deleted on plugin unload...
Definition: PluginKit.h:93
Header providing C++ interface wrappers around functionality in DeviceInterfaceC.h.