| The Gaudi Framework v32r1 (f65d50dc)

RndmGenerators.cpp
Go to the documentation of this file.
1 #define GAUDI_RNDMGENSVC_RNDMGENGENERATORS_CPP
2
3 // Framework include files
4 #include "GaudiKernel/RndmGenerators.h"
5 #include "GaudiKernel/GaudiException.h"
6 #include "GaudiKernel/IRndmGen.h"
7 #include "GaudiKernel/IRndmGenSvc.h"
8 #include "GaudiKernel/SmartIF.h"
9
10 // Construct and initialize the generator
11 Rndm::Numbers::Numbers( const SmartIF<IRndmGenSvc>& svc, const IRndmGen::Param& par ) {
12 StatusCode status = initialize( svc, par );
13 if ( !status.isSuccess() ) { throw GaudiException( "Initialization failed !", "Rndm::Numbers", status ); }
14 }
15
16 // Standard destructor
17 Rndm::Numbers::~Numbers() { finalize().ignore(); }
18
19 // Initialize the generator
20 StatusCode Rndm::Numbers::initialize( const SmartIF<IRndmGenSvc>& svc, const IRndmGen::Param& par ) {
21 if ( svc && !m_generator ) m_generator = svc->generator( par );
22 return m_generator ? StatusCode::SUCCESS : StatusCode::FAILURE;
23 }
24
25 // Initialize the generator
26 StatusCode Rndm::Numbers::finalize() {
27 if ( m_generator ) {
28 m_generator->finalize().ignore();
29 m_generator.reset();
30 }
31 return StatusCode::SUCCESS;
32 }
33
34 #if !defined( GAUDI_V22_API ) || defined( G22_NEW_SVCLOCATOR )
35 // Construct and initialize the generator
36 Rndm::Numbers::Numbers( IRndmGenSvc* svc, const IRndmGen::Param& par ) {
37 StatusCode status = initialize( svc, par );
38 if ( !status.isSuccess() ) { throw GaudiException( "Initialization failed !", "Rndm::Numbers", status ); }
39 }
40
41 // Initialize the generator
42 StatusCode Rndm::Numbers::initialize( IRndmGenSvc* svc, const IRndmGen::Param& par ) {
43 return initialize( SmartIF<IRndmGenSvc>( svc ), par );
44 }
45 #endif
SmartIF< IRndmGenSvc >
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:21
Rndm::Numbers::~Numbers
virtual ~Numbers()
Standard destructor.
Definition: RndmGenerators.cpp:17
IRndmGenSvc::generator
virtual StatusCode generator(const IRndmGen::Param &par, IRndmGen *&refpGen)=0
Add a Generator factory.
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
IRndmGen.h
Rndm::Numbers::finalize
virtual StatusCode finalize()
Finalization.
Definition: RndmGenerators.cpp:26
compareOutputFiles.par
string par
Definition: compareOutputFiles.py:465
IRndmGenSvc
Random Generator service interface definition Definition of a interface for a service to access rando...
Definition: IRndmGenSvc.h:35
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
IRndmGen::Param
Definition: IRndmGen.h:39
GaudiException.h
SmartIF.h
StatusCode::isSuccess
bool isSuccess() const
Definition: StatusCode.h:267
RndmGenerators.h
StatusCode::ignore
const StatusCode & ignore() const
Ignore/check StatusCode.
Definition: StatusCode.h:153
IRndmGenSvc.h
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:86
Rndm::Numbers::initialize
virtual StatusCode initialize(const SmartIF< IRndmGenSvc > &svc, const IRndmGen::Param &par)
Initialization.
Definition: RndmGenerators.cpp:20
Rndm::Numbers::Numbers
Numbers()=default
Standard constructor.