Lumiera  0.pre.03
»edit your freedom«
random.cpp
Go to the documentation of this file.
1 /*
2  random.cpp - storage and implementation for random number framework
3 
4  Copyright (C) Lumiera.org
5  2024, Hermann Vosseler <Ichthyostega@web.de>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 * *****************************************************/
22 
23 
30 #include "lib/random.hpp"
31 
32 #include <string>
33 
34 using std::string;
35 
36 
37 namespace lib {
38  namespace {
39 
40  const string ENTROPY_SOURCE_SPEC{"/dev/random"};
41 
42 
44  : public SeedNucleus
45  {
46  std::random_device entropySource_;
47 
48  uint64_t
49  getSeed() override
50  {
51  return entropySource_();
52  }
53 
54  public:
55  EntropyNucleus(string const& SPEC)
56  : entropySource_{SPEC}
57  { }
58  };
59 
61  : public SeedNucleus
62  {
63  uint64_t
64  getSeed() override
65  {
66  return LIFE_AND_UNIVERSE_4EVER;
67  }
68  };
69 
71  EntropyNucleus entropyNucleus{ENTROPY_SOURCE_SPEC};
72 
75  }
76 
77 
79 
82 
83 
84  void
86  {
89  }
90 
91 } // namespace lib
void randomise(SeedNucleus &)
inject controlled randomisation
Definition: random.hpp:124
virtual ~SeedNucleus()
this is an interface
Definition: random.cpp:78
Access point to a selection of random number sources.
Definition: random.hpp:65
EntropyNucleus entropyNucleus
static global entropy source instance
Definition: random.cpp:71
Random entropyGen
a global RandomSequencer seeded with real entropy
Definition: random.cpp:81
Implementation namespace for support and library code.
Establishes a seed point for any instance or performance.
Definition: random.hpp:49
Generating (pseudo) random numbers with controlled seed.
Random defaultGen
a global default RandomSequencer for mundane purposes
Definition: random.cpp:80
void randomiseRandomness()
inject true randomness into the defaultGen
Definition: random.cpp:85