| The Gaudi Framework v28r2p1 (f1a77ff4)

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