File: subtasklistener.h

package info (click to toggle)
aoflagger 3.4.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,960 kB
  • sloc: cpp: 83,076; python: 10,187; sh: 260; makefile: 178
file content (35 lines) | stat: -rw-r--r-- 983 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#ifndef UTIL_PROGRESS_SUB_TASK_LISTENER_H_
#define UTIL_PROGRESS_SUB_TASK_LISTENER_H_

#include "progresslistener.h"

class SubTaskListener final : public ProgressListener {
 public:
  SubTaskListener(ProgressListener& parentListener, size_t progress,
                  size_t maxProgress)
      : _parentListener(parentListener),
        _fullProgress(progress),
        _fullMaxProgress(maxProgress) {}

  void OnStartTask(const std::string& description) override {
    _parentListener.OnStartTask(description);
  }

  void OnProgress(size_t progress, size_t maxProgress) override {
    _parentListener.OnProgress(_fullProgress * maxProgress + progress,
                               maxProgress * _fullMaxProgress);
  }

  void OnFinish() override {}

  void OnException(std::exception& thrownException) override {
    _parentListener.OnException(thrownException);
  }

 private:
  ProgressListener& _parentListener;
  size_t _fullProgress;
  size_t _fullMaxProgress;
};

#endif