All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RndmGenerators.cpp
Go to the documentation of this file.
1 // $Id: RndmGenerators.cpp,v 1.7 2006/09/13 15:25:15 hmd Exp $
2 #define GAUDI_RNDMGENSVC_RNDMGENGENERATORS_CPP
3 
4 // Framework include files
5 #include "GaudiKernel/SmartIF.h"
6 #include "GaudiKernel/IRndmGen.h"
10 
11 // Standard constructor
13 : m_generator(0)
14 {
15 }
16 
17 // Copy constructor
19 : m_generator(copy.m_generator) {
20  if ( 0 != m_generator ) {
22  }
23 }
24 
25 // Construct and initialize the generator
27 : m_generator(0)
28 {
29  StatusCode status = initialize(svc, par);
30  if (!status.isSuccess()) {
31  throw GaudiException ("Initialization failed !", "Rndm::Numbers", status);
32  }
33 }
34 
35 // Standard destructor
37  finalize().ignore();
38 }
39 
40 // Initialize the generator
42  const IRndmGen::Param& par) {
43  if ( svc.isValid() && 0 == m_generator ) {
46  return const_cast<IRndmGenSvc*>(svc.get())->generator( par, m_generator );
47  }
48  return StatusCode::FAILURE;
49 }
50 
51 // Initialize the generator
53  if ( 0 != m_generator ) {
54  m_generator->finalize().ignore();
55  m_generator->release();
56  m_generator = 0;
57  }
58  return StatusCode::SUCCESS;
59 }
60 
61 #if !defined(GAUDI_V22_API) || defined(G22_NEW_SVCLOCATOR)
62 // Construct and initialize the generator
64 : m_generator(0)
65 {
66  StatusCode status = initialize(svc, par);
67  if (!status.isSuccess()) {
68  throw GaudiException ("Initialization failed !", "Rndm::Numbers", status);
69  }
70 }
71 
72 // Initialize the generator
74  return initialize(SmartIF<IRndmGenSvc>(svc), par);
75 }
76 #endif
Define general base for Gaudi exception.
virtual ~Numbers()
Standard destructor.
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:75
Random number accessor This small class encapsulates the use of the random number generator...
virtual StatusCode finalize()
Finalization.
bool isValid() const
Allow for check if smart pointer is valid.
Definition: SmartIF.h:51
Random Generator service interface definition Definition of a interface for a service to access rando...
Definition: IRndmGenSvc.h:34
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
IRndmGen * m_generator
Pointer to random number generator.
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:62
virtual unsigned long addRef()=0
Increment the reference count of Interface instance.
virtual StatusCode initialize(const SmartIF< IRndmGenSvc > &svc, const IRndmGen::Param &par)
Initialization.
void ignore() const
Definition: StatusCode.h:107
Numbers()
Standard constructor.