14#ifndef ARCANE_IRANDOMNUMBERGENERATOR_H
15#define ARCANE_IRANDOMNUMBERGENERATOR_H
20#include "arcane/utils/Array.h"
90 memcpy(m_seed.data(), &value_in, std::min(m_seed.size(), (
Integer)
sizeof(T)));
91 for (
Integer i =
sizeof(T); i < m_seed.size(); i++) {
108 bool value(T& value_out,
bool without_size_check =
true)
const
110 if (m_seed.empty() || (!without_size_check &&
sizeof(T) != m_seed.size())) {
114 memcpy(&value_out, m_seed.data(), std::min(m_seed.size(), (
Integer)
sizeof(T)));
129 bool value(T* value_out,
bool without_size_check =
true)
const
131 if (m_seed.empty() || (
sizeof(T) != m_seed.size() && !without_size_check)) {
135 memcpy(value_out, m_seed.data(), std::min(m_seed.size(), (
Integer)
sizeof(T)));
146 return m_seed.size();
156 return m_seed.constView();
Declarations of types used in Arcane.
Interface for a random number generator.
virtual ByteConstArrayView viewSeed()=0
Method allowing retrieval of a constant view of the current seed.
virtual ByteUniqueArray emptySeed()=0
Method allowing retrieval of an empty seed of the correct size.
virtual Real generateRandomNumber(ByteArrayView seed, Integer leap=0)=0
Method allowing generation of a random number using the seed passed as a parameter.
virtual ByteUniqueArray generateRandomSeed(Integer leap=0)=0
Method allowing generation of a "child" seed from a "parent" seed.
virtual bool isLeapSeedSupported()=0
Method allowing knowledge if leaps are allowed on the seed generator.
virtual Real generateRandomNumber(Integer leap=0)=0
Method allowing generation of a random number using the seed in memory.
virtual ByteUniqueArray generateRandomSeed(ByteArrayView parent_seed, Integer leap=0)=0
Method allowing generation of a "child" seed from a "parent" seed.
virtual bool isLeapNumberSupported()=0
Method allowing knowledge if leaps are allowed on the number generator.
virtual bool initSeed(ByteArrayView seed)=0
Method allowing initialization of the service.
virtual Integer neededSizeOfSeed()=0
Method allowing knowledge of the seed size required for the implementation.
virtual bool initSeed()=0
Method allowing initialization of the service.
Class allowing easy manipulation of a seed.
bool value(T &value_out, bool without_size_check=true) const
Method allowing retrieval of the seed value.
Integer sizeOfSeed() const
Method allowing retrieval of the seed size.
bool setValue(T value_in)
Method allowing setting a value in the seed.
ByteConstArrayView constView() const
Method allowing retrieval of a constant view.
ByteUniqueArray copy()
Method allowing retrieval of a copy of the Byte array.
bool value(T *value_out, bool without_size_check=true) const
Method allowing retrieval of the seed value.
ByteArrayView view()
Method allowing retrieval of a view.
RNGSeedHelper(T *var)
Class constructor.
RNGSeedHelper(ByteArrayView av)
Class constructor.
RNGSeedHelper & operator=(T new_value)
Copy operator from a seed value.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
ArrayView< Byte > ByteArrayView
C equivalent of a 1D array of characters.
Int32 Integer
Type representing an integer.
UniqueArray< Byte > ByteUniqueArray
Dynamic 1D array of characters.
double Real
Type representing a real number.
ConstArrayView< Byte > ByteConstArrayView
C equivalent of a 1D array of characters.
unsigned char Byte
Type of a byte.