aboutsummaryrefslogtreecommitdiff
path: root/src/nix/progress-bar.hh
blob: 2dda24346c90df62c961ca54e739f35a3d3e7485 (plain)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#pragma once

#include "sync.hh"
#include "util.hh"

namespace nix {

class ProgressBar
{
private:
    struct State
    {
        std::string status;
        bool done = false;
        std::list<std::string> activities;
    };

    Sync<State> state;

public:

    ProgressBar();

    ~ProgressBar();

    void updateStatus(const std::string & s);

    void done();

    class Activity
    {
        friend class ProgressBar;
    private:
        ProgressBar & pb;
        std::list<std::string>::iterator it;
        Activity(ProgressBar & pb, const FormatOrString & fs);
    public:
        ~Activity();
    };

    Activity startActivity(const FormatOrString & fs);

private:

    void render(State & state_);

};

}