0.5.4
C++ to UML diagram generator based on Clang
Loading...
Searching...
No Matches
progress_indicator.h
Go to the documentation of this file.
1/**
2 * @file src/common/generators/progress_indicator.h
3 *
4 * Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18#pragma once
19
20#include <indicators/indicators.hpp>
21
22#include <map>
23#include <memory>
24#include <vector>
25
27
28/**
29 * @brief Container for diagram generation progress indicators
30 */
32public:
34 explicit progress_state(size_t i, size_t p, size_t m)
35 : index{i}
36 , progress{p}
37 , max{m}
38 {
39 }
40
41 size_t index;
42 size_t progress;
43 size_t max;
44 };
45
47
48 progress_indicator(std::ostream &ostream);
49
50 /**
51 * Add a new progress bar to the indicator set
52 *
53 * @param name Name (prefix) of the progress bar
54 * @param max Total number of steps in the progress bar
55 * @param color Color of the progress bar
56 */
58 const std::string &name, size_t max, indicators::Color color);
59
60 /**
61 * Increment specified progress bar.
62 *
63 * @param name Name of the progress bar
64 */
65 void increment(const std::string &name);
66
67 /**
68 * Stop all the progress bars.
69 */
70 void stop();
71
72 /**
73 * Set specified progress bar as complete.
74 *
75 * @param name Name of the progress bar
76 */
77 void complete(const std::string &name);
78
79 /**
80 * Set progress bar as failed.
81 *
82 * @param name Name of the progress bar
83 */
84 void fail(const std::string &name);
85
86private:
87 indicators::DynamicProgress<indicators::ProgressBar> progress_bars_;
88 std::vector<std::shared_ptr<indicators::ProgressBar>> bars_;
89 std::map<std::string, progress_state> progress_bar_index_;
91 std::ostream &ostream_;
92};
93} // namespace clanguml::common::generators