| The Gaudi Framework v29r0 (ff2e7097)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Protected Attributes | Private Attributes | Static Private Attributes | List of all members
HiveRndm::HiveNumbers Class Reference

`#include <src/HiveNumbers.h>`

Collaboration diagram for HiveRndm::HiveNumbers:
[legend]

## Public Member Functions
| HiveNumbers ()
| Standard constructor. More...
| HiveNumbers (const HiveNumbers &copy)
| Copy constructor. More...
| HiveNumbers (const SmartIF< IRndmGenSvc > &svc, const IRndmGen::Param &par)
| Initializing constructor. More...
virtual | ~HiveNumbers ()
| Standard destructor. More...
virtual StatusCode | initialize (const SmartIF< IRndmGenSvc > &svc, const IRndmGen::Param &par)
| Initialization. More...
| HiveNumbers (IRndmGenSvc *svc, const IRndmGen::Param &par)
| Initializing constructor. More...
virtual StatusCode | initialize (IRndmGenSvc *svc, const IRndmGen::Param &par)
| Initialization. More...
virtual StatusCode | finalize ()
| Finalization. More...
| operator bool () const
| Check if the number supply is possible. More...
double | operator() ()
| Operator () for the use within STL. More...
double | pop ()
| Pop a new number from the buffer. More...
double | shoot ()
| Pop a new number from the buffer. More...
StatusCode | shootArray (std::vector< double > &array, long num, long start=0)
| Pop a new number from the buffer. More...

## Protected Attributes
IRndmGen * | m_generator
| Pointer to random number generator. More...

## Private Attributes
unsigned int | m_buffer_index
const unsigned int | m_buffer_size
std::vector< double > | m_buffer

## Static Private Attributes
static HiveNumbersMutex | m_genMutex

## Detailed Description

Definition at line 29 of file HiveNumbers.h.

## Constructor & Destructor Documentation

HiveRndm::HiveNumbers::HiveNumbers | ( |  | ) |

Standard constructor.

Definition at line 16 of file HiveNumbers.cpp.

16 : m_buffer_index( 0 ), m_buffer_size( HIVENUMBERS_BUFFER_SIZE ), m_generator( 0 )
17 {
18 m_buffer.reserve( m_buffer_size );
19 }
HiveRndm::HiveNumbers::m_buffer_size
const unsigned int m_buffer_size
Definition: HiveNumbers.h:33
HiveRndm::HiveNumbers::m_buffer
std::vector< double > m_buffer
Definition: HiveNumbers.h:34
HiveRndm::HiveNumbers::m_generator
IRndmGen * m_generator
Pointer to random number generator.
Definition: HiveNumbers.h:39
HiveRndm::HiveNumbers::m_buffer_index
unsigned int m_buffer_index
Definition: HiveNumbers.h:32
std::vector::reserve
T reserve(T...args)

HiveRndm::HiveNumbers::HiveNumbers | ( | const HiveNumbers & | copy | ) |

Copy constructor.

Definition at line 22 of file HiveNumbers.cpp.

23 : m_buffer_index( 0 ), m_buffer_size( HIVENUMBERS_BUFFER_SIZE ), m_generator( copy.m_generator )
24 {
25 m_buffer.reserve( m_buffer_size );
26 if ( 0 != m_generator ) {
27 m_generator->addRef();
28 }
29 }
HiveRndm::HiveNumbers::m_buffer_size
const unsigned int m_buffer_size
Definition: HiveNumbers.h:33
std::copy
T copy(T...args)
HiveRndm::HiveNumbers::m_buffer
std::vector< double > m_buffer
Definition: HiveNumbers.h:34
HiveRndm::HiveNumbers::m_generator
IRndmGen * m_generator
Pointer to random number generator.
Definition: HiveNumbers.h:39
IInterface::addRef
virtual unsigned long addRef()=0
Increment the reference count of Interface instance.
HiveRndm::HiveNumbers::m_buffer_index
unsigned int m_buffer_index
Definition: HiveNumbers.h:32
std::vector::reserve
T reserve(T...args)

HiveRndm::HiveNumbers::HiveNumbers | ( | const SmartIF< IRndmGenSvc > & | svc,
|  | const IRndmGen::Param & | par
| ) |  |

Initializing constructor.

Definition at line 32 of file HiveNumbers.cpp.

