fix8  version 1.4.0
Open Source C++ FIX Framework
RandDev Struct Reference

A random number generator wrapper. More...

#include <hftest.hpp>

Static Public Member Functions

static void init ()
 Initialise the random number generator. More...
 
template<typename T >
static T getrandom (const T range=0)
 
static void init ()
 
template<typename T >
static T getrandom (const T range=0)
 

Detailed Description

A random number generator wrapper.

Definition at line 202 of file hftest.hpp.

Member Function Documentation

template<typename T >
static T RandDev::getrandom ( const T  range = 0)
inlinestatic

Return a random number between 0 and n - 1, or between 0 and RAND_MAX

Template Parameters
Ttype of random number
Parameters
rangeupper range to return value within, or 0 for RAND_MAX
Returns
the random number of the specified type within the psecifed range

Definition at line 219 of file hftest.hpp.

Referenced by MyMenu::batch_preload_new_order_single(), MyMenu::generate_new_order_single(), MyMenu::generate_new_order_single_alternate(), main(), MyMenu::new_order_single(), tex_router_server::operator()(), and MyMenu::preload_new_order_single().

220  {
221 #ifdef _MSC_VER
222  T target(rand());
223 #else
224  T target(random());
225 #endif
226  return range ? target / (RAND_MAX / range + 1) : target;
227  }
template<typename T >
static T RandDev::getrandom ( const T  range = 0)
inlinestatic

Definition at line 250 of file myfix.hpp.

251  {
252 #ifdef _MSC_VER
253  T target(rand());
254 #else
255  T target(random());
256 #endif
257  return range ? target / (RAND_MAX / range + 1) : target;
258  }
static void RandDev::init ( )
inlinestatic

Initialise the random number generator.

Definition at line 205 of file hftest.hpp.

Referenced by main().

206  {
207 #ifdef _MSC_VER
208  srand (static_cast<unsigned>(time(0) % _getpid()));
209 #else
210  srandom (static_cast<unsigned>(time(0) % getpid()));
211 #endif
212  }
static void RandDev::init ( )
inlinestatic

Definition at line 239 of file myfix.hpp.

240  {
241  time_t tval(time(0));
242 #ifdef _MSC_VER
243  srand (static_cast<unsigned>(((tval % _getpid()) * tval)));
244 #else
245  srandom (static_cast<unsigned>(((tval % getpid()) * tval)));
246 #endif
247  }

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