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

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

- Search for |

- File List
- File Members

# RndmGen.cpp

Go to the documentation of this file.

    00001 //====================================================================
    00002 //      Random RndmGen class implementation
    00003 //--------------------------------------------------------------------
    00004 //
    00005 //      Package    : Gaudi/RndmGen ( The LHCb Offline System)
    00006 //      Author     : M.Frank
    00007 //  History    :
    00008 //  +---------+----------------------------------------------+--------+
    00009 //  |    Date |                 Comment                      | Who    |
    00010 //  +---------+----------------------------------------------+--------+
    00011 //  | 21/11/99| Initial version.                             | MF     |
    00012 //  +---------+----------------------------------------------+--------+
    00013 //====================================================================
    00014 #define GAUDI_RANDOMGENSVC_RNDMGEN_CPP
    00015
    00016 #include <cfloat>
    00017 #include "GaudiKernel/ISvcLocator.h"
    00018 #include "GaudiKernel/IRndmEngine.h"
    00019 #include "RndmGen.h"
    00020
    00022 RndmGen::RndmGen(IInterface* engine) : m_refCount(0), m_params(0), m_engine(0)   {
    00023   if ( 0 != engine )  {
    00024     engine->queryInterface(IID_IRndmEngine, pp_cast<void>(&m_engine)).ignore();
    00025   }
    00026 }
    00027
    00029 RndmGen::~RndmGen()   {
    00030   if ( m_engine ) m_engine->release();
    00031   m_engine = 0;
    00032   if ( m_params ) delete m_params;
    00033   m_params = 0;
    00034 }
    00035
    00037 StatusCode RndmGen::queryInterface(const InterfaceID& riid, void** ppvInterface)  {
    00038   if ( IID_IRndmGen == riid )   {
    00039     *ppvInterface = (IRndmGen*)this;
    00040   }
    00041   else if ( IID_IInterface == riid )   {
    00042     *ppvInterface = (IInterface*)this;
    00043   }
    00044   else  {
    00045     return StatusCode::FAILURE;
    00046   }
    00047   addRef();
    00048   return StatusCode::SUCCESS;
    00049 }
    00050
    00052 StatusCode RndmGen::initialize(const IRndmGen::Param& par)   {
    00053   m_params = par.clone();
    00054   return (0==m_engine) ? StatusCode::FAILURE : StatusCode::SUCCESS;
    00055 }
    00056
    00058 StatusCode RndmGen::finalize()   {
    00059   return StatusCode::SUCCESS;
    00060 }
    00061
    00063 double RndmGen::shoot()  const  {
    00064   return DBL_MAX;
    00065 }
    00066
    00068 StatusCode RndmGen::shootArray( std::vector<double>& array, long howmany, long start) const {
    00069   if ( 0 != m_engine )    {
    00070     long cnt = start;
    00071     array.resize(start+howmany);
    00072     for ( long i = start, num = start+howmany; i < num; i++ )     {
    00073       array[cnt++] = shoot();
    00074     }
    00075     return StatusCode::SUCCESS;
    00076   }
    00077   return StatusCode::FAILURE;
    00078 }
    00079