46 unsigned totalPercentage )
52 scale(totalSteps, totalPercentage);
62 unsigned totalPercentage ,
63 bool updateCurrentProgress ) {
65 if (totalSteps == 0 || totalPercentage == 0) {
71 if (totalSteps >= 2 * totalPercentage) {
72 m_step =
static_cast<unsigned>(
73 ceil(
static_cast<float>(totalSteps) / totalPercentage));
76 static_cast<float>(totalPercentage) / (totalSteps /
m_step);
79 m_percentAdd =
static_cast<float>(totalPercentage) / totalSteps;
82 if (updateCurrentProgress) {
83 m_percent =
static_cast<float>(totalPercentage) / totalSteps *
104 unsigned currentCount =
106 if ((currentCount %
m_step) == 0) {
119 unsigned currentCount =
121 unsigned d1 = currentCount /
m_step;
122 unsigned d2 = (currentCount + n) /
m_step;
std::function< void(std::shared_ptr< core::Tensor >)> callback
int fetchAndAddRelaxed(int add)
virtual void update(float percent)=0
Notifies the algorithm progress.
virtual bool isCancelRequested()=0
Checks if the process should be canceled.
bool steps(unsigned n)
Increments total progress value of more than a single unit.
void reset()
Resets progress state.
float m_percentAdd
Percentage added to total progress value at each step.
NormalizedProgress(GenericProgressCallback *callback, unsigned totalSteps, unsigned totalPercentage=100)
Default constructor.
bool oneStep()
Increments total progress value of a single unit.
virtual ~NormalizedProgress()
Destructor.
AtomicCounter * m_counter
Current number of calls to 'oneStep'.
void scale(unsigned totalSteps, unsigned totalPercentage=100, bool updateCurrentProgress=false)
float m_percent
Total progress value (in percent)
GenericProgressCallback * progressCallback
associated GenericProgressCallback
MiniVec< float, N > ceil(const MiniVec< float, N > &a)
Generic file read and write utility for python interface.