Line data Source code
1 : /*! 2 : * \file 3 : * \brief Class tools::Terminal_std. 4 : */ 5 : #ifndef TERMINAL_STD_HPP_ 6 : #define TERMINAL_STD_HPP_ 7 : 8 : #include <iostream> 9 : #include <memory> 10 : #include <rang.hpp> 11 : #include <string> 12 : #include <vector> 13 : 14 : #include "Tools/Display/Terminal/Terminal.hpp" 15 : #include "Tools/Reporter/Reporter.hpp" 16 : 17 : namespace spu 18 : { 19 : namespace tools 20 : { 21 : /*! 22 : * \class Terminal_std 23 : * 24 : * \brief The terminal_std display. 25 : */ 26 : class Terminal_std : public Terminal 27 : { 28 : public: 29 : static const char line_separator; 30 : static const std::string col_separator; 31 : static const std::string group_separator; 32 : static const std::string spaced_scol_separator; 33 : static const std::string spaced_dcol_separator; 34 : static const std::string data_tag; 35 : static const rang::style legend_style; 36 : static const rang::style report_style; 37 : static const size_t def_column_width; 38 : 39 : protected: 40 : std::vector<tools::Reporter*> reporters; 41 : 42 : public: 43 : /*! 44 : * \brief Constructor. 45 : */ 46 : explicit Terminal_std(const std::vector<tools::Reporter*>& reporters); 47 : 48 : /*! 49 : * \brief Constructor. 50 : */ 51 : explicit Terminal_std(const std::vector<std::unique_ptr<tools::Reporter>>& reporters); 52 : 53 : /*! 54 : * \brief Destructor. 55 : */ 56 0 : virtual ~Terminal_std() = default; 57 : 58 : /*! 59 : * \brief Displays the terminal_std legend. 60 : * 61 : * \param stream: the stream to print the legend. 62 : */ 63 : void legend(std::ostream& stream = std::cout) const; 64 : 65 : std::vector<tools::Reporter*>& get_reporters(); 66 : 67 : protected: 68 : virtual void report(std::ostream& stream = std::cout, bool final = false); 69 : 70 : static unsigned extra_spaces(const Reporter::title_t& text, const unsigned group_width); 71 : static unsigned extra_spaces(const Reporter::group_t& group); 72 : static unsigned get_group_width(const Reporter::group_t& group); 73 : }; 74 : } 75 : } 76 : 77 : #endif /* TERMINAL_STD_HPP_ */