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