62 lines
1.2 KiB
C++
62 lines
1.2 KiB
C++
#ifndef FORTUNA_ACCUMULATOR_H
|
|
#define FORTUNA_ACCUMULATOR_H
|
|
|
|
#include "event_adder_impl.h"
|
|
#include "generator.h"
|
|
#include "pool.h"
|
|
#include <algorithm>
|
|
#include <exception>
|
|
#include <fmt/core.h>
|
|
|
|
namespace fortuna {
|
|
namespace accumulator {
|
|
|
|
class Accumulator {
|
|
private:
|
|
fortuna::generator::Generator *Gen;
|
|
|
|
protected:
|
|
uint src_count{0};
|
|
|
|
public:
|
|
constexpr static const unsigned int init_pool_num{0};
|
|
|
|
auto add_source() -> void {
|
|
static uint src_id{this->src_count};
|
|
++src_count;
|
|
accumulator::Pool pools[32];
|
|
EventAdderImpl event_adder(src_id, pools);
|
|
[[maybe_unused]] bool scheduled;
|
|
}
|
|
|
|
auto set_gen(fortuna::generator::Generator& Gen) -> void {
|
|
this->Gen = std::move(&Gen);
|
|
}
|
|
|
|
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 call_reseed(const std::string& seed) -> void {
|
|
try {
|
|
this->Gen->reseed(seed);
|
|
} catch(std::exception& e) {
|
|
fmt::print("{}", e.what());
|
|
}
|
|
}
|
|
Accumulator();
|
|
~Accumulator() noexcept;
|
|
|
|
}; //class Accumulator
|
|
|
|
} //namespace accumulator
|
|
} //namespace fortuna
|
|
|
|
#endif//FORTUNA_ACCUMULATOR_H
|