| # Gaudi Framework, version v22r4 |

Home |  | Generated: Fri Sep 2 2011

# RndmGenerators.cpp

Go to the documentation of this file.

    00001 // $Id: RndmGenerators.cpp,v 1.7 2006/09/13 15:25:15 hmd Exp $
    00002 #define GAUDI_RNDMGENSVC_RNDMGENGENERATORS_CPP
    00003
    00004 // Framework include files
    00005 #include "GaudiKernel/SmartIF.h"
    00006 #include "GaudiKernel/IRndmGen.h"
    00007 #include "GaudiKernel/IRndmGenSvc.h"
    00008 #include "GaudiKernel/RndmGenerators.h"
    00009 #include "GaudiKernel/GaudiException.h"
    00010
    00011 // Standard constructor
    00012 Rndm::Numbers::Numbers()
    00013 : m_generator(0)
    00014 {
    00015 }
    00016
    00017 // Copy constructor
    00018 Rndm::Numbers::Numbers(const Rndm::Numbers& copy )
    00019 : m_generator(copy.m_generator)   {
    00020   if ( 0 != m_generator )   {
    00021     m_generator->addRef();
    00022   }
    00023 }
    00024
    00025 // Construct and initialize the generator
    00026 Rndm::Numbers::Numbers(const SmartIF<IRndmGenSvc>& svc, const IRndmGen::Param& par)
    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 }
    00034
    00035 // Standard destructor
    00036 Rndm::Numbers::~Numbers()    {
    00037   finalize().ignore();
    00038 }
    00039
    00040 // Initialize the generator
    00041 StatusCode Rndm::Numbers::initialize(const SmartIF<IRndmGenSvc>& svc,
    00042                                      const IRndmGen::Param& par)  {
    00043   if ( svc.isValid() && 0 == m_generator )   {
    00046     return const_cast<IRndmGenSvc*>(svc.get())->generator( par, m_generator );
    00047   }
    00048   return StatusCode::FAILURE;
    00049 }
    00050
    00051 // Initialize the generator
    00052 StatusCode Rndm::Numbers::finalize()   {
    00053   if ( 0 != m_generator )   {
    00054     m_generator->finalize().ignore();
    00055     m_generator->release();
    00056     m_generator = 0;
    00057   }
    00058   return StatusCode::SUCCESS;
    00059 }
    00060
    00061 #if !defined(GAUDI_V22_API) || defined(G22_NEW_SVCLOCATOR)
    00062 // Construct and initialize the generator
    00063 Rndm::Numbers::Numbers(IRndmGenSvc* svc, const IRndmGen::Param& par)
    00064 : m_generator(0)
    00065 {
    00066   StatusCode status = initialize(svc, par);
    00067   if (!status.isSuccess()) {
    00068     throw GaudiException ("Initialization failed !", "Rndm::Numbers", status);
    00069   }
    00070 }
    00071
    00072 // Initialize the generator
    00073 StatusCode Rndm::Numbers::initialize(IRndmGenSvc* svc, const IRndmGen::Param& par) {
    00074   return initialize(SmartIF<IRndmGenSvc>(svc), par);
    00075 }
    00076 #endif

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines