Qt Virtual Chart Table (QVCT)
CDeviceDriver.cpp
Go to the documentation of this file.
1 // INDENTING (emacs/vi): -*- mode:c++; tab-width:2; c-basic-offset:2; intent-tabs-mode:nil; -*- ex: set tabstop=2 expandtab:
2 
3 /*
4  * Qt Virtual Chart Table (QVCT)
5  * Copyright (C) 2012 Cedric Dufour <http://cedric.dufour.name>
6  * Author: Cedric Dufour <http://cedric.dufour.name>
7  *
8  * The Qt Virtual Chart Table (QVCT) is free software:
9  * you can redistribute it and/or modify it under the terms of the GNU General
10  * Public License as published by the Free Software Foundation, Version 3.
11  *
12  * The Qt Virtual Chart Table (QVCT) is distributed in the hope
13  * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
14  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15  *
16  * See the GNU General Public License for more details.
17  */
18 
19 // QT
20 #include <QMap>
21 #include <QString>
22 
23 // QVCT
28 // #include "devices/drivers/Sample/CDeviceSample.hpp" // SAMPLE_DRIVER
29 
30 
31 //------------------------------------------------------------------------------
32 // CONSTANTS / STATIC
33 //------------------------------------------------------------------------------
34 
37 
38 const QMap<CDeviceDriver::EDriver,QString> &CDeviceDriver::names()
39 {
41 }
42 
44 {
45  return oDeviceDriverNames.qMapNames.value( _eDriver, "?" );
46 }
47 
49 {
50  return oDeviceDriverNames.qMapNames.key( _rqString, UNDEFINED );
51 }
52 
53 const QMap<CDeviceDriver::EDriver,QString> &CDeviceDriver::codes()
54 {
56 }
57 
59 {
60  return oDeviceDriverCodes.qMapCodes.value( _eDriver, "undef" );
61 }
62 
64 {
65  return oDeviceDriverCodes.qMapCodes.key( _rqString, UNDEFINED );
66 }
67 
68 CDevice* CDeviceDriver::createDevice( const QString& _rqsDeviceName, CDeviceDriver::EDriver _eDriver )
69 {
70  switch( _eDriver )
71  {
72 
73  case GPSD_GPS:
74  return new CDeviceGpsdGps( _rqsDeviceName );
75 
76  case GPSD_AIS:
77  return new CDeviceGpsdAis( _rqsDeviceName );
78 
79  case TCP_SBS1:
80  return new CDeviceTcpSbs1( _rqsDeviceName );
81 
82  // case SAMPLE: // SAMPLE_DRIVER
83  // return new CDeviceSample( _rqsDeviceName ); // SAMPLE_DRIVER
84 
85  case UNDEFINED:
86  default:; // WHAT THE F*** !?!
87 
88  }
89  return 0;
90 }
Container class for supported machine-friendly device driver codes.
QMap< CDeviceDriver::EDriver, QString > qMapCodes
Container class for supported human-readable device driver names.
QMap< CDeviceDriver::EDriver, QString > qMapNames
static const CDeviceDriverCodes oDeviceDriverCodes
Container for supported machine-friendly device driver codes.
static EDriver fromName(const QString &_rqsName)
Returns the device driver ID corresponding to the given human-readable name.
static const QMap< EDriver, QString > & codes()
Returns the list of supported machine-friendly device driver codes.
static const QMap< EDriver, QString > & names()
Returns the list of supported human-readable device driver names.
EDriver
Driver ID.
@ GPSD_AIS
GPSD daemon (AIS mode)
@ GPSD_GPS
GPSD daemon (GPS mode)
@ UNDEFINED
Undefined driver.
@ TCP_SBS1
TCP socket, SBS-1 protocol.
static CDevice * createDevice(const QString &_rqsDeviceName, EDriver _eDriver)
Create a new device based on the specified driver.
static QString toName(EDriver _eDriver)
Returns the human-readable name corresponding to the given device driver ID.
static QString toCode(EDriver _eDriver)
Returns the machine-friendly code corresponding to the given device driver ID.
static EDriver fromCode(const QString &_rqsCode)
Returns the device driver ID corresponding to the given machine-friendly code.
static const CDeviceDriverNames oDeviceDriverNames
Container for supported human-readable device driver names.
GPSD daemon (GPS mode) navigation device.
GPSD daemon (GPS mode) navigation device.
SBS-1 protocol (TCP socket) navigation device.
Generic navigation device (GPS, speedometer, compass, etc.)
Definition: CDevice.hpp:43