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

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

- Search for |

- File List
- File Members

# 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(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(IRndmGenSvc* svc,
    00042                                      const IRndmGen::Param& par)  {
    00043   if ( 0 != svc && 0 == m_generator )   {
    00044     StatusCode status = svc->generator( par, m_generator );
    00045     return status;
    00046   }
    00047   return StatusCode::FAILURE;
    00048 }
    00049
    00050 // Initialize the generator
    00051 StatusCode Rndm::Numbers::finalize()   {
    00052   if ( 0 != m_generator )   {
    00053     m_generator->finalize().ignore();
    00054     m_generator->release();
    00055     m_generator = 0;
    00056   }
    00057   return StatusCode::SUCCESS;
    00058 }
    00059