Visualization Library

A lightweight C++ OpenGL middleware for 2D/3D graphics
[Home] [Tutorials] [All Classes] [Grouped Classes]
Public Member Functions | Static Public Member Functions

vl::Random Class Reference

Random number generator. More...

#include <Random.hpp>

Inheritance diagram for vl::Random:
vl::Object

List of all members.

Public Member Functions

virtual const char * className ()
 Returns the name of the class.
 Random ()
 Constructor.
virtual ~Random ()
 Destructor.
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 provided by the operating system.

Static Public Member Functions

static void standardFillRandom (void *ptr, size_t bytes)
 Fills the specified buffer with random data generated using the standard rand() function.
static void standardRandomize ()
 Initializes the standard rand() random number generator using srand() with a reasonably unprobable value, based on the current time stamp and memory state.

Detailed Description

Random number generator.

Definition at line 40 of file Random.hpp.


Constructor & Destructor Documentation

Random::Random (  )

Constructor.

Definition at line 47 of file Random.cpp.

References VL_DEBUG_SET_OBJECT_NAME.

Random::~Random (  ) [virtual]

Destructor.

Definition at line 57 of file Random.cpp.


Member Function Documentation

virtual const char* vl::Random::className (  ) [inline, virtual]

Returns the name of the class.

Reimplemented from vl::Object.

Definition at line 43 of file Random.hpp.

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 provided by the operating system.

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 standardFillRandom().

Returns:
This method returns false if the function had to fallback to standardFillRandom() otherwise returns true.

Definition at line 65 of file Random.cpp.

References standardFillRandom().

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

void Random::standardFillRandom ( void *  ptr,
size_t  bytes 
) [static]

Fills the specified buffer with random data generated using the standard rand() function.

The method fillRandom() falls back to this function if no other high quality random number generation mechanism is detected.

Definition at line 93 of file Random.cpp.

References vl::Log::warning().

Referenced by fillRandom().

void Random::standardRandomize (  ) [static]

Initializes the standard rand() random number generator using srand() with a reasonably unprobable value, based on the current time stamp and memory state.

Definition at line 109 of file Random.cpp.

References vl::Time::dayOfMonth(), vl::Time::hour(), vl::Time::microsecond(), vl::Time::minute(), vl::Time::month(), vl::Time::second(), and vl::Time::year().


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

Visualization Library v2011.05.1142 Reference Documentation
Copyright 2005-2011 Michele Bosi. All rights reserved.
Updated on Thu May 26 2011 22:51:35.
Permission is granted to use this page to write and publish articles regarding Visualization Library.