33 : m_buffer_index( 0 ), m_buffer_size( HIVENUMBERS_BUFFER_SIZE ), m_generator( 0 )
34 {
35 m_buffer.reserve( m_buffer_size );
36 StatusCode status = initialize( svc, par );
37 if ( !status.isSuccess() ) {
38 throw GaudiException( "Initialization failed !", "HiveRndm::HiveNumbers", status );
39 }
40 }
HiveRndm::HiveNumbers::m_buffer_size
const unsigned int m_buffer_size
Definition: HiveNumbers.h:33
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:22
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:75
HiveRndm::HiveNumbers::m_buffer
std::vector< double > m_buffer
Definition: HiveNumbers.h:34
HiveRndm::HiveNumbers::m_generator
IRndmGen * m_generator
Pointer to random number generator.
Definition: HiveNumbers.h:39
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
HiveRndm::HiveNumbers::initialize
virtual StatusCode initialize(const SmartIF< IRndmGenSvc > &svc, const IRndmGen::Param &par)
Initialization.
Definition: HiveNumbers.cpp:46
HiveRndm::HiveNumbers::m_buffer_index
unsigned int m_buffer_index
Definition: HiveNumbers.h:32
std::vector::reserve
T reserve(T...args)

HiveRndm::HiveNumbers::~HiveNumbers | ( |  | ) |
| virtual

Standard destructor.

Definition at line 43 of file HiveNumbers.cpp.

43 { finalize().ignore(); }
HiveRndm::HiveNumbers::finalize
virtual StatusCode finalize()
Finalization.
Definition: HiveNumbers.cpp:57
StatusCode::ignore
void ignore() const
Definition: StatusCode.h:109

HiveRndm::HiveNumbers::HiveNumbers | ( | IRndmGenSvc * | svc,
|  | const IRndmGen::Param & | par
| ) |  |

Initializing constructor.

Definition at line 69 of file HiveNumbers.cpp.

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 }
HiveRndm::HiveNumbers::m_buffer_size
const unsigned int m_buffer_size
Definition: HiveNumbers.h:33
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:22
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:75
HiveRndm::HiveNumbers::m_generator
IRndmGen * m_generator
Pointer to random number generator.
Definition: HiveNumbers.h:39
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
HiveRndm::HiveNumbers::initialize
virtual StatusCode initialize(const SmartIF< IRndmGenSvc > &svc, const IRndmGen::Param &par)
Initialization.
Definition: HiveNumbers.cpp:46
HiveRndm::HiveNumbers::m_buffer_index
unsigned int m_buffer_index
Definition: HiveNumbers.h:32

## Member Function Documentation

StatusCode HiveRndm::HiveNumbers::finalize | ( |  | ) |
| virtual

Finalization.

Definition at line 57 of file HiveNumbers.cpp.

58 {
59 if ( 0 != m_generator ) {
60 m_generator->finalize().ignore();
61 m_generator->release();
62 m_generator = 0;
63 }
64 return StatusCode::SUCCESS;
65 }
StatusCode::SUCCESS
Definition: StatusCode.h:31
IRndmGen::finalize
virtual StatusCode finalize()=0
Finalize the generator.
HiveRndm::HiveNumbers::m_generator
IRndmGen * m_generator
Pointer to random number generator.
Definition: HiveNumbers.h:39
IInterface::release
virtual unsigned long release()=0
Release Interface instance.
StatusCode::ignore
void ignore() const
Definition: StatusCode.h:109

StatusCode HiveRndm::HiveNumbers::initialize | ( | const SmartIF< IRndmGenSvc > & | svc,
|  | const IRndmGen::Param & | par
| ) |  |
| virtual

Initialization.

Fix-Me:
  : this is a hack, but I do not have the time to review the correct constantness of all the methods

Definition at line 46 of file HiveNumbers.cpp.

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 }
StatusCode::FAILURE
Definition: StatusCode.h:31
SmartIF::get
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:82
HiveRndm::HiveNumbers::m_generator
IRndmGen * m_generator
Pointer to random number generator.
Definition: HiveNumbers.h:39
IRndmGenSvc
Random Generator service interface definition Definition of a interface for a service to access rando...
Definition: IRndmGenSvc.h:35
SmartIF::isValid
bool isValid() const
Allow for check if smart pointer is valid.
Definition: SmartIF.h:68

StatusCode HiveRndm::HiveNumbers::initialize | ( | IRndmGenSvc * | svc,
|  | const IRndmGen::Param & | par
| ) |  |
| virtual

Initialization.

Definition at line 79 of file HiveNumbers.cpp.

80 {
81 return initialize( SmartIF<IRndmGenSvc>( svc ), par );
82 }
SmartIF< IRndmGenSvc >
HiveRndm::HiveNumbers::initialize
virtual StatusCode initialize(const SmartIF< IRndmGenSvc > &svc, const IRndmGen::Param &par)
Initialization.
Definition: HiveNumbers.cpp:46

