There were two smaller merge requests that where accepted in the last two weeks that move the device hierarchy to a more dynamic runtime oriented access. Currently when you need to find out if a device is built and fall back to other devices if it isnt, there is really no good solution except to construct a series of #ifdef checks on the cmake variables, this works reasonably well but is not very flexible and does not lend itself to reusability. For example a new series of checks has to be constructed for each new device chain that needs to be implemented.
First to make including devices easier we added a common Devices/Devices.h file, that includes all the devices that are currently being built. This removes the need to create #ifdef constructs for the device inlcudes (yes at the cost of including all the devices).
Second we added a factory class to InterfaceDevice some devices already register themselves here, this enables a dynamic query and construction of the devices without the need to resort to strict types. We can now write a generic device factory like this
std::array<std::string, 2> devices =
for (auto deviceName : devices)
device = SurgSim::Input::DeviceInterface::getFactory().create(deviceName, "Tracker");
catch (std::exception e)
device = nullptr;
SURGSIM_ASSERT(device != nullptr) << "Could not initialize any kind of tracking device.";
As next steps we will be adding all other devices to the factory, and enabling untyped access (deriving from Accessible) on them, this would make the device configuration completely dynamic and independent of the static types.
Principal Software Engineer
Simquest Solutions Inc.