1
0
Fork 0
mirror of https://github.com/HamletDuFromage/aio-switch-updater.git synced 2024-11-13 21:56:42 +00:00
AIO-switch-updater/include/progress_event.hpp

55 lines
1.6 KiB
C++
Raw Normal View History

2020-09-20 01:21:28 +01:00
#pragma once
2021-09-11 14:48:13 +01:00
class ProgressEvent
{
2020-09-20 01:21:28 +01:00
private:
ProgressEvent() {}
int _current = 0;
int _max = 60;
double _now = 0;
double _total = 0;
double _speed = 0;
long _status_code = 0;
bool _interupt = false;
2020-09-20 01:21:28 +01:00
public:
ProgressEvent(const ProgressEvent&) = delete;
2021-09-11 14:48:13 +01:00
ProgressEvent& operator=(const ProgressEvent&) = delete;
ProgressEvent(ProgressEvent&&) = delete;
ProgressEvent& operator=(ProgressEvent&&) = delete;
2020-09-20 01:21:28 +01:00
2021-09-11 14:48:13 +01:00
static auto& instance()
{
2020-09-20 01:21:28 +01:00
static ProgressEvent event;
return event;
}
2021-09-11 14:48:13 +01:00
void reset()
{
2020-09-20 01:21:28 +01:00
_current = 0;
_max = 60;
_now = 0;
_total = 0;
_speed = 0;
_status_code = 0;
_interupt = false;
2020-09-20 01:21:28 +01:00
}
inline void setTotalSteps(int steps) { _max = steps; }
inline void setTotalCount(double total) { _total = total; }
inline void setSpeed(double speed) { _speed = speed; }
2020-09-20 01:21:28 +01:00
inline void setStep(int step) { _current = step; }
inline void setStatusCode(long status_code) { _status_code = status_code; }
2021-09-11 14:48:13 +01:00
inline void incrementStep(int increment) { _current += increment; }
inline void setNow(double now) { _now = now; }
2020-09-20 01:21:28 +01:00
inline int getStep() { return _current; }
inline double getNow() { return _now; }
2021-09-11 14:48:13 +01:00
inline bool finished() { return (_current == _max); }
2020-09-20 01:21:28 +01:00
inline int getMax() { return _max; }
inline double getTotal() { return _total; }
inline double getSpeed() { return _speed; }
inline double getStatusCode() { return _status_code; }
inline void setInterupt(bool interupt) { _interupt = interupt; }
inline bool getInterupt() { return _interupt; }
2020-09-20 01:21:28 +01:00
};