X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Fdriver.cpp;h=6fbef93e1f13be64a90afcf3fb5a0037d11fe04a;hb=d0881a98a6240758ac1aeceaa9443d718ab1ad5c;hp=ea903afd14bbee7403052975457d2966a004ef4a;hpb=1ff06c5bc46a677fa389ef86c6b26664368f1653;p=r2c2.git diff --git a/source/libr2c2/driver.cpp b/source/libr2c2/driver.cpp index ea903af..6fbef93 100644 --- a/source/libr2c2/driver.cpp +++ b/source/libr2c2/driver.cpp @@ -1,16 +1,12 @@ -/* $Id$ - -This file is part of R²C² -Copyright © 2010 Mikkosoft Productions, Mikko Rasa -Distributed under the GPL -*/ - -#include +#include +#include "arducontrol.h" +#include "centralstation.h" #include "driver.h" #include "dummy.h" #include "intellibox.h" using namespace std; +using namespace Msp; namespace R2C2 { @@ -25,10 +21,36 @@ Driver *Driver::create(const string &str) if(type=="ib" || type=="intellibox") return new Intellibox(params); + else if(type=="cs" || type=="centralstation") + return new CentralStation(params); + else if(type=="ac" || type=="arducontrol") + return new ArduControl(params); else if(type=="dummy") - return new Dummy; + return new Dummy(params); + + throw invalid_argument("Driver::create"); +} + - throw Msp::InvalidParameterValue("Unknown driver"); +Driver::Options::Options(const string &optstr) +{ + vector parts = split(optstr, ':'); + for(vector::const_iterator i=parts.begin(); i!=parts.end(); ++i) + { + string::size_type equals = i->find('='); + if(equals==0) + throw invalid_argument("Driver::Options::Options"); + + if(equals==string::npos) + set(string(), *i); + else + set(i->substr(0, equals), i->substr(equals+1)); + } +} + +void Driver::Options::set(const string &key, const string &value) +{ + opts[key] = value; } } // namespace R2C2