Qt Virtual Chart Table (QVCT)
CDeviceDriver.hpp
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 #ifndef QVCT_CDEVICEDRIVER_HPP
20 #define QVCT_CDEVICEDRIVER_HPP
21 
22 // QT
23 #include <QMap>
24 #include <QString>
25 
26 // QVCT
27 class CDevice;
28 class CDeviceDriverNames; // see below
29 class CDeviceDriverCodes; // see below
30 
31 
33 
39 {
40 
41  //------------------------------------------------------------------------------
42  // CONSTANTS / STATIC
43  //------------------------------------------------------------------------------
44 
45 public:
47  enum EDriver {
51  // SAMPLE, ///< SAMPLE_DRIVER
52  UNDEFINED
53  };
54 
55 private:
60 
61 public:
63  static const QMap<EDriver,QString> &names();
65  static QString toName( EDriver _eDriver );
67  static EDriver fromName( const QString& _rqsName );
69  static const QMap<EDriver,QString> &codes();
71  static QString toCode( EDriver _eDriver );
73  static EDriver fromCode( const QString& _rqsCode );
75  static CDevice* createDevice( const QString& _rqsDeviceName, EDriver _eDriver );
76 
77 };
78 
81 {
82  friend class CDeviceDriver;
83 
84  //------------------------------------------------------------------------------
85  // CONSTRUCTORS / DESTRUCTOR
86  //------------------------------------------------------------------------------
87 
88 private:
90  {
91  qMapNames.insert( CDeviceDriver::GPSD_GPS, "GPSD (GPS)" );
92  qMapNames.insert( CDeviceDriver::GPSD_AIS, "GPSD (AIS)" );
93  qMapNames.insert( CDeviceDriver::TCP_SBS1, "SBS-1" );
94  // qMapNames.insert( CDeviceDriver::SAMPLE, "Sample Driver" ); // SAMPLE_DRIVER
95  };
96  QMap<CDeviceDriver::EDriver,QString> qMapNames;
97 };
98 
101 {
102  friend class CDeviceDriver;
103 
104  //------------------------------------------------------------------------------
105  // CONSTRUCTORS / DESTRUCTOR
106  //------------------------------------------------------------------------------
107 
108 private:
110  {
111  qMapCodes.insert( CDeviceDriver::GPSD_GPS, "gpsd_gps" );
112  qMapCodes.insert( CDeviceDriver::GPSD_AIS, "gpsd_ais" );
113  qMapCodes.insert( CDeviceDriver::TCP_SBS1, "tcp_sbs1" );
114  // qMapCodes.insert( CDeviceDriver::SAMPLE, "sample" ); // SAMPLE_DRIVER
115  };
116  QMap<CDeviceDriver::EDriver,QString> qMapCodes;
117 };
118 
119 #endif // QVCT_CDEVICEDRIVER_HPP
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
Device driver inventory and instantiation class.
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.
Generic navigation device (GPS, speedometer, compass, etc.)
Definition: CDevice.hpp:43