accumulator: move logic to source file
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
ebcc4f87d5
commit
ebb1e46e1c
|
@ -2,6 +2,7 @@
|
|||
#define FORTUNA_ACCUMULATOR_CPP
|
||||
|
||||
#include "accumulator.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
|
||||
|
@ -17,6 +18,31 @@ Accumulator::Accumulator() noexcept {
|
|||
}
|
||||
Accumulator::~Accumulator() noexcept {};
|
||||
|
||||
|
||||
auto Accumulator::set_gen(fortuna::generator::Generator& gen) -> void {
|
||||
this->Gen = std::move(&gen);
|
||||
}
|
||||
|
||||
auto Accumulator::get_random_data(uint n_bytes) -> std::string {
|
||||
std::string data{""};
|
||||
try {
|
||||
data = this->Gen->generate_random_data(n_bytes);
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
fmt::print("{}", e.what());
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
auto Accumulator::call_reseed(const std::string& seed) -> void {
|
||||
try {
|
||||
this->Gen->reseed(seed);
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
fmt::print("{}", e.what());
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace accumulator
|
||||
} // namespace fortuna
|
||||
|
||||
|
|
|
@ -4,7 +4,9 @@
|
|||
#include "event_adder_impl.h"
|
||||
#include "generator.h"
|
||||
#include "pool.h"
|
||||
|
||||
#include <fmt/core.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <exception>
|
||||
|
||||
|
@ -13,7 +15,7 @@ namespace accumulator {
|
|||
|
||||
class Accumulator {
|
||||
private:
|
||||
fortuna::generator::Generator *Gen;
|
||||
fortuna::generator::Generator* Gen;
|
||||
|
||||
protected:
|
||||
uint src_count{0};
|
||||
|
@ -29,27 +31,11 @@ public:
|
|||
[[maybe_unused]] bool scheduled;
|
||||
}
|
||||
|
||||
auto set_gen(fortuna::generator::Generator& Gen) -> void {
|
||||
this->Gen = std::move(&Gen);
|
||||
}
|
||||
auto set_gen(fortuna::generator::Generator& Gen) -> void;
|
||||
|
||||
auto get_random_data(uint n_bytes) -> std::string {
|
||||
std::string data{""};
|
||||
try {
|
||||
data = this->Gen->generate_random_data(n_bytes);
|
||||
} catch(std::exception& e) {
|
||||
fmt::print("{}", e.what());
|
||||
}
|
||||
return data;
|
||||
}
|
||||
auto get_random_data(uint n_bytes) -> std::string;
|
||||
|
||||
auto call_reseed(const std::string& seed) -> void {
|
||||
try {
|
||||
this->Gen->reseed(seed);
|
||||
} catch(std::exception& e) {
|
||||
fmt::print("{}", e.what());
|
||||
}
|
||||
}
|
||||
auto call_reseed(const std::string& seed) -> void;
|
||||
|
||||
auto wait_for(uint milliseconds) -> void;
|
||||
|
||||
|
@ -66,9 +52,9 @@ public:
|
|||
Accumulator() noexcept;
|
||||
~Accumulator() noexcept;
|
||||
|
||||
}; //class Accumulator
|
||||
}; // class Accumulator
|
||||
|
||||
} //namespace accumulator
|
||||
} //namespace fortuna
|
||||
} // namespace accumulator
|
||||
} // namespace fortuna
|
||||
|
||||
#endif//FORTUNA_ACCUMULATOR_H
|
||||
#endif // FORTUNA_ACCUMULATOR_H
|
||||
|
|
Reference in New Issue