[*] Allocless RNG devices

This commit is contained in:
Reece Wilson 2023-10-17 10:03:15 +01:00
parent 95643d6e19
commit 8fd4ef0a71
3 changed files with 20 additions and 1 deletions

View File

@ -9,6 +9,8 @@
namespace Aurora::RNG namespace Aurora::RNG
{ {
static const auto kSizeRNGDevice = 256;
struct IRandomDevice struct IRandomDevice
{ {
virtual void Read(Memory::MemoryViewWrite view) = 0; virtual void Read(Memory::MemoryViewWrite view) = 0;
@ -94,5 +96,7 @@ namespace Aurora::RNG
} }
}; };
AUKN_SHARED_API(Random, IRandomDevice, const RandomDef &def); AUKN_SHARED_SOO2(Random, IRandomDevice, kSizeRNGDevice,
((const RandomDef &, def)),
const RandomDef &def);
} }

View File

@ -10,6 +10,16 @@
namespace Aurora::RNG namespace Aurora::RNG
{ {
RandomDevice::RandomDevice()
{
}
RandomDevice::RandomDevice(const RandomDef &def)
{
this->Init(def);
}
void RandomDevice::Init(const RandomDef &def) void RandomDevice::Init(const RandomDef &def)
{ {
this->def_ = def; this->def_ = def;
@ -172,4 +182,6 @@ namespace Aurora::RNG
{ {
AuSafeDelete<RandomDevice *>(pDevice); AuSafeDelete<RandomDevice *>(pDevice);
} }
AUROXTL_INTERFACE_SOO_SRC(Random, RandomDevice, (const RandomDef &, def))
} }

View File

@ -13,6 +13,9 @@ namespace Aurora::RNG
{ {
struct RandomDevice : IRandomDevice struct RandomDevice : IRandomDevice
{ {
RandomDevice();
RandomDevice(const RandomDef & def);
void Read(Memory::MemoryViewWrite view) override; void Read(Memory::MemoryViewWrite view) override;
AuString NextString(AuUInt32 uLength, ERngStringCharacters type) override; AuString NextString(AuUInt32 uLength, ERngStringCharacters type) override;