Add utils-class for static utils methods

This commit is contained in:
Siegfried Siegert 2023-06-19 15:06:04 +02:00
parent c4cbf89182
commit 74753ce644
Signed by: SiegfriedSiegert
GPG Key ID: 68371E015E8F0B03
3 changed files with 45 additions and 2 deletions

View File

@ -73,11 +73,13 @@ HEADERS += \
src/ATBAPP/ATBAPPplugin.h \
src/ATBAPP/DeviceControllerInterface.h \
src/ATBAPP/ATBHealthEvent.h \
src/ATBAPP/ATBDeviceControllerPlugin.h
src/ATBAPP/ATBDeviceControllerPlugin.h \
src/ATBAPP/Utils.h
SOURCES += \
src/ATBAPP/ATBHealthEvent.cpp \
src/ATBAPP/ATBDeviceControllerPlugin.cpp
src/ATBAPP/ATBDeviceControllerPlugin.cpp \
src/ATBAPP/Utils.cpp
DISTFILES += \
generate-version.sh

18
src/ATBAPP/Utils.cpp Normal file
View File

@ -0,0 +1,18 @@
#include "Utils.h"
Utils::Utils(QObject *parent) : QObject(parent)
{
}
int Utils::compare(const void* a, const void* b)
{
int int_a = * ( (int*) a );
int int_b = * ( (int*) b );
if ( int_a == int_b ) return 0;
else if ( int_a < int_b ) return -1;
else return 1;
}

23
src/ATBAPP/Utils.h Normal file
View File

@ -0,0 +1,23 @@
#ifndef UTILS_H
#define UTILS_H
#include <QObject>
class Utils : public QObject
{
Q_OBJECT
public:
static int compare(const void* a, const void* b);
private:
explicit Utils(QObject *parent = nullptr);
signals:
};
#endif // UTILS_H