HiveRndm::HiveNumbers::operator bool | ( |  | ) | const
| inline

Check if the number supply is possible.

Definition at line 61 of file HiveNumbers.h.

61 { return m_generator != 0; }
HiveRndm::HiveNumbers::m_generator
IRndmGen * m_generator
Pointer to random number generator.
Definition: HiveNumbers.h:39

double HiveRndm::HiveNumbers::operator() | ( | void |  | ) |
| inline

Operator () for the use within STL.

Definition at line 63 of file HiveNumbers.h.

63 { return this->shoot(); }
HiveRndm::HiveNumbers::shoot
double shoot()
Pop a new number from the buffer.
Definition: HiveNumbers.h:67

double HiveRndm::HiveNumbers::pop | ( |  | ) |
| inline

Pop a new number from the buffer.

Definition at line 65 of file HiveNumbers.h.

65 { return this->shoot(); }
HiveRndm::HiveNumbers::shoot
double shoot()
Pop a new number from the buffer.
Definition: HiveNumbers.h:67

double HiveRndm::HiveNumbers::shoot | ( |  | ) |
| inline

Pop a new number from the buffer.

Definition at line 67 of file HiveNumbers.h.

68 {
69 if ( 0 != m_generator ) {
70 if ( m_buffer_index == 0 ) { // we are out of numbers
71 this->shootArray( m_buffer, m_buffer_size );
72 m_buffer_index = m_buffer_size - 1;
73 }
74 const double number = m_buffer[m_buffer_index];
75 m_buffer_index--;
76 return number;
77 }
78 return -1;
79 }
HiveRndm::HiveNumbers::m_buffer_size
const unsigned int m_buffer_size
Definition: HiveNumbers.h:33
HiveRndm::HiveNumbers::m_buffer
std::vector< double > m_buffer
Definition: HiveNumbers.h:34
HiveRndm::HiveNumbers::m_generator
IRndmGen * m_generator
Pointer to random number generator.
Definition: HiveNumbers.h:39
HiveRndm::HiveNumbers::shootArray
StatusCode shootArray(std::vector< double > &array, long num, long start=0)
Pop a new number from the buffer.
Definition: HiveNumbers.h:81
HiveRndm::HiveNumbers::m_buffer_index
unsigned int m_buffer_index
Definition: HiveNumbers.h:32

StatusCode HiveRndm::HiveNumbers::shootArray | ( | std::vector< double > & | array,
|  | long | num,
|  | long | start = `0`
| ) |  |
| inline

Pop a new number from the buffer.

Definition at line 81 of file HiveNumbers.h.

82 {
83 if ( 0 != m_generator ) {
84 StatusCode status;
85 {
86 HiveNumbersMutex::scoped_lock lock( m_genMutex );
87 status = m_generator->shootArray( array, num, start );
88 }
89 return status;
90 }
91 return StatusCode::FAILURE;
92 }
StatusCode::FAILURE
Definition: StatusCode.h:31
HiveRndm::HiveNumbers::m_generator
IRndmGen * m_generator
Pointer to random number generator.
Definition: HiveNumbers.h:39
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
std::lock
T lock(T...args)
IOTest.start
start
Definition: IOTest.py:99
IRndmGen::shootArray
virtual StatusCode shootArray(std::vector< double > &array, long howmany, long start=0) const =0
Multiple shots returning vector with random number according to specified distribution.
HiveRndm::HiveNumbers::m_genMutex
static HiveNumbersMutex m_genMutex
Definition: HiveNumbers.h:35

## Member Data Documentation

std::vector<double> HiveRndm::HiveNumbers::m_buffer
| private

Definition at line 34 of file HiveNumbers.h.

unsigned int HiveRndm::HiveNumbers::m_buffer_index
| private

Definition at line 32 of file HiveNumbers.h.

const unsigned int HiveRndm::HiveNumbers::m_buffer_size
| private

Definition at line 33 of file HiveNumbers.h.

IRndmGen* HiveRndm::HiveNumbers::m_generator
| protected

Pointer to random number generator.

Definition at line 39 of file HiveNumbers.h.

HiveRndm::HiveNumbersMutex HiveRndm::HiveNumbers::m_genMutex
| static private

Definition at line 35 of file HiveNumbers.h.

The documentation for this class was generated from the following files:

- GaudiHive/src/HiveNumbers.h
- GaudiHive/src/HiveNumbers.cpp