]> git.tdb.fi Git - r2c2.git/blob - source/libmarklin/driver.cpp
3bec54ea79128e65cd571eac24b68d6cf90ff70e
[r2c2.git] / source / libmarklin / driver.cpp
1 /* $Id$
2
3 This file is part of the MSP Märklin suite
4 Copyright © 2010  Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
6 */
7
8 #include <msp/core/except.h>
9 #include "driver.h"
10 #include "dummy.h"
11 #include "intellibox.h"
12
13 using namespace std;
14
15 namespace Marklin {
16
17 Driver *Driver::create(const string &str)
18 {
19         string::size_type colon = str.find(':');
20         string type = str.substr(0, colon);
21         string params;
22
23         if(colon!=string::npos)
24                 params = str.substr(colon+1);
25
26         if(type=="ib" || type=="intellibox")
27                 return new Intellibox(params);
28         else if(type=="dummy")
29                 return new Dummy;
30
31         throw Msp::InvalidParameterValue("Unknown driver");
32 }
33
34 } // namespace Marklin