diff options
| author | jacqueline <me@jacqueline.id.au> | 2023-07-17 16:54:35 +1000 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2023-07-17 16:54:35 +1000 |
| commit | 7197da21f6bcc1aaa5d1905228e0e2ec1caf3fa8 (patch) | |
| tree | f24f81cba08160d45d7e994dc31f48506e823e49 /src/util/include/random.hpp | |
| parent | b6bc6b9e47605ede9bffe50445d1afe3acf0ab49 (diff) | |
| download | tangara-fw-7197da21f6bcc1aaa5d1905228e0e2ec1caf3fa8.tar.gz | |
Basic playlists for upcoming
Beware under-testing and bugs. Just getting something barebones in so
that I can do rN+1 bringup
Diffstat (limited to 'src/util/include/random.hpp')
| -rw-r--r-- | src/util/include/random.hpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/util/include/random.hpp b/src/util/include/random.hpp new file mode 100644 index 00000000..cd8ab1c6 --- /dev/null +++ b/src/util/include/random.hpp @@ -0,0 +1,39 @@ +/* + * Copyright 2023 jacqueline <me@jacqueline.id.au> + * + * SPDX-License-Identifier: GPL-3.0-only + */ + +#pragma once + +#include <cstdint> + +#include "komihash.h" + +namespace util { + +class IRandom { + public: + virtual ~IRandom() {} + + virtual auto Next() -> std::uint64_t = 0; + virtual auto RangeInclusive(std::uint64_t lower, std::uint64_t upper) + -> std::uint64_t = 0; +}; + +extern IRandom* sRandom; + +class Random : public IRandom { + public: + Random(); + + auto Next() -> std::uint64_t override; + auto RangeInclusive(std::uint64_t lower, std::uint64_t upper) + -> std::uint64_t override; + + private: + std::uint64_t seed1_; + std::uint64_t seed2_; +}; + +} // namespace util |
