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