All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RndmGenSvc Class Reference

Random Generator service definition. More...

#include <src/RndmGenSvc/RndmGenSvc.h>

Inheritance diagram for RndmGenSvc:
Collaboration diagram for RndmGenSvc:

Public Member Functions

 RndmGenSvc (const std::string &name, ISvcLocator *svc)
 Standard Service constructor.
 
virtual ~RndmGenSvc ()
 Standard Service destructor.
 
virtual StatusCode initialize ()
 Service override: initialization.
 
virtual StatusCode finalize ()
 Service override: finalization.
 
virtual StreamBufferserialize (StreamBuffer &str)
 IRndmGenSvc interface implementation.
 
virtual StreamBufferserialize (StreamBuffer &str) const
 Output serialization to stream buffer. Saves the status of the generator engine.
 
virtual IRndmEngineengine ()
 Retrieve engine.
 
virtual StatusCode generator (const IRndmGen::Param &par, IRndmGen *&refpGen)
 Retrieve a valid generator from the service.
 
virtual double rndm () const
 Single shot returning single random number.
 
virtual StatusCode rndmArray (std::vector< double > &array, long howmany, long start=0) const
 Multiple shots returning vector with flat random numbers.
 
virtual StatusCode setSeeds (const std::vector< long > &seeds)
 Allow to set new seeds.
 
virtual StatusCode seeds (std::vector< long > &seeds) const
 Allow to get seeds.
 
- Public Member Functions inherited from extends3< Service, IRndmGenSvc, IRndmEngine, ISerialize >
 extends3 (A1 a1, A2 a2, A3 a3)
 Templated constructor with 3 arguments.
 
 extends3 (A1 a1, A2 a2)
 Templated constructor with 2 arguments.
 
 extends3 (A1 a1)
 Templated constructor with 1 argument.
 
 extends3 ()
 Default constructor.
 
 extends3 (A1 a1, A2 a2, A3 a3)
 Templated constructor with 3 arguments.
 
 extends3 (A1 a1, A2 a2)
 Templated constructor with 2 arguments.
 
 extends3 (A1 a1)
 Templated constructor with 1 argument.
 
 extends3 ()
 Default constructor.
 
virtual void * i_cast (const InterfaceID &tid) const
 Implementation of IInterface::i_cast.
 
virtual void * i_cast (const InterfaceID &tid) const
 Implementation of IInterface::i_cast.
 
virtual StatusCode queryInterface (const InterfaceID &ti, void **pp)
 Implementation of IInterface::queryInterface.
 
virtual StatusCode queryInterface (const InterfaceID &ti, void **pp)
 Implementation of IInterface::queryInterface.
 
virtual std::vector< std::string > getInterfaceNames () const
 Implementation of IInterface::getInterfaceNames.
 
virtual std::vector< std::string > getInterfaceNames () const
 Implementation of IInterface::getInterfaceNames.
 
virtual ~extends3 ()
 Virtual destructor.
 
virtual ~extends3 ()
 Virtual destructor.
 
- Public Member Functions inherited from Service
virtual unsigned long release ()
 Release Interface instance.
 
virtual const std::string & name () const
 Retrieve name of the service.
 
virtual StatusCode configure ()
 
virtual StatusCode start ()
 
virtual StatusCode stop ()
 
virtual StatusCode terminate ()
 
virtual Gaudi::StateMachine::State FSMState () const
 
virtual Gaudi::StateMachine::State targetFSMState () const
 
virtual StatusCode reinitialize ()
 
virtual StatusCode restart ()
 
virtual StatusCode sysInitialize ()
 Initialize Service.
 
virtual StatusCode sysStart ()
 Initialize Service.
 
virtual StatusCode sysStop ()
 Initialize Service.
 
virtual StatusCode sysFinalize ()
 Finalize Service.
 
virtual StatusCode sysReinitialize ()
 Re-initialize the Service.
 
virtual StatusCode sysRestart ()
 Re-initialize the Service.
 
virtual StatusCode setProperty (const Property &p)
 
virtual StatusCode setProperty (const std::string &s)
 
virtual StatusCode setProperty (const std::string &n, const std::string &v)
 
virtual StatusCode getProperty (Property *p) const
 
