| The Gaudi Framework v27r1

- 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 28 of file HiveNumbers.h.

## Constructor & Destructor Documentation

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

Standard constructor.

Definition at line 15 of file HiveNumbers.cpp.

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

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

Copy constructor.

Definition at line 24 of file HiveNumbers.cpp.

25 : m_buffer_index(0),
26 m_buffer_size(HIVENUMBERS_BUFFER_SIZE),
27 m_generator(copy.m_generator){
28 m_buffer.reserve(m_buffer_size);
29 if ( 0 != m_generator ) {
30 m_generator->addRef();
31 }
32 }
HiveRndm::HiveNumbers::m_buffer_size
const unsigned int m_buffer_size
Definition: HiveNumbers.h:31
std::copy
T copy(T...args)
HiveRndm::HiveNumbers::m_buffer
std::vector< double > m_buffer
Definition: HiveNumbers.h:32
HiveRndm::HiveNumbers::m_generator
IRndmGen * m_generator
Pointer to random number generator.
Definition: HiveNumbers.h:36
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:30
std::vector::reserve
T reserve(T...args)

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

Initializing constructor.

Definition at line 35 of file HiveNumbers.cpp.

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

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

Standard destructor.

Definition at line 48 of file HiveNumbers.cpp.

48 {
49 finalize().ignore();
50 }
HiveRndm::HiveNumbers::finalize
virtual StatusCode finalize()
Finalization.
Definition: HiveNumbers.cpp:64
StatusCode::ignore
void ignore() const
Definition: StatusCode.h:108

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

Initializing constructor.

Definition at line 75 of file HiveNumbers.cpp.

76 : m_buffer_index(0),
77 m_buffer_size(HIVENUMBERS_BUFFER_SIZE),
78 m_generator(0)
79 {
80 StatusCode status = initialize(svc, par);
81 if (!status.isSuccess()) {
82 throw GaudiException ("Initialization failed !", "HiveRndm::HiveNumbers", status);
83 }
84 }
HiveRndm::HiveNumbers::m_buffer_size
const unsigned int m_buffer_size
Definition: HiveNumbers.h:31
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:23
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
HiveRndm::HiveNumbers::m_generator
IRndmGen * m_generator
Pointer to random number generator.
Definition: HiveNumbers.h:36
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
HiveRndm::HiveNumbers::initialize
virtual StatusCode initialize(const SmartIF< IRndmGenSvc > &svc, const IRndmGen::Param &par)
Initialization.
Definition: HiveNumbers.cpp:53
HiveRndm::HiveNumbers::m_buffer_index
unsigned int m_buffer_index
Definition: HiveNumbers.h:30

## Member Function Documentation

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

Finalization.

Definition at line 64 of file HiveNumbers.cpp.

64 {
65 if ( 0 != m_generator ) {
66 m_generator->finalize().ignore();
67 m_generator->release();
68 m_generator = 0;
69 }
70 return StatusCode::SUCCESS;
71 }
IRndmGen::finalize
virtual StatusCode finalize()=0
Finalize the generator.
HiveRndm::HiveNumbers::m_generator
IRndmGen * m_generator
Pointer to random number generator.
Definition: HiveNumbers.h:36
StatusCode::SUCCESS
Definition: StatusCode.h:30
IInterface::release
virtual unsigned long release()=0
Release Interface instance.
StatusCode::ignore
void ignore() const
Definition: StatusCode.h:108

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 53 of file HiveNumbers.cpp.

54 {
55 if ( svc.isValid() && 0 == m_generator ) {
58 return const_cast<IRndmGenSvc*>(svc.get())->generator( par, m_generator );
59 }
60 return StatusCode::FAILURE;
61 }
SmartIF::get
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:76
HiveRndm::HiveNumbers::m_generator
IRndmGen * m_generator
Pointer to random number generator.
Definition: HiveNumbers.h:36
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
SmartIF::isValid
bool isValid() const
Allow for check if smart pointer is valid.
Definition: SmartIF.h:62

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

Initialization.

Definition at line 87 of file HiveNumbers.cpp.

87 {
88 return initialize(SmartIF<IRndmGenSvc>(svc), par);
89 }
SmartIF< IRndmGenSvc >
HiveRndm::HiveNumbers::initialize
virtual StatusCode initialize(const SmartIF< IRndmGenSvc > &svc, const IRndmGen::Param &par)
Initialization.
Definition: HiveNumbers.cpp:53

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

Check if the number supply is possible.

Definition at line 57 of file HiveNumbers.h.

57 {
58 return m_generator != 0;
59 }
HiveRndm::HiveNumbers::m_generator
IRndmGen * m_generator
Pointer to random number generator.
Definition: HiveNumbers.h:36

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

Operator () for the use within STL.

Definition at line 61 of file HiveNumbers.h.

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

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

Pop a new number from the buffer.

Definition at line 65 of file HiveNumbers.h.

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

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

Pop a new number from the buffer.

Definition at line 69 of file HiveNumbers.h.

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

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

Pop a new number from the buffer.

Definition at line 82 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 }
HiveRndm::HiveNumbers::m_generator
IRndmGen * m_generator
Pointer to random number generator.
Definition: HiveNumbers.h:36
StatusCode::FAILURE
Definition: StatusCode.h:29
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
locker.lock
def lock(file)
Definition: locker.py:16
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:33
IOTest.start
tuple start
Definition: IOTest.py:88

## Member Data Documentation

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

Definition at line 32 of file HiveNumbers.h.

unsigned int HiveRndm::HiveNumbers::m_buffer_index
| private

Definition at line 30 of file HiveNumbers.h.

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

Definition at line 31 of file HiveNumbers.h.

IRndmGen* HiveRndm::HiveNumbers::m_generator
| protected

Pointer to random number generator.

Definition at line 36 of file HiveNumbers.h.

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

Definition at line 33 of file HiveNumbers.h.

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

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