QuasarAppLib/doctor.h

96 lines
3.0 KiB
C
Raw Normal View History

2022-01-10 20:36:41 +03:00
/*
* Copyright (C) 2018-2022 QuasarApp.
* Distributed under the lgplv3 software license, see the accompanying
* Everyone is permitted to copy and distribute verbatim copies
* of this license document, but changing it is not allowed.
*/
#ifndef DOCTOR_H
#define DOCTOR_H
2022-01-11 10:53:25 +03:00
#include "ipill.h"
2022-01-10 20:36:41 +03:00
#include <QSharedPointer>
namespace QuasarAppUtils {
/**
* @brief The Doctor class is class that execute pills objects.
* The Doctor check issue that will be executed and if the issue realy then execute fix.
* @warning This is dangerous system because you may create bug in pill and doctor that will execute this pill may broke users app.
* @see iPill
*/
class Doctor: public QObject
{
Q_OBJECT
public:
/**
* @brief Doctor This is base contructor of doctor calss.
* @param base This is list of known issues.
*/
2022-01-11 10:17:29 +03:00
Doctor(const QList<QSharedPointer<iPill>> &base);
2022-01-10 20:36:41 +03:00
/**
2022-01-11 10:59:45 +03:00
* @brief diagnostic This method run full diagnostic of this application.
2022-01-10 20:36:41 +03:00
* If the @a fix is true then doctor try fix the foundet issues.
* If the @a fix value if false then the Doctor emit the sigTroubleDetected signal.
* @param fix set this argument to tru if you want fix all foundet issues.
2022-01-11 10:17:29 +03:00
* @see Doctor::fix
* @see Doctor::addPill
* @see Doctor::sigFixesFailed
* @see Doctor::sigFixesFinishedSuccessful
*/
void diagnostic(bool fix = false) const;
/**
* @brief fix This method try run fixes by input pills.
* @note All fixes will be checked before execute fix.
* @param pills This is list of fixes that will be executed.
2022-01-11 10:59:45 +03:00
* @see Doctor::diagnostic
2022-01-11 10:17:29 +03:00
* @see Doctor::addPill
* @see Doctor::sigFixesFailed
* @see Doctor::sigFixesFinishedSuccessful
2022-01-10 20:36:41 +03:00
*/
2022-01-11 10:17:29 +03:00
void fix(const QList<QSharedPointer<iPill>>& pills) const;
2022-01-10 20:36:41 +03:00
/**
2022-01-11 10:17:29 +03:00
* @brief addPill This method add new pill object to doctor library
* @param pill This is pill object.
2022-01-11 10:59:45 +03:00
* @see Doctor::diagnostic
2022-01-11 10:17:29 +03:00
* @see Doctor::fix
* @see Doctor::sigFixesFailed
* @see Doctor::sigFixesFinishedSuccessful
2022-01-10 20:36:41 +03:00
*/
2022-01-11 10:17:29 +03:00
void addPill(const QSharedPointer<iPill>& pill);
2022-01-10 20:36:41 +03:00
signals:
/**
* @brief sigTroubleDetected This signal will emited when The doctor object found issues in this application.
2022-01-11 10:17:29 +03:00
* @param issues this is list of detected issues.
2022-01-11 10:59:45 +03:00
* @see Doctor::diagnostic
2022-01-11 10:17:29 +03:00
* @see Doctor::fix
* @see Doctor::sigFixesFailed
* @see Doctor::sigFixesFinishedSuccessful
2022-01-10 20:36:41 +03:00
*/
2022-01-11 10:17:29 +03:00
void sigTroubleDetected(QList<QSharedPointer<iPill>> issues) const;
2022-01-10 20:36:41 +03:00
/**
* @brief sigFixesFailed This signal emited when the doctor can't fix foundet issues.
* @param issues This is list of the unfixable issues.
*/
2022-01-11 10:17:29 +03:00
void sigFixesFailed(QList<QSharedPointer<iPill>> issues) const;
2022-01-10 20:36:41 +03:00
/**
* @brief sigFixesFinishedSuccessful This signal emited when the doctor fix foundet issues successfull.
* @param issues This is list of the fixed issues.
*/
2022-01-11 10:17:29 +03:00
void sigFixesFinishedSuccessful(QList<QSharedPointer<iPill>> issues) const;
2022-01-10 20:36:41 +03:00
private:
2022-01-11 10:17:29 +03:00
QList<QSharedPointer<iPill>> _pillsData;
2022-01-10 20:36:41 +03:00
};
}
#endif // DOCTOR_H