Allow calling RandomGenerator::get() on child classes (failed due to overridden overload)
This commit is contained in:
parent
233f1a2ecb
commit
6e4ecd6e19
@ -11,12 +11,12 @@ namespace cpputils {
|
||||
OSRandomGenerator();
|
||||
|
||||
protected:
|
||||
void get(void *target, size_t bytes) override;
|
||||
void _get(void *target, size_t bytes) override;
|
||||
};
|
||||
|
||||
inline OSRandomGenerator::OSRandomGenerator() {}
|
||||
|
||||
inline void OSRandomGenerator::get(void *target, size_t bytes) {
|
||||
inline void OSRandomGenerator::_get(void *target, size_t bytes) {
|
||||
CryptoPP::OS_GenerateRandomBlock(true, (byte*)target, bytes);
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ namespace cpputils {
|
||||
PseudoRandomPool();
|
||||
|
||||
protected:
|
||||
void get(void *target, size_t bytes) override;
|
||||
void _get(void *target, size_t bytes) override;
|
||||
|
||||
private:
|
||||
static constexpr size_t MIN_BUFFER_SIZE = 1*1024*1024; // 1MB
|
||||
@ -27,7 +27,7 @@ namespace cpputils {
|
||||
};
|
||||
|
||||
|
||||
inline void PseudoRandomPool::get(void *target, size_t bytes) {
|
||||
inline void PseudoRandomPool::_get(void *target, size_t bytes) {
|
||||
_buffer.get(target, bytes);
|
||||
}
|
||||
|
||||
|
@ -11,20 +11,20 @@ namespace cpputils {
|
||||
Data get(size_t size);
|
||||
|
||||
protected:
|
||||
virtual void get(void *target, size_t bytes) = 0;
|
||||
virtual void _get(void *target, size_t bytes) = 0;
|
||||
private:
|
||||
static std::mutex _mutex;
|
||||
};
|
||||
|
||||
template<size_t SIZE> inline FixedSizeData<SIZE> RandomGenerator::getFixedSize() {
|
||||
FixedSizeData<SIZE> result = FixedSizeData<SIZE>::Null();
|
||||
get(result.data(), SIZE);
|
||||
_get(result.data(), SIZE);
|
||||
return result;
|
||||
}
|
||||
|
||||
inline Data RandomGenerator::get(size_t size) {
|
||||
Data result(size);
|
||||
get(result.data(), size);
|
||||
_get(result.data(), size);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user