Gaudi Framework, version v20r4

Generated: 8 Jan 2009

Rndm::Numbers Class Reference

#include <RndmGenerators.h>

Collaboration diagram for Rndm::Numbers:

Collaboration graph
[legend]

List of all members.


Detailed Description

Random number accessor This small class encapsulates the use of the random number generator.

The sole pupose of this class is to hide the usage of the interface and make the whole thing more user friendly. The object is usable directly after creation.

The typical usage is: Rndm::Numbers numbers(); if ( numbers.initialize(rndmGenSvc, Rndm::Gauss(0.5,0.2)).isSuccess() ) { for ( int i = 0; i < 10; i++ ) { value = numbers(); ... } }

Definition at line 388 of file RndmGenerators.h.


Public Member Functions

 Numbers ()
 Standard constructor.
 Numbers (const Numbers &copy)
 Copy constructor.
 Numbers (IRndmGenSvc *svc, const IRndmGen::Param &par)
 Initializing constructor.
virtual ~Numbers ()
 Standard destructor.
virtual StatusCode initialize (IRndmGenSvc *svc, const IRndmGen::Param &par)
 Initialization.
virtual StatusCode finalize ()
 Finalization.
 operator bool () const
 Check if the number supply is possible.
double operator() ()
 Operator () for the use within STL.
double pop ()
 Pop a new number from the buffer.
double shoot ()
 Pop a new number from the buffer.
StatusCode shootArray (std::vector< double > &array, long num, long start=0)
 Pop a new number from the buffer.

Protected Attributes

IRndmGenm_generator
 Pointer to random number generator.

Constructor & Destructor Documentation

Rndm::Numbers::Numbers (  ) 

Standard constructor.

Definition at line 12 of file RndmGenerators.cpp.

00013 : m_generator(0)
00014 {
00015 }

Rndm::Numbers::Numbers ( const Numbers copy  ) 

Copy constructor.

Definition at line 18 of file RndmGenerators.cpp.

00019 : m_generator(copy.m_generator)   {
00020   if ( 0 != m_generator )   {
00021     m_generator->addRef();
00022   }
00023 }

Rndm::Numbers::Numbers ( IRndmGenSvc svc,
const IRndmGen::Param par 
)

Initializing constructor.

Definition at line 26 of file RndmGenerators.cpp.

00027 : m_generator(0) 
00028 {
00029   StatusCode status = initialize(svc, par);
00030   if (!status.isSuccess()) {
00031     throw GaudiException ("Initialization failed !", "Rndm::Numbers", status);
00032   }
00033 }

Rndm::Numbers::~Numbers (  )  [virtual]

Standard destructor.

Definition at line 36 of file RndmGenerators.cpp.

00036                          {
00037   finalize().ignore();
00038 }


Member Function Documentation

StatusCode Rndm::Numbers::initialize ( IRndmGenSvc svc,
const IRndmGen::Param par 
) [virtual]

Initialization.

Definition at line 41 of file RndmGenerators.cpp.

00042                                                                 {
00043   if ( 0 != svc && 0 == m_generator )   {
00044     StatusCode status = svc->generator( par, m_generator );
00045     return status;
00046   }
00047   return StatusCode::FAILURE;
00048 }

StatusCode Rndm::Numbers::finalize ( void   )  [virtual]

Finalization.

Definition at line 51 of file RndmGenerators.cpp.

00051                                    {
00052   if ( 0 != m_generator )   {
00053     m_generator->finalize().ignore();
00054     m_generator->release();
00055     m_generator = 0;
00056   }
00057   return StatusCode::SUCCESS;
00058 }

Rndm::Numbers::operator bool (  )  const [inline]

Check if the number supply is possible.

Definition at line 406 of file RndmGenerators.h.

00406                               {
00407       return m_generator != 0;
00408     }

double Rndm::Numbers::operator() (  )  [inline]

Operator () for the use within STL.

Definition at line 410 of file RndmGenerators.h.

00410                            {
00411       return this->shoot();
00412     }

double Rndm::Numbers::pop (  )  [inline]

Pop a new number from the buffer.

Definition at line 414 of file RndmGenerators.h.

00414                     {
00415       return this->shoot();
00416     }

double Rndm::Numbers::shoot (  )  [inline]

Pop a new number from the buffer.

Definition at line 418 of file RndmGenerators.h.

00418                       {
00419       if ( 0 != m_generator )   {
00420         return m_generator->shoot();
00421       }
00422       return -1;
00423     }

StatusCode Rndm::Numbers::shootArray ( std::vector< double > &  array,
long  num,
long  start = 0 
) [inline]

Pop a new number from the buffer.

Definition at line 425 of file RndmGenerators.h.

00425                                                                              {
00426       if ( 0 != m_generator )   {
00427         return m_generator->shootArray(array, num, start);
00428       }
00429       return StatusCode::FAILURE;
00430     }


Member Data Documentation

Pointer to random number generator.

Definition at line 391 of file RndmGenerators.h.


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

Generated at Thu Jan 8 17:54:21 2009 for Gaudi Framework, version v20r4 by Doxygen version 1.5.6 written by Dimitri van Heesch, © 1997-2004