Line data Source code
1 : /*! 2 : * \file 3 : * \brief Class tools::Reporter_probe. 4 : */ 5 : #ifndef REPORTER_PROBE_HPP_ 6 : #define REPORTER_PROBE_HPP_ 7 : 8 : #include <cstddef> 9 : #include <initializer_list> 10 : #include <ios> 11 : #include <iostream> 12 : #include <map> 13 : #include <mutex> 14 : #include <string> 15 : #include <typeindex> 16 : #include <vector> 17 : 18 : #include "Tools/Interface/Interface_get_set_n_frames.hpp" 19 : #include "Tools/Reporter/Reporter.hpp" 20 : 21 : namespace spu 22 : { 23 : namespace module 24 : { 25 : class AProbe; 26 : } 27 : namespace tools 28 : { 29 : 30 : class Reporter_probe 31 : : public Reporter 32 : , public Interface_get_set_n_frames 33 : { 34 : friend module::AProbe; 35 : 36 : protected: 37 : std::vector<module::AProbe*> probes; 38 : 39 : std::vector<size_t> head; 40 : std::vector<size_t> tail; 41 : std::vector<std::vector<std::vector<int8_t>>> buffer; 42 : std::vector<std::type_index> datatypes; 43 : std::vector<std::ios_base::fmtflags> format_flags; 44 : std::vector<size_t> precisions; 45 : std::vector<size_t> column_sizes; 46 : std::vector<size_t> data_sizes; 47 : std::vector<bool> display_as_str; 48 : std::map<std::string, int> name_to_col; 49 : std::map<int, std::string> col_to_name; 50 : size_t n_frames; 51 : std::vector<std::mutex> mtx; 52 : 53 : public: 54 : Reporter_probe(const std::string& group_name, const std::string& group_description); 55 : 56 : explicit Reporter_probe(const std::string& group_name); 57 : 58 0 : virtual ~Reporter_probe() = default; 59 : 60 : virtual report_t report(bool final = false); 61 : 62 : virtual void reset(); 63 : 64 : void set_n_frames(const size_t n_frames); 65 : 66 : size_t get_n_frames() const; 67 : 68 : void set_col_unit(const std::string& unit, const module::AProbe& prb); 69 : void set_col_buff_size(const size_t buffer_size, const module::AProbe& prb); 70 : void set_col_fmtflags(const std::ios_base::fmtflags ff, const module::AProbe& prb); 71 : void set_col_prec(const size_t precision, const module::AProbe& prb); 72 : void set_col_size(const size_t col_size, const module::AProbe& prb); 73 : 74 : void set_cols_unit(const std::string& unit); 75 : void set_cols_buff_size(const size_t buffer_size); 76 : void set_cols_fmtflags(const std::ios_base::fmtflags ff); 77 : void set_cols_prec(const size_t precision); 78 : void set_cols_size(const size_t col_size); 79 : 80 : void register_probes(const std::vector<module::AProbe*>& probes); 81 : 82 : protected: 83 : void register_probe(module::AProbe& probe, 84 : const size_t data_size, 85 : const std::type_index data_type, 86 : const std::string& unit, 87 : const size_t buffer_size, 88 : const std::ios_base::fmtflags ff, 89 : const size_t precision); 90 : 91 : virtual void probe(const module::AProbe& probe, const void* data, const size_t frame_id); 92 : 93 : void create_probe_checks(const std::string& name); 94 : 95 : template<typename T> 96 : size_t col_size(const int col); 97 : 98 : template<typename T> 99 : bool push(const int col, const T* data); 100 : 101 : template<typename T> 102 : bool pull(const int col, T* data); 103 : 104 : size_t get_probe_index(const module::AProbe& prb); 105 : 106 : private: 107 : template<typename T> 108 : bool format_values(const int col, std::stringstream& temp_stream); 109 : }; 110 : } 111 : } 112 : 113 : #ifndef DOXYGEN_SHOULD_SKIP_THIS 114 : #include "Tools/Reporter/Probe/Reporter_probe.hxx" 115 : #endif 116 : 117 : #endif /* REPORTER_PROBE_HPP_ */