MCPcopy Create free account
hub / github.com/OSVR/OSVR-Core / osvrDeviceGenericInit

Function osvrDeviceGenericInit

src/osvr/PluginKit/DeviceInterfaceC.cpp:118–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

116
117template <typename FactoryFunction>
118inline static OSVR_ReturnCode
119osvrDeviceGenericInit(OSVR_DeviceInitOptions options, OSVR_DeviceToken *device,
120 FactoryFunction f) {
121
122 osvr::connection::DeviceTokenPtr dev = f(*options);
123 if (!dev) {
124 OSVR_DEV_VERBOSE("Device token factory returned a null "
125 "pointer - this shouldn't happen!");
126 return OSVR_RETURN_FAILURE;
127 }
128 // Transfer ownership of the device token object to the plugin context.
129 try {
130 *device =
131 options->getContext()->registerDataWithGenericDelete(dev.release());
132 /// @todo Is this too late to delete? Can we delete it earlier?
133 options->getContext()->registerDataWithGenericDelete(options);
134 options->notifyToken(*device);
135 } catch (std::exception &e) {
136 std::cerr << "Error in osvrDeviceGenericInit: " << e.what()
137 << std::endl;
138 return OSVR_RETURN_FAILURE;
139 } catch (...) {
140 return OSVR_RETURN_FAILURE;
141 }
142 return OSVR_RETURN_SUCCESS;
143}
144
145template <typename FactoryFunction>
146inline static OSVR_ReturnCode

Callers 4

osvrDeviceSyncInitFunction · 0.85
osvrDeviceAsyncInitFunction · 0.85

Calls 6

getContextMethod · 0.80
releaseMethod · 0.80
notifyTokenMethod · 0.80
setNameMethod · 0.80

Tested by

no test coverage detected