diff --git a/doctor.cpp b/doctor.cpp deleted file mode 100644 index f48bc4f..0000000 --- a/doctor.cpp +++ /dev/null @@ -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 - -#include "doctor.h" - -namespace QuasarAppUtils { - -Doctor::Doctor(const QList > &base) { - _pillsData = base; -} - -void Doctor::diagnostic(bool fix) const { - - QList > failed; - QList > detected; - QList > 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 > &pills) const { - - QList > failed; - QList > 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 &pill) { - _pillsData.push_back(pill); -} - -} diff --git a/doctor.h b/doctor.h deleted file mode 100644 index a2cf332..0000000 --- a/doctor.h +++ /dev/null @@ -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 - -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> &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>& 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& 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> 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> 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> issues) const; - -private: - QList> _pillsData; -}; - - -} - -#endif // DOCTOR_H diff --git a/doctortest.cpp b/doctortest.cpp deleted file mode 100644 index e368b51..0000000 --- a/doctortest.cpp +++ /dev/null @@ -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 &pill, - bool appIsBroken) const { - - if (pill->diagnostic() != appIsBroken) { - return false; - } - - if (appIsBroken && !pill->fix()) { - return false; - } - - return pill->diagnostic(); -} - -} diff --git a/doctortest.h b/doctortest.h deleted file mode 100644 index 3e9f97c..0000000 --- a/doctortest.h +++ /dev/null @@ -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 - -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& pill, bool appIsBroken) const; - -}; - -} -#endif // DOCTORTEST_H diff --git a/ipill.cpp b/ipill.cpp deleted file mode 100644 index eb74275..0000000 --- a/ipill.cpp +++ /dev/null @@ -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() -{ - -} - - -} diff --git a/ipill.h b/ipill.h deleted file mode 100644 index 9fa90f0..0000000 --- a/ipill.h +++ /dev/null @@ -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 - - -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