Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
progress.h
1/*
2** Copyright 2007-2024, RTE (https://www.rte-france.com)
3** See AUTHORS.txt
4** SPDX-License-Identifier: MPL-2.0
5** This file is part of Antares-Simulator,
6** Adequacy and Performance assessment for interconnected energy networks.
7**
8** Antares_Simulator is free software: you can redistribute it and/or modify
9** it under the terms of the Mozilla Public Licence 2.0 as published by
10** the Mozilla Foundation, either version 2 of the License, or
11** (at your option) any later version.
12**
13** Antares_Simulator is distributed in the hope that it will be useful,
14** but WITHOUT ANY WARRANTY; without even the implied warranty of
15** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16** Mozilla Public Licence 2.0 for more details.
17**
18** You should have received a copy of the Mozilla Public Licence 2.0
19** along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
20*/
21#ifndef __STUDY_JOB_AGGREGATOR_PROGRESS_H__
22#define __STUDY_JOB_AGGREGATOR_PROGRESS_H__
23
24#include <atomic>
25
26#include <yuni/thread/timer.h>
27
28#include <antares/logs/logs.h>
29
30class Progress final: public Yuni::Thread::Timer
31{
32public:
34 using ThreadingPolicy = Yuni::Thread::Timer::ThreadingPolicy;
35
37 enum State
38 {
39 stJobs,
40 stWrite,
41 stReading,
42 stSilent,
43 };
44
45public:
47 static std::atomic<int> Current;
49 static uint Total;
50
51public:
52 Progress();
53 virtual ~Progress();
54
58 bool completed() const;
59
61 template<class StringT>
62 void message(const StringT& msg);
63
64public:
67
68protected:
69 virtual bool onInterval(uint) override;
70
71private:
73 bool pCompleted;
75 Yuni::String pMessage;
77 uint pLastPercent;
78
79}; // class Progress
80
81extern Progress progressBar;
82
83#include "progress.hxx"
84
85#endif // __STUDY_JOB_AGGREGATOR_PROGRESS_H__
Definition progress.h:31
static uint Total
The total number of jobs to execute.
Definition progress.h:49
bool completed() const
Get if the task is complete.
Definition progress.cpp:42
void message(const StringT &msg)
Set the message to display into logs.
Definition progress.hxx:29
Yuni::Thread::Timer::ThreadingPolicy ThreadingPolicy
The threading policy.
Definition progress.h:34
State
Different states related to the progression.
Definition progress.h:38
State state
The current state in the progression.
Definition progress.h:66
static std::atomic< int > Current
The number of jobs currently done.
Definition progress.h:47