libyggdrasil  v1.0.0
rng.hpp
Go to the documentation of this file.
1  /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2  * _____.___. .___ .__.__ *
3  * \__ | | ____ ____ __| _/___________ _____|__| | *
4  * / | |/ ___\ / ___\ / __ |\_ __ \__ \ / ___/ | | *
5  * \____ / /_/ > /_/ > /_/ | | | \// __ \_\___ \| | |__ *
6  * / ______\___ /\___ /\____ | |__| (____ /____ >__|____/ *
7  * \/ /_____//_____/ \/ \/ \/ *
8  * - Common - *
9  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
10  * This software can be used by students and other personal of the *
11  * Bern University of Applied Sciences under the terms of the MIT *
12  * license. *
13  * For other persons this software is under the terms of the GNU *
14  * General Public License version 2. *
15  * *
16  * Copyright © 2021, Bern University of Applied Sciences. *
17  * All rights reserved. *
18  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
26 #pragma once
27 
28 #include <cpp/common/registers.hpp>
30 
31 #include <array>
32 
33 namespace bsp::drv {
34 
41  template<auto Context, template<addr_t> typename RandomImpl>
42  struct Random {
43  Random() = delete;
44  Random(const Random&) = delete;
45  auto operator=(const Random&) = delete;
46 
47  using Impl = RandomImpl<Context>;
48 
55  static auto init(auto ... args) {
56  return Impl::init(args...);
57  }
58 
65  static auto deinit(auto ... args) {
66  return Impl::deinit(args...);
67  }
68 
74  template<typename T>
75  static T get() {
76  return Impl::template get<T>();
77  }
78 
79  };
80 
81 }
bsp::drv::Random::Random
Random()=delete
bsp::drv::Random::operator=
auto operator=(const Random &)=delete
registers.hpp
Zero-cost abstraction for accessing registers and bits/bitfields within them.
bsp::drv::Random::Random
Random(const Random &)=delete
bsp::drv::Random
Base class for the RNG abstraction.
Definition: rng.hpp:42
bsp::drv::Random::get
static T get()
Get random values seeded by true entropy.
Definition: rng.hpp:75
attributes.hpp
Commonly used C++ and GNU attributes.
bsp::drv
Definition: display.hpp:37
bsp::drv::Random::Impl
RandomImpl< Context > Impl
Definition: rng.hpp:47
bsp::drv::Random::deinit
static auto deinit(auto ... args)
RNG deinitialization.
Definition: rng.hpp:65
bsp::drv::Random::init
static auto init(auto ... args)
RNG initialization.
Definition: rng.hpp:55