]> git.tdb.fi Git - libs/vr.git/blobdiff - source/displaydevice.cpp
Add a factory method in DisplayDevice
[libs/vr.git] / source / displaydevice.cpp
diff --git a/source/displaydevice.cpp b/source/displaydevice.cpp
new file mode 100644 (file)
index 0000000..5e11266
--- /dev/null
@@ -0,0 +1,29 @@
+#include <msp/strings/format.h>
+#include "displaydevice.h"
+#ifdef WITH_OPENVR
+#include "openvr/openvrdevice.h"
+#endif
+#ifdef WITH_LIBOVR
+#include "ovr/oculusriftdevice.h"
+#endif
+
+using namespace std;
+
+namespace Msp {
+namespace VR {
+
+DisplayDevice *DisplayDevice::create_device(const string &type)
+{
+#ifdef WITH_OPENVR
+       if(type=="openvr")
+               return new OpenVRDevice;
+#endif
+#ifdef WITH_LIBOVR
+       if(type=="libovr")
+               return new OculusRiftDevice;
+#endif
+       throw invalid_argument(format("device type '%s' not supported", type));
+}
+
+} // namespace VR
+} // namespace Msp