Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   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_params(0), m_engine(0)   {
00023   if ( 0 != engine )  {
00024     engine->queryInterface(IID_IRndmEngine, (void**)&m_engine);
00025   }
00026 }
00027 
00029 RndmGen::~RndmGen()   {
00030   if ( m_engine ) m_engine->release();
00031   m_engine = 0;
00032 }
00033 
00035 StatusCode RndmGen::queryInterface(const IID& riid, void** ppvInterface)  {
00036   if ( IID_IRndmGen == riid )   {
00037     *ppvInterface = (IRndmGen*)this;
00038   }
00039   else if ( IID_IInterface == riid )   {
00040     *ppvInterface = (IInterface*)this;
00041   }
00042   else  {
00043     return StatusCode::FAILURE;
00044   }
00045   addRef();
00046   return StatusCode::SUCCESS;
00047 }
00048 
00050 StatusCode RndmGen::initialize(const IRndmGen::Param& par)   {
00051   m_params = par.clone();
00052   return (0==m_engine) ? StatusCode::FAILURE : StatusCode::SUCCESS;
00053 }
00054 
00056 StatusCode RndmGen::finalize()   {
00057   delete m_params;
00058   m_params = 0;
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 

Generated at Wed Nov 21 12:22:31 2001 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000