| The Gaudi Framework v27r1

- 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
SmartIF< IRndmGenSvc >
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:23
Rndm::Numbers::~Numbers
virtual ~Numbers()
Standard destructor.
Definition: RndmGenerators.cpp:22
AnalysisTest.initialize
def initialize()
Definition: AnalysisTest.py:12
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
IRndmGenSvc::generator
virtual StatusCode generator(const IRndmGen::Param &par, IRndmGen *&refpGen)=0
Add a Generator factory.
IRndmGen.h
compareOutputFiles.par
string par
Definition: compareOutputFiles.py:386
Rndm::Numbers::finalize
virtual StatusCode finalize()
Finalization.
Definition: RndmGenerators.cpp:34
StatusCode::FAILURE
Definition: StatusCode.h:29
IRndmGenSvc
Random Generator service interface definition Definition of a interface for a service to access rando...
Definition: IRndmGenSvc.h:35
StatusCode::SUCCESS
Definition: StatusCode.h:30
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
Rndm::Numbers::Numbers
Numbers()=default
Standard constructor.
StatusCode::ignore
void ignore() const
Definition: StatusCode.h:108