Visualization Library 2.0.0-b3

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
Public Member Functions | List of all members
vl::Random Class Reference

Cryptographic random number generator. More...

#include <Random.hpp>

+ Inheritance diagram for vl::Random:

Public Member Functions

 Random ()
 Constructor. More...
 
virtual ~Random ()
 Destructor. More...
 
virtual bool fillRandom (void *ptr, size_t bytes) const
 Fills the specified buffer with random data generated using the best quality random number generation facilities available. More...
 
void fillRandomMersenneTwister (void *ptr, size_t bytes) const
 Fills the specified buffer with random data generated using a defMersienneTwister(). More...
 
- Public Member Functions inherited from vl::Object
 Object ()
 Constructor. More...
 
 Object (const Object &other)
 Copy constructor: copies the name, ref count mutex and user data. More...
 
Objectoperator= (const Object &other)
 Copy operator: copies the object's name, ref count mutex and user data. More...
 
const std::string & objectName () const
 The name of the object, by default set to the object's class name. More...
 
void setObjectName (const char *name)
 The name of the object, by default set to the object's class name in debug builds. More...
 
void setObjectName (const std::string &name)
 The name of the object, by default set to the object's class name in debug builds. More...
 
void setRefCountMutex (IMutex *mutex)
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
IMutexrefCountMutex ()
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
const IMutexrefCountMutex () const
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
int referenceCount () const
 Returns the number of references of an object. More...
 
void incReference () const
 Increments the reference count of an object. More...
 
void decReference ()
 Decrements the reference count of an object and deletes it if both automaticDelete() is true the count reaches 0. More...
 
void setAutomaticDelete (bool autodel_on)
 If set to true the Object is deleted when its reference count reaches 0. More...
 
bool automaticDelete () const
 If set to true the Object is deleted when its reference count reaches 0. More...
 
template<class T >
T * as ()
 Casts an Object to the specified class. More...
 
template<class T >
const T * as () const
 Casts an Object to the specified class. More...
 

Additional Inherited Members

- Protected Member Functions inherited from vl::Object
virtual ~Object ()
 
- Protected Attributes inherited from vl::Object
std::string mObjectName
 
IMutexmRefCountMutex
 
int mReferenceCount
 
bool mAutomaticDelete
 

Detailed Description

Cryptographic random number generator.

For non-ryptographic fast and high quality random number generation use vl::MersenneTwister.

Definition at line 41 of file Random.hpp.

Constructor & Destructor Documentation

◆ Random()

Random::Random ( )

Constructor.

Definition at line 45 of file Random.cpp.

References NULL.

◆ ~Random()

Random::~Random ( )
virtual

Destructor.

Definition at line 57 of file Random.cpp.

References NULL.

Member Function Documentation

◆ fillRandom()

bool Random::fillRandom ( void *  ptr,
size_t  bytes 
) const
virtual

Fills the specified buffer with random data generated using the best quality random number generation facilities available.

Under Windows (including MinGW) CryptGenRandom is used, while under Unix-like operating systems /dev/urandom is used. If no special random number generation facility is detected the function falls back to use a MersenneTwister.

Returns
This method returns false if the function had to fallback to MersenneTwister otherwise returns true.

Definition at line 74 of file Random.cpp.

References fillRandomMersenneTwister().

Referenced by vl::UUID::generateVersion4().

◆ fillRandomMersenneTwister()

void Random::fillRandomMersenneTwister ( void *  ptr,
size_t  bytes 
) const

Fills the specified buffer with random data generated using a defMersienneTwister().

MersienneTwister produces high quality random number and can be much faster than fillRandom().

Definition at line 98 of file Random.cpp.

References vl::defMersenneTwister(), and vl::MersenneTwister::randInt().

Referenced by fillRandom().


The documentation for this class was generated from the following files: