X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibmarklin%2Fdriver.cpp;fp=source%2Flibmarklin%2Fdriver.cpp;h=3bec54ea79128e65cd571eac24b68d6cf90ff70e;hb=651698847d5293cfb15b6fb23a394701388c0151;hp=0000000000000000000000000000000000000000;hpb=dcfa1e9503b7e97b61396d7458f0b2e5896779cd;p=r2c2.git diff --git a/source/libmarklin/driver.cpp b/source/libmarklin/driver.cpp new file mode 100644 index 0000000..3bec54e --- /dev/null +++ b/source/libmarklin/driver.cpp @@ -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 +#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