virtual const PropertygetProperty (const std::string &name) const
 
virtual StatusCode getProperty (const std::string &n, std::string &v) const
 
virtual const std::vector
< Property * > & 
getProperties () const
 
template<class TYPE >
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value
 
 Service (const std::string &name, ISvcLocator *svcloc)
 Standard Constructor.
 
SmartIF< ISvcLocator > & serviceLocator () const
 Retrieve pointer to service locator.
 
StatusCode setProperties ()
 Method for setting declared properties to the values specified for the job.
 
template<class T >
StatusCode service (const std::string &name, const T *&psvc, bool createIf=true) const
 Access a service by name, creating it if it doesn't already exist.
 
template<class T >
StatusCode service (const std::string &name, T *&psvc, bool createIf=true) const
 
template<class T >
StatusCode service (const std::string &svcType, const std::string &svcName, T *&psvc) const
 Access a service by name and type, creating it if it doesn't already exist.
 
template<class T >
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
 Declare the named property.
 
PropertydeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
 Declare remote named properties.
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked.
 
virtual unsigned long release ()
 Release Interface instance.
 
virtual const std::string & name () const
 Retrieve name of the service.
 
virtual StatusCode configure ()
 
virtual StatusCode start ()
 
virtual StatusCode stop ()
 
virtual StatusCode terminate ()
 
virtual Gaudi::StateMachine::State FSMState () const
 
virtual Gaudi::StateMachine::State targetFSMState () const
 
virtual StatusCode reinitialize ()
 
virtual StatusCode restart ()
 
virtual StatusCode sysInitialize ()
 Initialize Service.
 
virtual StatusCode sysStart ()
 Initialize Service.
 
virtual StatusCode sysStop ()
 Initialize Service.
 
virtual StatusCode sysFinalize ()
 Finalize Service.
 
virtual StatusCode sysReinitialize ()
 Re-initialize the Service.
 
virtual StatusCode sysRestart ()
 Re-initialize the Service.
 
virtual StatusCode setProperty (const Property &p)
 
virtual StatusCode setProperty (const std::string &s)
 
virtual StatusCode setProperty (const std::string &n, const std::string &v)
 
virtual StatusCode getProperty (Property *p) const
 
virtual const PropertygetProperty (const std::string &name) const
 
virtual StatusCode getProperty (const std::string &n, std::string &v) const
 
virtual const std::vector
< Property * > & 
getProperties () const
 
template<class TYPE >
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value
 
 Service (const std::string &name, ISvcLocator *svcloc)
 Standard Constructor.
 
SmartIF< ISvcLocator > & serviceLocator () const
 Retrieve pointer to service locator.
 
StatusCode setProperties ()
 Method for setting declared properties to the values specified for the job.
 
template<class T >
StatusCode service (const std::string &name, const T *&psvc, bool createIf=true) const
 Access a service by name, creating it if it doesn't already exist.
 
template<class T >
StatusCode service (const std::string &name, T *&psvc, bool createIf=true) const
 
template<class T >
StatusCode service (const std::string &svcType, const std::string &svcName, T *&psvc) const
 Access a service by name and type, creating it if it doesn't already exist.
 
template<class T >
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
 Declare the named property.
 
PropertydeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
 Declare remote named properties.
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked.
 
- Public Member Functions inherited from CommonMessaging< implements3< IService, IProperty, IStateful > >
 CommonMessaging (const A1 &a1, const A2 &a2, const A3 &a3)
 Templated constructor with 3 arguments.
 
 CommonMessaging (const A1 &a1, const A2 &a2)
 Templated constructor with 2 arguments.
 
 CommonMessaging (const A1 &a1)
 Templated constructor with 1 argument.
 
 CommonMessaging ()
 Default constructor.
 
 CommonMessaging (const A1 &a1, const A2 &a2, const A3 &a3)
 Templated constructor with 3 arguments.
 
 CommonMessaging (const A1 &a1, const A2 &a2)
 Templated constructor with 2 arguments.
 
 CommonMessaging (const A1 &a1)
 Templated constructor with 1 argument.
 
 CommonMessaging ()
 Default constructor.
 
