]> git.tdb.fi Git - r2c2.git/blob - source/libr2c2/driver.cpp
04df5f4e82465f9c8d57ab28b0e24ec222e122bb
[r2c2.git] / source / libr2c2 / driver.cpp
1 #include "arducontrol.h"
2 #include "centralstation.h"
3 #include "driver.h"
4 #include "dummy.h"
5 #include "intellibox.h"
6
7 using namespace std;
8
9 namespace R2C2 {
10
11 Driver *Driver::create(const string &str)
12 {
13         string::size_type colon = str.find(':');
14         string type = str.substr(0, colon);
15         string params;
16
17         if(colon!=string::npos)
18                 params = str.substr(colon+1);
19
20         if(type=="ib" || type=="intellibox")
21                 return new Intellibox(params);
22         else if(type=="cs" || type=="centralstation")
23                 return new CentralStation(params);
24         else if(type=="ac" || type=="arducontrol")
25                 return new ArduControl(params);
26         else if(type=="dummy")
27                 return new Dummy(params);
28
29         throw invalid_argument("Driver::create");
30 }
31
32 } // namespace R2C2