0.6.1
C++ to UML diagram generator based on Clang
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Member Functions | List of all members
clanguml::common::generators::json_logger_progress_indicator Class Reference

Detailed Description

Definition at line 86 of file progress_indicator.h.

#include <progress_indicator.h>

Public Member Functions

 json_logger_progress_indicator ()=default
 
 ~json_logger_progress_indicator () override=default
 
void add_progress_bar (const std::string &name, size_t max, indicators::Color color) override
 
void increment (const std::string &name) override
 
void stop () override
 
void complete (const std::string &name) override
 
void fail (const std::string &name) override
 
- Public Member Functions inherited from clanguml::common::generators::progress_indicator_base
virtual ~progress_indicator_base ()=default
 
virtual void add_progress_bar (const std::string &name, size_t max, indicators::Color color)=0
 
virtual void increment (const std::string &name)=0
 
virtual void stop ()=0
 
virtual void complete (const std::string &name)=0
 
virtual void fail (const std::string &name)=0
 

Additional Inherited Members

- Protected Attributes inherited from clanguml::common::generators::progress_indicator_base
std::map< std::string, progress_stateprogress_bar_index_
 
std::mutex progress_bars_mutex_
 

Constructor & Destructor Documentation

◆ json_logger_progress_indicator()

clanguml::common::generators::json_logger_progress_indicator::json_logger_progress_indicator ( )
default

◆ ~json_logger_progress_indicator()

clanguml::common::generators::json_logger_progress_indicator::~json_logger_progress_indicator ( )
overridedefault

Member Function Documentation

◆ add_progress_bar()

void clanguml::common::generators::json_logger_progress_indicator::add_progress_bar ( const std::string &  name,
size_t  max,
indicators::Color  color 
)
overridevirtual

Add a new progress bar to the indicator set

Parameters
nameName (prefix) of the progress bar
maxTotal number of steps in the progress bar
colorColor of the progress bar

Implements clanguml::common::generators::progress_indicator_base.

Definition at line 37 of file progress_indicator.cc.

39{ 40 inja::json j; 41 j["diagram_name"] = name; 42 j["max"] = max; 43 j["progress"] = 0; 44 j["status"] = "started"; 45 46 progress_bars_mutex_.lock(); 47 48 progress_bar_index_.emplace(name, progress_state{0, 0, max}); 49 50 progress_bars_mutex_.unlock(); 51 52 spdlog::get("json-progress-logger") 53 ->log(spdlog::level::info, "{}", j.dump()); 54}

◆ complete()

void clanguml::common::generators::json_logger_progress_indicator::complete ( const std::string &  name)
overridevirtual

Set specified progress bar as complete.

Parameters
nameName of the progress bar

Implements clanguml::common::generators::progress_indicator_base.

Definition at line 149 of file progress_indicator.cc.

150{ 151 inja::json j; 152 j["diagram_name"] = name; 153 154 progress_bars_mutex_.lock(); 155 156 if (progress_bar_index_.count(name) == 0) { 157 progress_bars_mutex_.unlock(); 158 return; 159 } 160 161 auto &p = progress_bar_index_.at(name); 162 163 p.progress = p.max; 164 165 j["progress"] = p.progress; 166 j["max"] = p.max; 167 j["status"] = "completed"; 168 169 progress_bars_mutex_.unlock(); 170 171 spdlog::get("json-progress-logger") 172 ->log(spdlog::level::info, "{}", j.dump()); 173}

◆ fail()

void clanguml::common::generators::json_logger_progress_indicator::fail ( const std::string &  name)
overridevirtual

Set progress bar as failed.

Parameters
nameName of the progress bar

Implements clanguml::common::generators::progress_indicator_base.

Definition at line 206 of file progress_indicator.cc.

207{ 208 inja::json j; 209 j["diagram_name"] = name; 210 211 progress_bars_mutex_.lock(); 212 213 if (progress_bar_index_.count(name) == 0) { 214 progress_bars_mutex_.unlock(); 215 return; 216 } 217 auto &p = progress_bar_index_.at(name); 218 219 j["progress"] = p.progress; 220 j["max"] = p.max; 221 j["status"] = "failed"; 222 223 progress_bars_mutex_.unlock(); 224 225 spdlog::get("json-progress-logger") 226 ->log(spdlog::level::err, "{}", j.dump()); 227}

◆ increment()

void clanguml::common::generators::json_logger_progress_indicator::increment ( const std::string &  name)
overridevirtual

Increment specified progress bar.

Parameters
nameName of the progress bar

Implements clanguml::common::generators::progress_indicator_base.

Definition at line 89 of file progress_indicator.cc.

90{ 91 inja::json j; 92 j["diagram_name"] = name; 93 94 progress_bars_mutex_.lock(); 95 96 if (progress_bar_index_.count(name) == 0) { 97 progress_bars_mutex_.unlock(); 98 return; 99 } 100 101 auto &p = progress_bar_index_.at(name); 102 103 j["progress"] = p.progress; 104 j["max"] = p.max; 105 j["status"] = "ongoing"; 106 107 p.progress++; 108 109 progress_bars_mutex_.unlock(); 110 111 spdlog::get("json-progress-logger") 112 ->log(spdlog::level::info, "{}", j.dump()); 113}

◆ stop()

void clanguml::common::generators::json_logger_progress_indicator::stop ( )
inlineoverridevirtual

Stop all the progress bars.

Implements clanguml::common::generators::progress_indicator_base.

Definition at line 97 of file progress_indicator.h.

97{ }

The documentation for this class was generated from the following files: