LCOV - code coverage report
Current view: top level - src/app - abstractcommand.h (source / functions) Hit Total Coverage
Project: QtPokit Lines: 2 2 100.0 %
Version: Functions: 1 1 100.0 %

          Line data    Source code
       1             : // SPDX-FileCopyrightText: 2022 Paul Colby <git@colby.id.au>
       2             : // SPDX-License-Identifier: LGPL-3.0-or-later
       3             : 
       4             : #ifndef QTPOKIT_ABSTRACTCOMMAND_H
       5             : #define QTPOKIT_ABSTRACTCOMMAND_H
       6             : 
       7             : #include <QBluetoothDeviceInfo>
       8             : #include <QCommandLineParser>
       9             : #include <QLoggingCategory>
      10             : #include <QObject>
      11             : 
      12             : class PokitDiscoveryAgent;
      13             : 
      14        6822 : class AbstractCommand : public QObject
      15             : {
      16             : public:
      17             :     enum class OutputFormat {
      18             :         Csv,  ///< RFC 4180 compliant CSV text.
      19             :         Json, ///< RFC 8259 compliant JSON text.
      20             :         Text, ///< Plain unstructured text.
      21             :     };
      22             : 
      23             :     explicit AbstractCommand(QObject * const parent);
      24             : 
      25             :     virtual QStringList requiredOptions(const QCommandLineParser &parser) const;
      26             :     virtual QStringList supportedOptions(const QCommandLineParser &parser) const;
      27             : 
      28             :     static QString escapeCsvField(const QString &field);
      29             :     static quint32 parseMicroValue(const QString &value, const QString &unit,
      30             :                                    const quint32 sensibleMinimum=0);
      31             :     static quint32 parseMilliValue(const QString &value, const QString &unit,
      32             :                                    const quint32 sensibleMinimum=0);
      33             :     static quint32 parseWholeValue(const QString &value, const QString &unit);
      34             : 
      35             : public slots:
      36             :     virtual QStringList processOptions(const QCommandLineParser &parser);
      37             :     virtual bool start() = 0;
      38             : 
      39             : protected:
      40             :     QString deviceToScanFor; ///< Device (if any) that were passed to processOptions().
      41             :     PokitDiscoveryAgent * discoveryAgent; ///< Agent for Pokit device descovery.
      42             :     OutputFormat format; ///< Selected output format.
      43       23824 :     static Q_LOGGING_CATEGORY(lc, "pokit.ui.command", QtInfoMsg); ///< Logging category for UI commands.
      44             : 
      45             : protected slots:
      46             :     virtual void deviceDiscovered(const QBluetoothDeviceInfo &info) = 0;
      47             :     virtual void deviceDiscoveryFinished() = 0;
      48             : 
      49             :     friend class TestAbstractCommand;
      50             : };
      51             : 
      52             : #endif // QTPOKIT_ABSTRACTCOMMAND_H

Generated by: LCOV version 1.14