The Gaudi Framework  v30r3 (a5ef0a68)
HiveNumbers.cpp
Go to the documentation of this file.
1 // Framework include files
2 #include "HiveNumbers.h"
4 #include "GaudiKernel/IRndmGen.h"
6 #include "GaudiKernel/SmartIF.h"
7 
8 namespace
9 {
10  constexpr double HIVENUMBERS_BUFFER_SIZE = 1000;
11 }
12 
14 
15 // Standard constructor
16 HiveRndm::HiveNumbers::HiveNumbers() : m_buffer_index( 0 ), m_buffer_size( HIVENUMBERS_BUFFER_SIZE ), m_generator( 0 )
17 {
19 }
20 
21 // Copy constructor
23  : m_buffer_index( 0 ), m_buffer_size( HIVENUMBERS_BUFFER_SIZE ), m_generator( copy.m_generator )
24 {
26  if ( 0 != m_generator ) {
28  }
29 }
30 
31 // Construct and initialize the generator
33  : m_buffer_index( 0 ), m_buffer_size( HIVENUMBERS_BUFFER_SIZE ), m_generator( 0 )
34 {
36  StatusCode status = initialize( svc, par );
37  if ( !status.isSuccess() ) {
38  throw GaudiException( "Initialization failed !", "HiveRndm::HiveNumbers", status );
39  }
40 }
41 
42 // Standard destructor
44 
45 // Initialize the generator
47 {
48  if ( svc.isValid() && 0 == m_generator ) {
51  return const_cast<IRndmGenSvc*>( svc.get() )->generator( par, m_generator );
52  }
53  return StatusCode::FAILURE;
54 }
55 
56 // Initialize the generator
58 {
59  if ( 0 != m_generator ) {
62  m_generator = 0;
63  }
64  return StatusCode::SUCCESS;
65 }
66 
67 #if !defined( GAUDI_V22_API ) || defined( G22_NEW_SVCLOCATOR )
68 // Construct and initialize the generator
70  : m_buffer_index( 0 ), m_buffer_size( HIVENUMBERS_BUFFER_SIZE ), m_generator( 0 )
71 {
72  StatusCode status = initialize( svc, par );
73  if ( !status.isSuccess() ) {
74  throw GaudiException( "Initialization failed !", "HiveRndm::HiveNumbers", status );
75  }
76 }
77 #endif
78 // Initialize the generator
80 {
81  return initialize( SmartIF<IRndmGenSvc>( svc ), par );
82 }
const unsigned int m_buffer_size
Definition: HiveNumbers.h:33
constexpr static const auto FAILURE
Definition: StatusCode.h:88
virtual StatusCode finalize()
Finalization.
Definition: HiveNumbers.cpp:57
Define general base for Gaudi exception.
tbb::spin_rw_mutex_v3 HiveNumbersMutex
Definition: HiveNumbers.h:27
virtual StatusCode finalize()=0
Finalize the generator.
bool isSuccess() const
Definition: StatusCode.h:287
std::vector< double > m_buffer
Definition: HiveNumbers.h:34
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:82
IRndmGen * m_generator
Pointer to random number generator.
Definition: HiveNumbers.h:39
Random Generator service interface definition Definition of a interface for a service to access rando...
Definition: IRndmGenSvc.h:35
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
virtual ~HiveNumbers()
Standard destructor.
Definition: HiveNumbers.cpp:43
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
virtual unsigned long release()=0
Release Interface instance.
bool isValid() const
Allow for check if smart pointer is valid.
Definition: SmartIF.h:68
const StatusCode & ignore() const
Ignore/check StatusCode.
Definition: StatusCode.h:165
virtual StatusCode initialize(const SmartIF< IRndmGenSvc > &svc, const IRndmGen::Param &par)
Initialization.
Definition: HiveNumbers.cpp:46
virtual unsigned long addRef()=0
Increment the reference count of Interface instance.
unsigned int m_buffer_index
Definition: HiveNumbers.h:32
HiveNumbers()
Standard constructor.
Definition: HiveNumbers.cpp:16
static HiveNumbersMutex m_genMutex
Definition: HiveNumbers.h:35
T reserve(T...args)