Line data Source code
1 : #include <ios> 2 : #include <sstream> 3 : 4 : #include "Module/Stateful/Probe/Stream/Probe_stream.hpp" 5 : #include "Tools/Exception/exception.hpp" 6 : 7 : using namespace spu; 8 : using namespace spu::module; 9 : 10 14 : Probe_stream::Probe_stream(const std::string& col_name, tools::Reporter_probe* reporter) 11 : : Probe<uint8_t>(0, col_name) 12 14 : , occurrences(0) 13 : { 14 14 : const std::string name = "Probe_stream<" + col_name + ">"; 15 14 : this->set_name(name); 16 14 : this->set_single_wave(true); 17 : 18 14 : if (reporter != nullptr) this->register_reporter(reporter); 19 14 : } 20 : 21 : void 22 14 : Probe_stream::register_reporter(tools::Reporter_probe* reporter) 23 : { 24 14 : if (this->reporter != nullptr) 25 : { 26 0 : std::stringstream message; 27 : message << "It is not possible to register this probe to a new 'tools::Reporter_probe' because it is already " 28 0 : << "registered to an other 'tools::Reporter_probe'."; 29 0 : throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str()); 30 0 : } 31 14 : this->reporter = reporter; 32 14 : this->proxy_register_probe(1, typeid(int64_t), "", 100, std::ios_base::scientific, 3); 33 14 : } 34 : 35 : void 36 103 : Probe_stream::_probe(const uint8_t* in, const size_t frame_id) 37 : { 38 236 : for (size_t f = 0; f < this->get_n_frames(); f++) 39 133 : this->proxy_probe((void*)&occurrences, frame_id); 40 103 : this->occurrences++; 41 103 : } 42 : 43 : void 44 14 : Probe_stream::reset() 45 : { 46 14 : this->occurrences = 0; 47 14 : } 48 : 49 : int64_t 50 0 : Probe_stream::get_occurrences() const 51 : { 52 0 : return this->occurrences; 53 : }