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 16 : Probe_stream::Probe_stream(const std::string& col_name, tools::Reporter_probe* reporter) 11 : : Probe<uint8_t>(0, col_name) 12 16 : , occurrences(0) 13 : { 14 16 : const std::string name = "Probe_stream<" + col_name + ">"; 15 16 : this->set_name(name); 16 16 : this->set_single_wave(true); 17 : 18 16 : if (reporter != nullptr) this->register_reporter(reporter); 19 16 : } 20 : 21 : void 22 16 : Probe_stream::register_reporter(tools::Reporter_probe* reporter) 23 : { 24 16 : 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 16 : this->reporter = reporter; 32 16 : this->proxy_register_probe(1, typeid(int64_t), "", 100, std::ios_base::scientific, 3); 33 16 : } 34 : 35 : void 36 106 : Probe_stream::_probe(const uint8_t* /*in*/, const size_t frame_id) 37 : { 38 262 : for (size_t f = 0; f < this->get_n_frames(); f++) 39 156 : this->proxy_probe((void*)&occurrences, frame_id); 40 106 : this->occurrences++; 41 106 : } 42 : 43 : void 44 16 : Probe_stream::reset() 45 : { 46 16 : this->occurrences = 0; 47 16 : } 48 : 49 : int64_t 50 0 : Probe_stream::get_occurrences() const 51 : { 52 0 : return this->occurrences; 53 : }