| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- #pragma once
- #include <cassert>
- #include <memory>
- #include <random/forwards.h>
- namespace engine::random {
- class Random {
- private:
- std::shared_ptr<Device> impl_;
- std::shared_ptr<Tape> tape_{nullptr};
- public:
- Random();
- Random(Random const & other, Tape & with_tape);
- Random(Random const & other, std::shared_ptr<Tape> with_tape);
- template <typename P> Random(P const & p) : impl_(std::make_shared<P>(p)) {}
- template <typename P> Random(std::shared_ptr<P> const & p) : impl_(p) {}
- int32_t exclusive(int32_t min, int32_t max) const;
- int32_t inclusive(int32_t min, int32_t max) const;
- uint32_t exclusive(uint32_t min, uint32_t max) const;
- uint32_t inclusive(uint32_t min, uint32_t max) const;
- double exclusive(double min, double max) const;
- double inclusive(double min, double max) const;
- std::shared_ptr<Device> device() const { return impl_; }
- /**
- * Create a scope in which all calls to the generator functions will record
- * their results into a tape. Expects that there is no tape currently set.
- * @param tape The tape to write to
- * @return A scope object that stops recording once it is descructed
- */
- scope_exit record(std::shared_ptr<Tape> tape);
- };
- }
|