1#ifndef H_EXTENSIONS_CUTEHMI_DATAACQUISITION_1_INCLUDE_CUTEHMI_DATAACQUISITION_INTERNAL_DBSERVICEABLEMIXIN_HPP
2#define H_EXTENSIONS_CUTEHMI_DATAACQUISITION_1_INCLUDE_CUTEHMI_DATAACQUISITION_INTERNAL_DBSERVICEABLEMIXIN_HPP
4#include <cutehmi/services/Serviceable.hpp>
6#include <cutehmi/shareddatabase/Database.hpp>
12namespace dataacquisition {
15template <
class DERIVED>
24 const DERIVED & derived()
const;
29template <
typename DERIVED>
34 if (derived().schema()) {
38 emit derived().databaseConnected();
45 emit derived().broke();
49 assignStatus(*state,
QCoreApplication::translate(
"cutehmi::dataacquisition::internal::DbServiceableMixin",
"Waiting for database"));
52 state->
addTransition(& derived(), & DERIVED::databaseConnected, target);
57template <
typename DERIVED>
62 if (!derived().schema()) {
64 emit derived().broke();
66 derived().schema()->validate();
72 state->
addTransition(& derived(), & DERIVED::schemaValidated, target);
77template <
typename DERIVED>
80 return static_cast<const DERIVED &
>(*this);
83template <
typename DERIVED>
84DERIVED & DbServiceableMixin<DERIVED>::derived()
86 return static_cast<DERIVED &
>(*this);
Definition: DbServiceableMixin.hpp:17
QState * createWaitingForDatabaseConnectedSate(QState *parent, services::Serviceable::AssignStatusFunction assignStatus, QState *target=nullptr)
Definition: DbServiceableMixin.hpp:30
QState * createValidatingSchemaSate(QState *parent, services::Serviceable::AssignStatusFunction assignStatus, QState *target=nullptr)
Definition: DbServiceableMixin.hpp:58
static bool IsConnected(const QString &connectionName)
#define CUTEHMI_CRITICAL(EXPR)
QString translate(const char *context, const char *sourceText, const char *disambiguation, int n)
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
void addTransition(QAbstractTransition *transition)