]> git.tdb.fi Git - r2c2.git/blobdiff - source/libmarklin/driver.cpp
Major architecture rework
[r2c2.git] / source / libmarklin / driver.cpp
diff --git a/source/libmarklin/driver.cpp b/source/libmarklin/driver.cpp
new file mode 100644 (file)
index 0000000..3bec54e
--- /dev/null
@@ -0,0 +1,34 @@
+/* $Id$
+
+This file is part of the MSP Märklin suite
+Copyright © 2010  Mikkosoft Productions, Mikko Rasa
+Distributed under the GPL
+*/
+
+#include <msp/core/except.h>
+#include "driver.h"
+#include "dummy.h"
+#include "intellibox.h"
+
+using namespace std;
+
+namespace Marklin {
+
+Driver *Driver::create(const string &str)
+{
+       string::size_type colon = str.find(':');
+       string type = str.substr(0, colon);
+       string params;
+
+       if(colon!=string::npos)
+               params = str.substr(colon+1);
+
+       if(type=="ib" || type=="intellibox")
+               return new Intellibox(params);
+       else if(type=="dummy")
+               return new Dummy;
+
+       throw Msp::InvalidParameterValue("Unknown driver");
+}
+
+} // namespace Marklin