4
0
mirror of https://github.com/QuasarApp/QuasarAppLib.git synced 2025-05-03 04:59:44 +00:00

remove depricated code. see The QuasarApp DoctorPill library

This commit is contained in:
Andrei Yankovich 2022-01-18 23:21:11 +03:00
parent 03e5ecb541
commit 04b73772d8
6 changed files with 0 additions and 343 deletions

@ -1,79 +0,0 @@
/*
* 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.
*/
#include <ipill.h>
#include "doctor.h"
namespace QuasarAppUtils {
Doctor::Doctor(const QList<QSharedPointer<iPill> > &base) {
_pillsData = base;
}
void Doctor::diagnostic(bool fix) const {
QList<QSharedPointer<iPill> > failed;
QList<QSharedPointer<iPill> > detected;
QList<QSharedPointer<iPill> > fixedSuccessful;
for (const auto &pill: _pillsData) {
if (pill->diagnostic()) {
if (fix) {
if (!pill->fix()) {
failed.push_back(pill);
} else {
fixedSuccessful.push_back(pill);
}
} else {
detected.push_back(pill);
}
}
}
if (failed.size()) {
emit sigFixesFailed(failed);
}
if (detected.count()) {
emit sigTroubleDetected(detected);
}
if (fixedSuccessful.count()) {
emit sigFixesFinishedSuccessful(fixedSuccessful);
}
}
void Doctor::fix(const QList<QSharedPointer<iPill> > &pills) const {
QList<QSharedPointer<iPill> > failed;
QList<QSharedPointer<iPill> > fixedSuccessful;
for (const auto &pill: pills) {
if (pill->diagnostic()) {
if (!pill->fix()) {
failed.push_back(pill);
} else {
fixedSuccessful.push_back(pill);
}
}
}
if (failed.size()) {
emit sigFixesFailed(failed);
}
if (fixedSuccessful.count()) {
emit sigFixesFinishedSuccessful(fixedSuccessful);
}
}
void Doctor::addPill(const QSharedPointer<iPill> &pill) {
_pillsData.push_back(pill);
}
}

@ -1,95 +0,0 @@
/*
* 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
#include "ipill.h"
#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.
*/
Doctor(const QList<QSharedPointer<iPill>> &base);
/**
* @brief diagnostic This method run full diagnostic of this application.
* 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.
* @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.
* @see Doctor::diagnostic
* @see Doctor::addPill
* @see Doctor::sigFixesFailed
* @see Doctor::sigFixesFinishedSuccessful
*/
void fix(const QList<QSharedPointer<iPill>>& pills) const;
/**
* @brief addPill This method add new pill object to doctor library
* @param pill This is pill object.
* @see Doctor::diagnostic
* @see Doctor::fix
* @see Doctor::sigFixesFailed
* @see Doctor::sigFixesFinishedSuccessful
*/
void addPill(const QSharedPointer<iPill>& pill);
signals:
/**
* @brief sigTroubleDetected This signal will emited when The doctor object found issues in this application.
* @param issues this is list of detected issues.
* @see Doctor::diagnostic
* @see Doctor::fix
* @see Doctor::sigFixesFailed
* @see Doctor::sigFixesFinishedSuccessful
*/
void sigTroubleDetected(QList<QSharedPointer<iPill>> issues) const;
/**
* @brief sigFixesFailed This signal emited when the doctor can't fix foundet issues.
* @param issues This is list of the unfixable issues.
*/
void sigFixesFailed(QList<QSharedPointer<iPill>> issues) const;
/**
* @brief sigFixesFinishedSuccessful This signal emited when the doctor fix foundet issues successfull.
* @param issues This is list of the fixed issues.
*/
void sigFixesFinishedSuccessful(QList<QSharedPointer<iPill>> issues) const;
private:
QList<QSharedPointer<iPill>> _pillsData;
};
}
#endif // DOCTOR_H

@ -1,30 +0,0 @@
/*
* 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.
*/
#include "doctortest.h"
#include "ipill.h"
namespace QuasarAppUtils {
DoctorTest::DoctorTest() {
}
bool DoctorTest::test(const QSharedPointer<iPill> &pill,
bool appIsBroken) const {
if (pill->diagnostic() != appIsBroken) {
return false;
}
if (appIsBroken && !pill->fix()) {
return false;
}
return pill->diagnostic();
}
}

@ -1,46 +0,0 @@
/*
* 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 DOCTORTEST_H
#define DOCTORTEST_H
#include <QSharedPointer>
namespace QuasarAppUtils {
class iPill;
class Doctor;
/**
* @brief The DoctorTest class This class contains auto tests for pills objects.
* @see Doctor class for get more information.
*/
class DoctorTest
{
public:
DoctorTest();
/**
* @brief test This method run simple test for the pill object.
* **Test algorithm**
*
* 1. Doctor run the iPill::diagnostic method.
* 2. If an @a appIsBroken is false then diagnostic method should return true
* 3. If an @a appIsBroken is true then diagnostic method should return true.
* 4. Doctor run the fix and check diagnostic method again.
* 5. The diagnostic method should return false value.
*
* @param pill This is checked pill for solve issue.
* @param appIsBroken bollean variable that should be true if app is broken else false.
* @return true if test passed elase false.
*/
bool test(const QSharedPointer<iPill>& pill, bool appIsBroken) const;
};
}
#endif // DOCTORTEST_H

@ -1,19 +0,0 @@
/*
* 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.
*/
#include "ipill.h"
namespace QuasarAppUtils {
iPill::iPill()
{
}
}

74
ipill.h

@ -1,74 +0,0 @@
/*
* 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 IPILL_H
#define IPILL_H
#include <QString>
namespace QuasarAppUtils {
/**
* @brief The iPill class is base interface for the pill object.
* The Pill object is independet tool that must be fix one issue for runned application.
*
* ## For Example:
*
* You has a sume bug, but you don't known about this bug.
* This big broken the database for your users, but you still don't known about this.
* You found this bug and create new patch for fix it, but databae of your users alredy broken, and you users can't fix this issues yasterself.
* So you can create a pill for fix broked database and delive to your users for fix thes issue.
*
* The Pill object structure should be has:
* * The Action that should be check if contains this issue or not ...
* * The Action taht should be fix issue.
* * Description of the issue.
* * Name of the issue.
*
* * @see iPill
*/
class iPill
{
public:
iPill();
/**
* @brief name This method should be return name of this pill.
* @return name of this pill.
*/
virtual QString name() const = 0;
/**
* @brief description This method should be return dital description of the issue that this pill will fix after execute (accept).
* @return string valeu with description.
*/
virtual QString description() const = 0;
protected:
/**
* @brief diagnostic This method execute action that should be check if exits issues or not.
* @note This method will executed only on the Doctor object.
* @return true if the issues is detected.
*/
virtual bool diagnostic() const = 0;
/**
* @brief fix This method should be fix detected issue.
* @return true if the issue fixes successful else false
*/
virtual bool fix() const = 0;
friend class Doctor;
friend class DoctorTest;
};
}
#endif // IPILL_H