| The Gaudi Framework v29r0 (ff2e7097)

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

- File List
- File Members

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 {
13 StatusCode status = initialize( svc, par );
14 if ( !status.isSuccess() ) {
15 throw GaudiException( "Initialization failed !", "Rndm::Numbers", status );
16 }
17 }
18
19 // Standard destructor
20 Rndm::Numbers::~Numbers() { finalize().ignore(); }
21
22 // Initialize the generator
23 StatusCode Rndm::Numbers::initialize( const SmartIF<IRndmGenSvc>& svc, const IRndmGen::Param& par )
24 {
25 if ( svc && !m_generator ) m_generator = svc->generator( par );
26 return m_generator ? StatusCode::SUCCESS : StatusCode::FAILURE;
27 }
28
29 // Initialize the generator
30 StatusCode Rndm::Numbers::finalize()
31 {
32 if ( m_generator ) {
33 m_generator->finalize().ignore();
34 m_generator.reset();
35 }
36 return StatusCode::SUCCESS;
37 }
38
39 #if !defined( GAUDI_V22_API ) || defined( G22_NEW_SVCLOCATOR )
40 // Construct and initialize the generator
41 Rndm::Numbers::Numbers( IRndmGenSvc* svc, const IRndmGen::Param& par )
42 {
43 StatusCode status = initialize( svc, par );
44 if ( !status.isSuccess() ) {
45 throw GaudiException( "Initialization failed !", "Rndm::Numbers", status );
46 }
47 }
48
49 // Initialize the generator
50 StatusCode Rndm::Numbers::initialize( IRndmGenSvc* svc, const IRndmGen::Param& par )
51 {
52 return initialize( SmartIF<IRndmGenSvc>( svc ), par );
53 }
54 #endif
StatusCode::SUCCESS
Definition: StatusCode.h:31
SmartIF< IRndmGenSvc >
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:22
Rndm::Numbers::~Numbers
virtual ~Numbers()
Standard destructor.
Definition: RndmGenerators.cpp:20
StatusCode::FAILURE
Definition: StatusCode.h:31
IRndmGen::finalize
virtual StatusCode finalize()=0
Finalize the generator.
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:75
Rndm::Numbers::m_generator
SmartIF< IRndmGen > m_generator
Pointer to random number generator.
Definition: RndmGenerators.h:400
IRndmGenSvc::generator
virtual StatusCode generator(const IRndmGen::Param &par, IRndmGen *&refpGen)=0
Add a Generator factory.
IRndmGen.h
Rndm::Numbers::finalize
virtual StatusCode finalize()
Finalization.
Definition: RndmGenerators.cpp:30
compareOutputFiles.par
string par
Definition: compareOutputFiles.py:435
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:28
IRndmGen::Param
Definition: IRndmGen.h:40
GaudiException.h
SmartIF.h
RndmGenerators.h
IRndmGenSvc.h
Rndm::Numbers::initialize
virtual StatusCode initialize(const SmartIF< IRndmGenSvc > &svc, const IRndmGen::Param &par)
Initialization.
Definition: RndmGenerators.cpp:23
SmartIF::reset
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
Definition: SmartIF.h:92
Rndm::Numbers::Numbers
Numbers()=default
Standard constructor.
StatusCode::ignore
void ignore() const
Definition: StatusCode.h:109