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

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

- Search for |

- File List
- File Members

# RndmEngine.cpp

Go to the documentation of this file.

    00001 //====================================================================
    00002 //      Random Engine implementation
    00003 //--------------------------------------------------------------------
    00004 //
    00005 //      Package    : Gaudi/RndmGen ( The LHCb Offline System)
    00006 //      Author     : M.Frank
    00007 //  History    :
    00008 // +---------+----------------------------------------------+---------
    00009 // |    Date |                 Comment                      | Who
    00010 // +---------+----------------------------------------------+---------
    00011 // | 29/10/99| Initial version                              | MF
    00012 // +---------+----------------------------------------------+---------
    00013 //
    00014 //====================================================================
    00015 #define GAUDI_RANDOMGENSVC_RndmEngine_CPP
    00016
    00017 // STL include files
    00018 #include <cfloat>
    00019
    00020 // Framework include files
    00021 #include "GaudiKernel/IMessageSvc.h"
    00022 #include "GaudiKernel/ISvcLocator.h"
    00023 #include "GaudiKernel/IIncidentSvc.h"
    00024 #include "GaudiKernel/IOpaqueAddress.h"
    00025 #include "GaudiKernel/IDataProviderSvc.h"
    00026 #include "GaudiKernel/DataObject.h"
    00027 #include "GaudiKernel/MsgStream.h"
    00028 #include "RndmEngine.h"
    00029
    00031 RndmEngine::RndmEngine(const std::string& name, ISvcLocator* loc)
    00032 : Service(name, loc), m_pIncidentSvc(0)
    00033 {
    00034 }
    00035
    00037 RndmEngine::~RndmEngine()   {
    00038   if ( m_pIncidentSvc  ) m_pIncidentSvc->release();
    00039 }
    00040
    00042 StatusCode RndmEngine::queryInterface(const InterfaceID& riid, void** ppvInterface)  {
    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 }
    00058
    00060 StatusCode RndmEngine::initialize()   {
    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 }
    00070
    00072 StatusCode RndmEngine::finalize()   {
    00073   StatusCode status = Service::finalize();
    00074   if ( m_pIncidentSvc )     {
    00075     m_pIncidentSvc->release();
    00076   }
    00077   m_pIncidentSvc = 0;
    00078   return status;
    00079 }
    00080
    00082
    00083 StreamBuffer& RndmEngine::serialize(StreamBuffer& str)    {
    00084   return str;
    00085 }
    00086
    00088 StreamBuffer& RndmEngine::serialize(StreamBuffer& str) const    {
    00089   return str;
    00090 }
    00091
    00093 double RndmEngine::rndm() const   {
    00094   return DBL_MAX;
    00095 }
    00096
    00098 void RndmEngine::handle (const Incident& /* inc */ )    {
    00099 }
    00100
    00107 StatusCode RndmEngine::rndmArray( std::vector<double>& array, long howmany, long start) const   {
    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 }
    00115