| # 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

# RndmEngine Class Reference

`#include <RndmEngine.h>`

Inheritance diagram for RndmEngine:

[legend]
Collaboration diagram for RndmEngine:

[legend]
List of all members.

## Detailed Description

Random Generator engine definition.

Description: Definition of a interface for a generic random number generator giving randomly distributed numbers in the range [0...1] number generators.

Dependencies:

- Generic Service interface: Gaudi/Interfaces/IRndmEngine.h

History :

        +---------+----------------------------------------------+--------+
        |    Date |                 Comment                      | Who    |
        +---------+----------------------------------------------+--------+
        | 21/04/99| Initial version.                             | MF     |
        +---------+----------------------------------------------+--------+

Author: M.Frank Version: 1.0

Definition at line 46 of file RndmEngine.h.

## Public Member Functions
StatusCode | queryInterface (const InterfaceID &riid, void **ppvInterface)
| Query interface.
virtual StatusCode | initialize ()
| Service override: initialisation.
virtual StatusCode | finalize ()
| Service override: finalisation.
virtual double | rndm () const
| Single shot returning single random number.
virtual StatusCode | rndmArray (std::vector< double > &array, long howmany, long start=0) const
| Multiple shots returning vector with flat random numbers.
virtual StreamBuffer & | serialize (StreamBuffer &str)
| Input serialisation from stream buffer.
virtual StreamBuffer & | serialize (StreamBuffer &str) const
| Output serialisation to stream buffer.
virtual void | handle (const Incident &inc)
| Inform that a new incident has occured.
## Protected Member Functions
| RndmEngine (const std::string &name, ISvcLocator *loc)
| Standard Constructor.
virtual | ~RndmEngine ()
| Standard Destructor.
## Protected Attributes
IIncidentSvc * | m_pIncidentSvc
| Reference to the incident service.

## Constructor & Destructor Documentation

RndmEngine::RndmEngine | ( | const std::string & | name,
|  | ISvcLocator * | loc |
| ) |  |  | `[protected]`

Standard Constructor.

Definition at line 31 of file RndmEngine.cpp.

    00032 : Service(name, loc), m_pIncidentSvc(0)
    00033 {
    00034 }

RndmEngine::~RndmEngine | ( |  | ) | `[protected, virtual]`

Standard Destructor.

Definition at line 37 of file RndmEngine.cpp.

References m_pIncidentSvc, and IInterface::release().

    00037                           {
    00038   if ( m_pIncidentSvc  ) m_pIncidentSvc->release();
    00039 }

## Member Function Documentation

StatusCode RndmEngine::queryInterface | ( | const InterfaceID & | riid,
|  | void ** | ppvInterface |
| ) |  |  | `[virtual]`

Query interface.

Reimplemented from Service.

Definition at line 42 of file RndmEngine.cpp.

References Service::addRef(), IID_IIncidentListener, IID_IRndmEngine, IID_ISerialize, Service::queryInterface(), and StatusCode::SUCCESS.

    00042                                                                                    {
    00043   if ( IID_IRndmEngine == riid )   {
    00044     *ppvInterface = (IRndmEngine*)this;
    00045   }
    00046   else if ( IID_ISerialize == riid )   {
    00047     *ppvInterface = (ISerialize*)this;
    00048   }
    00049   else if ( IID_IIncidentListener == riid )   {
    00050     *ppvInterface = (IIncidentListener*)this;
    00051   }
    00052   else  {
    00053     return Service::queryInterface(riid, ppvInterface);
    00054   }
    00055   addRef();
    00056   return StatusCode::SUCCESS;
    00057 }

StatusCode RndmEngine::initialize | ( |  | ) | `[virtual]`

Service override: initialisation.

Reimplemented from Service.

Reimplemented in HepRndm::Engine< TYPE >.

Definition at line 60 of file RndmEngine.cpp.

References Service::initialize(), StatusCode::isSuccess(), m_pIncidentSvc, ISvcLocator::service(), Service::serviceLocator(), and Service::setProperties().

