Line data Source code
1 : /*! 2 : * \file 3 : * \brief Class module::Probe. 4 : */ 5 : #ifndef PROBE_HPP_ 6 : #define PROBE_HPP_ 7 : 8 : #include <cstddef> 9 : #include <cstdint> 10 : #include <memory> 11 : #include <string> 12 : #include <typeindex> 13 : #include <vector> 14 : 15 : #include "Module/Stateful/Stateful.hpp" 16 : #include "Runtime/Socket/Socket.hpp" 17 : #include "Runtime/Task/Task.hpp" 18 : #include "Tools/Interface/Interface_reset.hpp" 19 : #include "Tools/Reporter/Probe/Reporter_probe.hpp" 20 : 21 : namespace spu 22 : { 23 : namespace module 24 : { 25 : namespace prb 26 : { 27 : enum class tsk : uint8_t 28 : { 29 : probe, 30 : SIZE 31 : }; 32 : 33 : namespace sck 34 : { 35 : enum class probe : uint8_t 36 : { 37 : in, 38 : status 39 : }; 40 : enum class probe_noin : uint8_t 41 : { 42 : status 43 : }; 44 : } 45 : } 46 : 47 : class AProbe 48 : : public Stateful 49 : , public tools::Interface_reset 50 : { 51 : protected: 52 : tools::Reporter_probe* reporter; 53 : bool str_display; 54 : 55 : public: 56 : AProbe(); 57 0 : virtual ~AProbe() = default; 58 : virtual void reset() = 0; 59 : 60 : bool get_str_display() const; 61 : void set_str_display(bool str_display); 62 : 63 : virtual void set_col_unit(const std::string& unit) = 0; 64 : virtual void set_col_buff_size(const size_t buffer_size) = 0; 65 : virtual void set_col_fmtflags(const std::ios_base::fmtflags ff) = 0; 66 : virtual void set_col_prec(const size_t precision) = 0; 67 : virtual void set_col_size(const size_t col_size) = 0; 68 : 69 : virtual void register_reporter(tools::Reporter_probe* reporter) = 0; 70 : 71 : virtual const std::string& get_col_name() const = 0; 72 : 73 : inline runtime::Task& operator[](const prb::tsk t); 74 : inline runtime::Socket& operator[](const prb::sck::probe s); 75 : inline runtime::Socket& operator[](const prb::sck::probe_noin s); 76 : inline runtime::Socket& operator[](const std::string& tsk_sck); 77 : 78 : protected: 79 : void check_reporter(); 80 : void proxy_register_probe(const size_t data_size, 81 : const std::type_index data_type, 82 : const std::string& unit, 83 : const size_t buffer_size, 84 : const std::ios_base::fmtflags ff, 85 : const size_t precision); 86 : void proxy_probe(const void* data, const size_t frame_id); 87 : }; 88 : 89 : template<typename T = uint8_t> 90 : class Probe : public AProbe 91 : { 92 : public: 93 : inline runtime::Task& operator[](const prb::tsk t); 94 : inline runtime::Socket& operator[](const prb::sck::probe s); 95 : inline runtime::Socket& operator[](const prb::sck::probe_noin s); 96 : inline runtime::Socket& operator[](const std::string& tsk_sck); 97 : 98 : protected: 99 : const size_t socket_size; 100 : const std::string col_name; 101 : Probe(const size_t socket_size, const std::string& col_name); 102 : 103 : public: 104 0 : virtual ~Probe() = default; 105 : 106 : template<class AT = std::allocator<T>> 107 : void probe(const std::vector<T, AT>& in, const int frame_id = -1, const bool managed_memory = true); 108 : 109 : void probe(const T* in, const int frame_id = -1, const bool managed_memory = true); 110 : 111 : void probe(const int frame_id = -1, const bool managed_memory = true); 112 : 113 : virtual void reset(); 114 : 115 : virtual void set_n_frames(const size_t n_frames); 116 : 117 : virtual void set_col_unit(const std::string& unit); 118 : virtual void set_col_buff_size(const size_t buffer_size); 119 : virtual void set_col_fmtflags(const std::ios_base::fmtflags ff); 120 : virtual void set_col_prec(const size_t precision); 121 : virtual void set_col_size(const size_t col_size); 122 : 123 : const std::string& get_col_name() const; 124 : size_t get_socket_size() const; 125 : 126 : protected: 127 : virtual void _probe(const T* in, const size_t frame_id); 128 : }; 129 : } 130 : } 131 : 132 : #ifndef DOXYGEN_SHOULD_SKIP_THIS 133 : #include "Module/Stateful/Probe/Probe.hxx" 134 : #endif 135 : 136 : #endif /* PROBE_HPP_ */