virtual ~CommonMessaging ()
 Virtual destructor.
 
virtual ~CommonMessaging ()
 Virtual destructor.
 
SmartIF< IMessageSvc > & msgSvc () const
 The standard message service.
 
SmartIF< IMessageSvc > & msgSvc () const
 The standard message service.
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream.
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts.
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream.
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts.
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS)
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS)
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL)
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL)
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR)
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR)
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR)
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR)
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING)
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING)
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO)
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO)
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG)
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG)
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE)
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE)
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO)
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO)
 
MSG::Level msgLevel () const
 get the output level from the embedded MsgStream
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream
 
MSG::Level msgLevel () const
 get the output level from the embedded MsgStream
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream
 
- Public Member Functions inherited from extend_interfaces3< I1, I2, I3 >
virtual ~extend_interfaces3 ()
 Virtual destructor.
 
virtual ~extend_interfaces3 ()
 Virtual destructor.
 

Private Attributes

IRndmEnginem_engine
 Random number engine.
 
ISerializem_serialize
 Serialization interface of random number engine.
 
std::string m_engineName
 Engine name.
 

Additional Inherited Members

- Public Types inherited from extends3< Service, IRndmGenSvc, IRndmEngine, ISerialize >
typedef extends3 base_class
 Typedef to this class.
 
typedef extends3 base_class
 Typedef to this class.
 
typedef extend_interfaces3
< IRndmGenSvc, IRndmEngine,
ISerialize
extend_interfaces_base
 Typedef to the base of this class.
 
typedef extend_interfaces3
< IRndmGenSvc, IRndmEngine,
ISerialize
extend_interfaces_base
 Typedef to the base of this class.
 
typedef
extend_interfaces_base::ext_iids 
interfaces
 MPL set of all the implemented interfaces.
 
typedef
extend_interfaces_base::ext_iids 
interfaces
 MPL set of all the implemented interfaces.
 
- Protected Member Functions inherited from Service
virtual ~Service ()
 Standard Destructor.
 
int outputLevel () const
 get the Service's output level
 
virtual ~Service ()
 Standard Destructor.
 
int outputLevel () const
 get the Service's output level
 
- Protected Attributes inherited from Service
IntegerProperty m_outputLevel
 Service output level.
 
Gaudi::StateMachine::State m_state
 Service state.
 
Gaudi::StateMachine::State m_targetState
 Service state.
 

Detailed Description

Random Generator service definition.

Description: Definition of a interface for a service to access random generators according to predefined distributions. For more detailed explanations please see the interface definition.

Dependencies:

  • Base class: Gaudi/RndmGenSvc/ISerialize.h
  • Base class: Gaudi/RndmGenSvc/IRandomGenSvc.h

History :

+---------+----------------------------------------------+--------+
|    Date |                 Comment                      | Who    |
+---------+----------------------------------------------+--------+
| 21/04/99| Initial version.                             | MF     |
+---------+----------------------------------------------+--------+

Author: M.Frank Version: 1.0

Definition at line 49 of file RndmGenSvc.h.

Constructor & Destructor Documentation

RndmGenSvc::RndmGenSvc ( const std::string &  name,
ISvcLocator svc 
)

Standard Service constructor.

Definition at line 36 of file RndmGenSvc.cpp.

: base_class(nam, svc), m_engine(0), m_serialize(0)
{
declareProperty("Engine", m_engineName = "HepRndm::Engine<CLHEP::RanluxEngine>");
}
RndmGenSvc::~RndmGenSvc ( )
virtual

Standard Service destructor.

Definition at line 43 of file RndmGenSvc.cpp.

{
}

Member Function Documentation

IRndmEngine * RndmGenSvc::engine ( )
virtual

Retrieve engine.

Definition at line 120 of file RndmGenSvc.cpp.

{
return m_engine;
}
StatusCode RndmGenSvc::finalize ( )
virtual

Service override: finalization.

Reimplemented from Service.

Definition at line 85 of file RndmGenSvc.cpp.

{
if ( m_engine ) {
service->finalize().ignore();
}
m_engine = 0;
return status;
}
StatusCode RndmGenSvc::generator ( const IRndmGen::Param par,
IRndmGen *&  refpGen 
)
virtual

