2025-12-15 20:57:09 +01:00
|
|
|
|
/***************************************************************************
|
|
|
|
|
|
|
2025-12-26 14:07:55 +01:00
|
|
|
|
BionxControl
|
2026-01-03 23:51:14 +01:00
|
|
|
|
© 2025 -2026 christoph holzheuer
|
2025-12-26 14:07:55 +01:00
|
|
|
|
christoph.holzheuer@gmail.com
|
2025-12-15 20:57:09 +01:00
|
|
|
|
|
2025-12-26 14:07:55 +01:00
|
|
|
|
Using:
|
2025-12-15 20:57:09 +01:00
|
|
|
|
|
2025-12-26 14:07:55 +01:00
|
|
|
|
mhs_can_drv.c
|
|
|
|
|
|
© 2011 - 2023 by MHS-Elektronik GmbH & Co. KG, Germany
|
|
|
|
|
|
Klaus Demlehner, klaus@mhs-elektronik.de
|
|
|
|
|
|
@see www.mhs-elektronik.de
|
2025-12-15 20:57:09 +01:00
|
|
|
|
|
2025-12-26 14:07:55 +01:00
|
|
|
|
Based on Bionx data type descriptions from:
|
2025-12-15 20:57:09 +01:00
|
|
|
|
|
2025-12-26 14:07:55 +01:00
|
|
|
|
BigXionFlasher USB V 0.2.4 rev. 97
|
|
|
|
|
|
© 2011-2013 by Thomas Koenig <info@bigxionflasher.org>
|
|
|
|
|
|
@see www.bigxionflasher.org
|
2025-12-15 20:57:09 +01:00
|
|
|
|
|
2025-12-26 14:07:55 +01:00
|
|
|
|
Bionx Bike Info
|
|
|
|
|
|
© 2018 Thorsten Schmidt (tschmidt@ts-soft.de)
|
|
|
|
|
|
@see www.ts-soft.de
|
2025-12-15 20:57:09 +01:00
|
|
|
|
|
2025-12-26 14:07:55 +01:00
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
@see https://github.com/bikemike/bionx-bikeinfo
|
|
|
|
|
|
|
|
|
|
|
|
***************************************************************************/
|
2025-12-15 20:57:09 +01:00
|
|
|
|
|
|
|
|
|
|
|
2025-12-15 23:05:48 +01:00
|
|
|
|
#include <QApplication>
|
2025-12-17 13:11:26 +01:00
|
|
|
|
#include <QFile>
|
2025-12-15 20:57:09 +01:00
|
|
|
|
#include <QDebug>
|
|
|
|
|
|
|
2025-12-31 16:30:03 +01:00
|
|
|
|
#include <QPushButton>
|
|
|
|
|
|
#include <QStatusBar>
|
|
|
|
|
|
|
2025-12-15 23:05:48 +01:00
|
|
|
|
#include <bcmainwindow.h>
|
2025-12-15 20:57:09 +01:00
|
|
|
|
|
2026-03-06 10:34:57 +01:00
|
|
|
|
/*
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
|
#include <stdlib.h> // Stellt sicher, dass die Makros __argc und __argv bekannt sind
|
|
|
|
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
|
|
// Wir definieren die fehlenden Import-Pointer manuell und
|
|
|
|
|
|
// leiten sie auf die echten Variablen der neuen MinGW-Laufzeitumgebung um.
|
|
|
|
|
|
int* __imp___argc = &__argc;
|
|
|
|
|
|
char*** __imp___argv = &__argv;
|
|
|
|
|
|
}
|
|
|
|
|
|
#endif
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
// Intermediäre CRTP-Schicht übernimmt die generische Implementierung
|
|
|
|
|
|
template <typename Derived, typename Base>
|
|
|
|
|
|
struct cloneable : public Base
|
|
|
|
|
|
{
|
|
|
|
|
|
Derived* clone() override
|
|
|
|
|
|
{
|
|
|
|
|
|
return new Derived(static_cast<Derived const&>(*this));
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Base bleibt sauber – nur pure virtual
|
|
|
|
|
|
struct base
|
|
|
|
|
|
{
|
|
|
|
|
|
virtual base* clone() = 0;
|
|
|
|
|
|
virtual void moo() const = 0;
|
|
|
|
|
|
virtual ~base() = default;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Abgeleitete Klassen erben clone() automatisch
|
|
|
|
|
|
struct derived1 : public cloneable<derived1, base>
|
|
|
|
|
|
{
|
|
|
|
|
|
void moo() const override { qDebug() << " -- derived1 moo"; }
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct derived2 : public cloneable<derived2, base>
|
|
|
|
|
|
{
|
|
|
|
|
|
void moo() const override { qDebug() << " -- derived2 moo"; }
|
|
|
|
|
|
};
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
// ---
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
struct base
|
|
|
|
|
|
{
|
|
|
|
|
|
virtual base* clone() = 0;
|
|
|
|
|
|
virtual void moo() const = 0;
|
|
|
|
|
|
virtual ~base() = default;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// CRTP-Schicht
|
|
|
|
|
|
template <typename Derived, typename Base>
|
|
|
|
|
|
struct cloneable : public Base
|
|
|
|
|
|
{
|
|
|
|
|
|
Base* clone() override // Base* statt Derived*
|
|
|
|
|
|
{
|
|
|
|
|
|
return new Derived(static_cast<Derived const&>(*this));
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
// Der Rückgabetyp wird exakt nach deinen Vorgaben zur Kompilierzeit ermittelt
|
|
|
|
|
|
template <typename Self>
|
|
|
|
|
|
auto makeD3(this Self&& self) -> std::conditional_t<
|
|
|
|
|
|
std::is_const_v<std::remove_reference_t<Self>>,
|
|
|
|
|
|
const derived3&,
|
|
|
|
|
|
derived3&>
|
|
|
|
|
|
{
|
|
|
|
|
|
// Da der Rückgabetyp in der Signatur festgeschrieben ist,
|
|
|
|
|
|
// reicht ein einfaches return. Der Compiler bindet die Referenz automatisch korrekt.
|
|
|
|
|
|
return self;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- 2. Der CRTP-Klon-Automatismus
|
|
|
|
|
|
|
|
|
|
|
|
- Das NVI-Pattern (Non-Virtual Interface) in Kombination mit CRTP ist eine der elegantesten Architekturen im modernen C++, um dieses Problem zu lösen.
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
// Abgeleitete Klassen erben clone() automatisch
|
|
|
|
|
|
struct derived1 //: public cloneable<derived1, base>
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
// Eine einzige Methode für beide Value Categories
|
|
|
|
|
|
auto& nimmMich(this auto& self)
|
|
|
|
|
|
{
|
|
|
|
|
|
return self;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct derived2 : public cloneable<derived2, base>
|
|
|
|
|
|
{
|
|
|
|
|
|
void moo() const override { qDebug() << " -- derived2 moo"; }
|
|
|
|
|
|
|
|
|
|
|
|
void mooDerived2() const { qDebug() << " -- derived2 moo"; }
|
2025-12-31 16:30:03 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-03-06 10:34:57 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void machWasKonstantes() const
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
const derived1& d3 = d1.nimmMich();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void machWasSchmutziges()
|
|
|
|
|
|
{
|
|
|
|
|
|
derived1& d3 = d1.nimmMich();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
|
|
derived1 d1;
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct derived3 : public cloneable<derived3, base>
|
|
|
|
|
|
{
|
|
|
|
|
|
void moo() const override { qDebug() << " -- derived3 moo"; }
|
|
|
|
|
|
|
|
|
|
|
|
derived3* clone() override // Base* statt Derived*
|
|
|
|
|
|
{
|
|
|
|
|
|
return new derived3;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
derived2 m_myD2;
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
Das NVI-Pattern (Non-Virtual Interface) in Kombination mit CRTP ist eine der elegantesten Architekturen
|
|
|
|
|
|
im modernen C++, um dieses Problem zu lösen. Der Trick dabei beruht auf einer C++-Eigenheit: Die Sprache unterstützt "Kovarianz"
|
|
|
|
|
|
(Covariant Return Types) nativ nur bei rohen Zeigern und Referenzen, nicht aber bei Templates wie std::unique_ptr.
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2025-12-15 20:57:09 +01:00
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
|
|
{
|
2025-12-30 23:34:28 +01:00
|
|
|
|
|
2026-03-06 10:34:57 +01:00
|
|
|
|
qDebug() << "Starting NtxNode XML Test Suite...";
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
derived2 myDerived2;
|
|
|
|
|
|
base& d2 = *myDerived2.clone();
|
|
|
|
|
|
d2.moo();
|
|
|
|
|
|
|
|
|
|
|
|
derived3 myDerived3;
|
|
|
|
|
|
derived3& d3 = *myDerived3.clone();
|
|
|
|
|
|
d3.moo();
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2025-12-15 23:05:48 +01:00
|
|
|
|
QApplication app(argc, argv);
|
2026-01-09 08:39:53 +01:00
|
|
|
|
|
2025-12-23 20:47:03 +01:00
|
|
|
|
|
2025-12-17 13:11:26 +01:00
|
|
|
|
BCMainWindow w;
|
|
|
|
|
|
w.show();
|
|
|
|
|
|
|
2025-12-15 23:05:48 +01:00
|
|
|
|
return app.exec();
|
2025-12-15 20:57:09 +01:00
|
|
|
|
|
2025-12-31 13:38:46 +01:00
|
|
|
|
// 🌙☀️ !
|
2025-12-15 20:57:09 +01:00
|
|
|
|
}
|