Referenced by HepRndm::Engine< TYPE >::initialize().

    00060                                     {
    00061   StatusCode status = Service::initialize();
    00062   if ( status.isSuccess() )   {
    00063     status = setProperties();
    00064     if ( status.isSuccess() )   {
    00065       status = serviceLocator()->service( "IncidentSvc", m_pIncidentSvc, true );
    00066     }
    00067   }
    00068   return status;
    00069 }

StatusCode RndmEngine::finalize | ( |  | ) | `[virtual]`

Service override: finalisation.

Reimplemented from Service.

Reimplemented in HepRndm::Engine< TYPE >.

Definition at line 72 of file RndmEngine.cpp.

References Service::finalize(), m_pIncidentSvc, and IInterface::release().

Referenced by HepRndm::Engine< TYPE >::finalize().

    00072                                   {
    00073   StatusCode status = Service::finalize();
    00074   if ( m_pIncidentSvc )     {
    00075     m_pIncidentSvc->release();
    00076   }
    00077   m_pIncidentSvc = 0;
    00078   return status;
    00079 }

double RndmEngine::rndm | ( |  | ) | const`[virtual]`

Single shot returning single random number.

Implements IRndmEngine.

Reimplemented in HepRndm::Engine< TYPE >.

Definition at line 93 of file RndmEngine.cpp.

Referenced by rndmArray().

    00093                                 {
    00094   return DBL_MAX;
    00095 }

StatusCode RndmEngine::rndmArray | ( | std::vector< double > & | array,
|  | long | howmany,
|  | long | start = `0` |
| ) |  |  | const`[virtual]`

Multiple shots returning vector with flat random numbers.

Parameters:

  | array | Array containing random numbers
  | howmany | fill 'howmany' random numbers into array
  | start | ... starting at position start

Returns:
  StatusCode indicating failure or success.

Implements IRndmEngine.

Definition at line 107 of file RndmEngine.cpp.

References std::vector< _Tp, _Alloc >::resize(), rndm(), and StatusCode::SUCCESS.

    00107                                                                                             {
    00108   long cnt = start;
    00109   array.resize(start+howmany);
    00110   for ( long i = start, num = start+howmany; i < num; i++ )     {
    00111     array[cnt++] = rndm();
    00112   }
    00113   return StatusCode::SUCCESS;
    00114 }

StreamBuffer & RndmEngine::serialize | ( | StreamBuffer & | str | ) | `[virtual]`

Input serialisation from stream buffer.

Restores the status of the object.

Parameters:

  | str | Reference to Streambuffer to be filled

Returns:
  Reference to filled stream buffer

Implements ISerialize.

Definition at line 83 of file RndmEngine.cpp.

    00083                                                         {
    00084   return str;
    00085 }

StreamBuffer & RndmEngine::serialize | ( | StreamBuffer & | str | ) | const`[virtual]`

Output serialisation to stream buffer.

Saves the status of the object.

Parameters:

  | str | Reference to Streambuffer to be read

Returns:
  Reference to read stream buffer

Implements ISerialize.

Definition at line 88 of file RndmEngine.cpp.

    00088                                                               {
    00089   return str;
    00090 }

void RndmEngine::handle | ( | const Incident & | inc | ) | `[virtual]`

Inform that a new incident has occured.

Implements IIncidentListener.

Definition at line 98 of file RndmEngine.cpp.

    00098                                                       {
    00099 }

## Member Data Documentation

IIncidentSvc* RndmEngine::m_pIncidentSvc`[protected]`

Reference to the incident service.

Definition at line 53 of file RndmEngine.h.

Referenced by finalize(), initialize(), and ~RndmEngine().

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

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v20r2/GaudiSvc/v17r1/src/RndmGenSvc/RndmEngine.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v20r2/GaudiSvc/v17r1/src/RndmGenSvc/RndmEngine.cpp