Menge
Modular Pedestrian Simulation Framework for Research and Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Protected Attributes | Friends | List of all members
Menge::Math::UniformFloatGenerator Class Reference

A FloatGenerator which returns a uniformly distributed value within a defined range. More...

#include <RandGenerator.h>

Inheritance diagram for Menge::Math::UniformFloatGenerator:
Menge::Math::FloatGenerator

Public Member Functions

 UniformFloatGenerator (float minVal, float maxVal, int seed=0)
 Constructor. More...
 
 UniformFloatGenerator (const UniformFloatGenerator &gen)
 Copy constructor. More...
 
virtual float getValue () const
 Return a value based on the float generation rules. More...
 
virtual float getValueConcurrent () const
 Return a value based on the float generation rules - performed in a thread-safe manner. More...
 
virtual void print (Logger &out) const
 Function for converting the generator to a string on a output stream. More...
 
virtual FloatGeneratorcopy () const
 Create a copy of itself. More...
 
float getMin () const
 Reports the lower end of the valid range. More...
 
float getMax () const
 Reports the upper end of the valid range. More...
 
float getSize () const
 Reports the size of the interval. More...
 
- Public Member Functions inherited from Menge::Math::FloatGenerator
 FloatGenerator ()
 Constructor.
 
virtual ~FloatGenerator ()
 Virtual destructor.
 

Protected Attributes

float _min
 The lower end of the valid range.
 
float _size
 The size of the valid range.
 
int _seed
 A seed for the random number generator.
 
SimpleLock _lock
 The lock for guaranteeing threadsafe random number generation.
 

Friends

Loggeroperator<< (Logger &out, const UniformFloatGenerator &gen)
 Friend function for writing string representation to an output stream. More...
 

Detailed Description

A FloatGenerator which returns a uniformly distributed value within a defined range.

Constructor & Destructor Documentation

Menge::Math::UniformFloatGenerator::UniformFloatGenerator ( float  minVal,
float  maxVal,
int  seed = 0 
)

Constructor.

The value will lie within the range [minVal, maxVal]. All values in that range have equal probability of being selected.

Parameters
minValThe lower end of the valid range.
maxValThe upper end of the valid range.
seedIf the seed is zero, the global seed will be used otherwise the particular seed will be used.
Menge::Math::UniformFloatGenerator::UniformFloatGenerator ( const UniformFloatGenerator gen)

Copy constructor.

The copy is not a perfect copy - the seed value in the new float generator is NOT the same as the source.

Parameters
genThe generator to copy

Member Function Documentation

FloatGenerator * Menge::Math::UniformFloatGenerator::copy ( ) const
virtual

Create a copy of itself.

Returns
A pointer to a new generator which is a copy of this one. The caller of this function is responsible for freeing up the memory for the copy.

Implements Menge::Math::FloatGenerator.

float Menge::Math::UniformFloatGenerator::getMax ( ) const
inline

Reports the upper end of the valid range.

Returns
The upper end of the valid range.
float Menge::Math::UniformFloatGenerator::getMin ( ) const
inline

Reports the lower end of the valid range.

Returns
The lower end of the valid range.
float Menge::Math::UniformFloatGenerator::getSize ( ) const
inline

Reports the size of the interval.

Returns
The size of the interval.
float Menge::Math::UniformFloatGenerator::getValue ( ) const
virtual

Return a value based on the float generation rules.

Returns
A clamped, uniformly-distributed float value.

Implements Menge::Math::FloatGenerator.

float Menge::Math::UniformFloatGenerator::getValueConcurrent ( ) const
virtual

Return a value based on the float generation rules - performed in a thread-safe manner.

This is the basic functionality that must be overwridden by derived classes.

Returns
A float value.

Implements Menge::Math::FloatGenerator.

void Menge::Math::UniformFloatGenerator::print ( Logger out) const
virtual

Function for converting the generator to a string on a output stream.

Parameters
outThe output stream to write the string representation to.

Implements Menge::Math::FloatGenerator.

Friends And Related Function Documentation

Logger& operator<< ( Logger out,
const UniformFloatGenerator gen 
)
friend

Friend function for writing string representation to an output stream.

Parameters
outThe output stream.
genAn instance of the generator to represent as a string.
Returns
Reference to the input output stream.

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