add a factory for the different connection types

This commit is contained in:
canpadawan
2016-06-15 18:25:58 +02:00
parent 6e623015dd
commit 6d20a0665d
2 changed files with 18 additions and 3 deletions
+14 -1
View File
@@ -1,6 +1,19 @@
#include <QString>
#include "canconfactory.h"
#include "socketcan.h"
#include "gvretserial.h"
CanConFactory::CanConFactory()
using namespace CANCon;
CANConnection* CanConFactory::create(type pType, QString pPortName)
{
switch(pType) {
case SOCKETCAN:
return new SocketCanConnection(pPortName);
case GVRET_SERIAL:
return new GVRetSerial(pPortName);
default: {}
}
return NULL;
}
+4 -2
View File
@@ -1,11 +1,13 @@
#ifndef CANCONFACTORY_H
#define CANCONFACTORY_H
#include "canconconst.h"
#include "canconnection.h"
class CanConFactory
{
public:
CanConFactory();
static CANConnection* create(CANCon::type, QString pPortName);
};
#endif // CANCONFACTORY_H
#endif // CANCONFACTORY_H