The Gaudi Framework  master (82fdf313)
Loading...
Searching...
No Matches
HiveNumbers.cpp
Go to the documentation of this file.
1/***********************************************************************************\
2* (c) Copyright 1998-2025 CERN for the benefit of the LHCb and ATLAS collaborations *
3* *
4* This software is distributed under the terms of the Apache version 2 licence, *
5* copied verbatim in the file "LICENSE". *
6* *
7* In applying this licence, CERN does not waive the privileges and immunities *
8* granted to it by virtue of its status as an Intergovernmental Organization *
9* or submit itself to any jurisdiction. *
10\***********************************************************************************/
11// Framework include files
12#include "HiveNumbers.h"
16#include <GaudiKernel/SmartIF.h>
17
18namespace {
19 constexpr double HIVENUMBERS_BUFFER_SIZE = 1000;
20}
21
23
24// Standard constructor
26 m_buffer.reserve( m_buffer_size );
27}
28
29// Copy constructor
31 : m_buffer_index( 0 ), m_buffer_size( HIVENUMBERS_BUFFER_SIZE ), m_generator( copy.m_generator ) {
32 m_buffer.reserve( m_buffer_size );
33 if ( 0 != m_generator ) { m_generator->addRef(); }
34}
35
36// Construct and initialize the generator
38 : m_buffer_index( 0 ), m_buffer_size( HIVENUMBERS_BUFFER_SIZE ), m_generator( 0 ) {
39 m_buffer.reserve( m_buffer_size );
40 StatusCode status = initialize( svc, par );
41 if ( !status.isSuccess() ) { throw GaudiException( "Initialization failed !", "HiveRndm::HiveNumbers", status ); }
42}
43
44// Standard destructor
46
47// Initialize the generator
49 if ( svc.isValid() && 0 == m_generator ) {
52 return svc->generator( par, m_generator );
53 }
55}
56
57// Initialize the generator
59 if ( 0 != m_generator ) {
60 m_generator->finalize().ignore();
61 m_generator->release();
62 m_generator = 0;
63 }
65}
Define general base for Gaudi exception.
const unsigned int m_buffer_size
Definition HiveNumbers.h:40
virtual ~HiveNumbers()
Standard destructor.
unsigned int m_buffer_index
Definition HiveNumbers.h:39
virtual StatusCode finalize()
Finalization.
virtual StatusCode initialize(const SmartIF< IRndmGenSvc > &svc, const IRndmGen::Param &par)
Initialization.
IRndmGen * m_generator
Pointer to random number generator.
Definition HiveNumbers.h:46
static HiveNumbersMutex m_genMutex
Definition HiveNumbers.h:42
HiveNumbers()
Standard constructor.
std::vector< double > m_buffer
Definition HiveNumbers.h:41
Small smart pointer class with automatic reference counting for IInterface.
Definition SmartIF.h:28
bool isValid() const
Allow for check if smart pointer is valid.
Definition SmartIF.h:69
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64
bool isSuccess() const
Definition StatusCode.h:314
constexpr static const auto SUCCESS
Definition StatusCode.h:99
constexpr static const auto FAILURE
Definition StatusCode.h:100
tbb::spin_rw_mutex HiveNumbersMutex
Definition HiveNumbers.h:35