Retrieve a valid generator from the service.

Definition at line 125 of file RndmGenSvc.cpp.

{
IInterface* iface = ObjFactory::create(par.type(),(IInterface*)m_engine);
if ( iface ) {
// query requested interface (adds ref count)
status = iface->queryInterface(IRndmGen::interfaceID(), (void**)& refpGen);
if ( status.isSuccess() ) {
status = refpGen->initialize(par);
}
else {
iface->release();
}
}
// Error!
return status;
}
StatusCode RndmGenSvc::initialize ( )
virtual

Service override: initialization.

Reimplemented from Service.

Definition at line 47 of file RndmGenSvc.cpp.

{
std::string machName = name()+".Engine";
if ( status.isSuccess() ) {
status = setProperties();
if ( status.isSuccess() ) { // Check if the Engine service exists:
// FIXME: (MCl) why RndmGenSvc cannot create the engine service in a standard way?
const bool CREATE = false;
engine = serviceLocator()->service(machName, CREATE);
if ( !engine.isValid() && mgr.isValid() ) {
using Gaudi::Utils::TypeNameString;
engine = mgr->createService(TypeNameString(machName, m_engineName));
}
if ( engine.isValid() ) {
SmartIF<ISerialize> serial(engine);
if ( serial.isValid( ) && service.isValid( ) ) {
status = service->sysInitialize();
if ( status.isSuccess() ) {
m_serialize = serial;
log << MSG::INFO << "Using Random engine:" << m_engineName << endmsg;
return status;
}
}
}
}
}
return status;
}
double RndmGenSvc::rndm ( ) const
virtual

Single shot returning single random number.

Definition at line 143 of file RndmGenSvc.cpp.

{
if ( 0 != m_engine ) {
return m_engine->rndm();
}
return -1;
}
StatusCode RndmGenSvc::rndmArray ( std::vector< double > &  array,
long  howmany,
long  start = 0 
) const
virtual

Multiple shots returning vector with flat random numbers.

Parameters
arrayArray containing random numbers
howmanyfill 'howmany' random numbers into array
start... starting at position start
Returns
StatusCode indicating failure or success.

Definition at line 156 of file RndmGenSvc.cpp.

{
if ( 0 != m_engine ) {
return m_engine->rndmArray(array, howmany, start);
}
}
StatusCode RndmGenSvc::seeds ( std::vector< long > &  seeds) const
virtual

Allow to get seeds.

Definition at line 172 of file RndmGenSvc.cpp.

{
if ( 0 != m_engine ) {
return m_engine->seeds(seeds);
}
}
StreamBuffer & RndmGenSvc::serialize ( StreamBuffer str)
virtual

IRndmGenSvc interface implementation.

Input serialization from stream buffer. Restores the status of the generator engine.

Definition at line 100 of file RndmGenSvc.cpp.

{
if ( 0 != m_serialize ) {
return m_serialize->serialize(str);
}
log << MSG::ERROR << "Cannot input serialize Generator settings!" << endmsg;
return str;
}
StreamBuffer & RndmGenSvc::serialize ( StreamBuffer str) const
virtual

Output serialization to stream buffer. Saves the status of the generator engine.

Definition at line 110 of file RndmGenSvc.cpp.

{
if ( 0 != m_serialize ) {
return m_serialize->serialize(str);
}
log << MSG::ERROR << "Cannot output serialize Generator settings!" << endmsg;
return str;
}
StatusCode RndmGenSvc::setSeeds ( const std::vector< long > &  seeds)
virtual

Allow to set new seeds.

Definition at line 164 of file RndmGenSvc.cpp.

{
if ( 0 != m_engine ) {
return m_engine->setSeeds(seeds);
}
}

Member Data Documentation

IRndmEngine* RndmGenSvc::m_engine
mutableprivate

Random number engine.

Definition at line 52 of file RndmGenSvc.h.

std::string RndmGenSvc::m_engineName
private

Engine name.

Definition at line 56 of file RndmGenSvc.h.

ISerialize* RndmGenSvc::m_serialize
mutableprivate

Serialization interface of random number engine.

Definition at line 54 of file RndmGenSvc.h.


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