diff --git a/accumulator.cpp b/accumulator.cpp index 6f52bdf..337cf32 100644 --- a/accumulator.cpp +++ b/accumulator.cpp @@ -2,6 +2,7 @@ #define FORTUNA_ACCUMULATOR_CPP #include "accumulator.h" + #include #include @@ -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 diff --git a/accumulator.h b/accumulator.h index 5d10a66..e0dd60c 100644 --- a/accumulator.h +++ b/accumulator.h @@ -4,7 +4,9 @@ #include "event_adder_impl.h" #include "generator.h" #include "pool.h" + #include + #include #include @@ -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