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)
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 
25 using std::string;
26 
27 
28 namespace 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  {
57  return LIFE_AND_UNIVERSE_4EVER;
58  }
59  };
60 
62  EntropyNucleus entropyNucleus{ENTROPY_SOURCE_SPEC};
63 
66 
67  Random::Seed defaultNucleus{defaultGen};
68  }
69 
72 
75  {
76  return defaultNucleus;
77  }
78 
79 
81 
82  void
84  {
87  }
88 
89 
90 } // namespace lib
virtual ~SeedNucleus()
this is an interface
Definition: random.cpp:80
EntropyNucleus entropyNucleus
static global entropy source instance
Definition: random.cpp:62
Random entropyGen
a global RandomSequencer seeded with real entropy
Definition: random.cpp:71
Implementation namespace for support and library code.
SeedNucleus & seedFromDefaultGen()
draw seed another Generator from the default RandomSequencer
Definition: random.cpp:74
void reseed(SeedNucleus &)
inject controlled randomisation
Definition: random.hpp:188
Establishes a seed point for any instance or performance.
Definition: random.hpp:48
Generating (pseudo) random numbers with controlled seed.
Random defaultGen
a global default RandomSequencer for mundane purposes
Definition: random.cpp:70
void randomiseRandomness()
inject true randomness into the defaultGen
Definition: random.cpp:83