refactor: simplify Task class

This commit is contained in:
dd060606
2025-02-07 15:26:06 +01:00
parent 8e6a0d35c0
commit 379dcc3870
2 changed files with 12 additions and 36 deletions

View File

@@ -1,48 +1,29 @@
#include "Task.h"
// Constructeur
Task::Task() : is_paused(false), is_running(false) {}
Task::Task() : is_running(false) {}
Task::~Task()
{
// Si la tâche est en cours d'exécution, on l'arrête
stop();
}
// Démarre la tâche
void Task::start()
{
is_running = true;
is_paused = false;
}
// Met en pause la tâche
void Task::pause()
{
if (is_running && !is_paused)
{
is_paused = true;
}
}
// Reprend la tâche
void Task::resume()
{
if (is_paused)
{
is_paused = false;
}
}
// Arrête la tâche
void Task::stop()
{
if (is_running)
{
is_running = false;
is_paused = false;
}
is_running = false;
}
// Getters
bool Task::isPaused()
{
return is_paused;
}
bool Task::isRunning()
{
return is_running;

View File

@@ -4,21 +4,16 @@
class Task
{
private:
bool is_paused;
bool is_running;
public:
Task(); // Constructeur
// Mise en pause de la tâche
void pause();
// Reprise de la tâche
void resume();
Task(); // Constructeur
~Task(); // Déstructeur
// Démarrage de la tâche
void start();
// Arrêt de la tâche
void stop();
// Getters
bool isPaused();
bool isRunning();
};