31 #include <random/Encrypter.hpp> 64 if(out[0]<=(*
this)[0])
72 while(out[iDigit++]==0
and iDigit<4);
113 CRASH<<
"Trying to lock an already locked generator!";
126 CRASH<<
"Trying to unlock a non-locked generator!";
144 template <
typename F>
149 typename F::ResultType;
153 sizeof(Word)/
sizeof(FRes);
165 for(
int i=0;i<nCall;i++)
188 if(offset>=nReserved)
189 CRASH<<
"Asking to generate "<<offset<<
", beyond the reserved range: "<<nReserved;
197 const ResultType out{};
205 encrypt(key,
static_cast<Word>(shiftedState));
bool release()
Release the reserved number of random number, increasing the state.
State operator+=(const uint64_t &z)
Self increment.
State operator+(const uint64_t &z) const
Increment of a certain amount.
#define DEFINE_SERIALIZABLE_CLASS(T)
Shortcut to define a serializable class.
#define LIST_SERIALIZABLE_MEMBERS(...)
Defines a list of serializable members.
#define CRASH
Initialize the crasher.
State operator++()
Unitary self-increment.
Rng(const uint32_t &s=DEFAULT_SEED)
Default constructor.
#define SERIALIZABLE_SEQUENCE(CONTAINER,NAME,...)
Create a serializable sequence.
bool lock()
Lock the generator.
#define SERIALIZABLE_SEQUENCE_WITH_TAG(CONTAINER,NAME,TAG,...)
Create a serializable sequence with a given tag.
decltype(auto) operator+(T1 &&smet1, T2 &&smet2)
Implement smet1+smet2.
bool unLock()
Unlock the generator.
Holds the state of the generator.
void seed(F &f)
Draw a seed from a random generator.
ResultType generateNth(const uint64_t &offset)
Generate a number with a given offset w.r.t current state.
bool reserve(const uint64_t &n)
Reserve a number of random number.