| # Gaudi Framework, version v20r2
Generated: 18 Jul 2008

- Main Page
- Namespaces
- Classes
- Files
- Directories
- Related Pages

- Search for |

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# Rndm::Numbers Class Reference

`#include <RndmGenerators.h>`

Collaboration diagram for Rndm::Numbers:

[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
IRndmGen * | m_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.

References IInterface::addRef(), and m_generator.

    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.

References initialize(), and StatusCode::isSuccess().

    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.

References finalize(), and StatusCode::ignore().

    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.

References StatusCode::FAILURE, IRndmGenSvc::generator(), and m_generator.

Referenced by Numbers().

    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 | ( |  | ) | `[virtual]`

Finalization.

Definition at line 51 of file RndmGenerators.cpp.

References IRndmGen::finalize(), StatusCode::ignore(), m_generator, IInterface::release(), and StatusCode::SUCCESS.

Referenced by ~Numbers().

    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.

References m_generator.

    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.

References shoot().

    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.

References shoot().

    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.

References m_generator, and IRndmGen::shoot().

Referenced by operator()(), and pop().

    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.

References StatusCode::FAILURE, m_generator, and IRndmGen::shootArray().

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

## Member Data Documentation

IRndmGen* Rndm::Numbers::m_generator`[protected]`

Pointer to random number generator.

Definition at line 391 of file RndmGenerators.h.

Referenced by finalize(), initialize(), Numbers(), operator bool(), shoot(), and shootArray().

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

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v20r2/GaudiKernel/v25r2/GaudiKernel/RndmGenerators.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v20r2/GaudiKernel/v25r2/src/Lib/RndmGenerators.cpp