Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
random.cpp
Go to the documentation of this file.
1/*
2 random.cpp - storage and implementation for random number framework
3
4 Copyright (C)
5 2024, Hermann Vosseler <Ichthyostega@web.de>
6
7  **Lumiera** is free software; you can redistribute it and/or modify it
8  under the terms of the GNU General Public License as published by the
9  Free Software Foundation; either version 2 of the License, or (at your
10  option) any later version. See the file COPYING for further details.
11
12* *****************************************************************/
13
14
21#include "lib/random.hpp"
22
23#include <string>
24
25using std::string;
26
27
28namespace lib {
29 namespace {
30
31 const string ENTROPY_SOURCE_SPEC{"/dev/random"};
32
33
35 : public SeedNucleus
36 {
37 std::random_device entropySource_;
38
39 uint64_t
40 getSeed() override
41 {
42 return entropySource_();
43 }
44
45 public:
46 EntropyNucleus(string const& SPEC)
47 : entropySource_{SPEC}
48 { }
49 };
50
52 : public SeedNucleus
53 {
54 uint64_t
55 getSeed() override
56 {
58 }
59 };
60
63
66
68 }
69
70 Random defaultGen{eternalNucleus};
71 Random entropyGen{entropyNucleus};
72
73 SeedNucleus&
75 {
76 return defaultNucleus;
77 }
78
79
81
82 void
84 {
85 entropyGen.reseed(entropyNucleus);
86 defaultGen.reseed(entropyNucleus);
87 }
88
89
90} // namespace lib
void reseed(SeedNucleus &)
inject controlled randomisation
Definition random.hpp:188
Establishes a seed point for any instance or performance.
Definition random.hpp:49
virtual ~SeedNucleus()
this is an interface
Definition random.cpp:80
const uint LIFE_AND_UNIVERSE_4EVER
Definition integral.hpp:39
EntropyNucleus entropyNucleus
static global entropy source instance
Definition random.cpp:62
Implementation namespace for support and library code.
SeedNucleus & seedFromDefaultGen()
draw seed another Generator from the default RandomSequencer
Definition random.cpp:74
Random entropyGen
a global RandomSequencer seeded with real entropy
Definition random.cpp:71
void randomiseRandomness()
inject true randomness into the defaultGen
Definition random.cpp:83
Random defaultGen
a global default RandomSequencer for mundane purposes
Definition random.cpp:70
Generating (pseudo) random numbers with controlled seed.