00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #define GAUDI_RANDOMGENSVC_RndmEngine_CPP
00016
00017
00018 #include <cfloat>
00019
00020
00021 #include "GaudiKernel/IMessageSvc.h"
00022 #include "GaudiKernel/ISvcLocator.h"
00023 #include "GaudiKernel/IIncidentSvc.h"
00024 #include "GaudiKernel/IOpaqueAddress.h"
00025 #include "GaudiKernel/IDataProviderSvc.h"
00026 #include "GaudiKernel/GenericLink.h"
00027 #include "GaudiKernel/DataObject.h"
00028 #include "GaudiKernel/MsgStream.h"
00029 #include "RndmEngine.h"
00030
00032 RndmEngine::RndmEngine(const std::string& name, ISvcLocator* loc)
00033 : Service(name, loc), m_pIncidentSvc(0)
00034 {
00035 }
00036
00038 RndmEngine::~RndmEngine() {
00039 }
00040
00042 StatusCode RndmEngine::queryInterface(const IID& riid, void** ppvInterface) {
00043 if ( IID_IRndmEngine == riid ) {
00044 *ppvInterface = (IRndmEngine*)this;
00045 }
00046 else if ( IID_ISerialize == riid ) {
00047 *ppvInterface = (ISerialize*)this;
00048 }
00049 else if ( IID_IIncidentListener == riid ) {
00050 *ppvInterface = (IIncidentListener*)this;
00051 }
00052 else {
00053 return Service::queryInterface(riid, ppvInterface);
00054 }
00055 addRef();
00056 return StatusCode::SUCCESS;
00057 }
00058
00060 StatusCode RndmEngine::initialize() {
00061 StatusCode status = Service::initialize();
00062 if ( status.isSuccess() ) {
00063 status = setProperties();
00064 if ( status.isSuccess() ) {
00065 status = serviceLocator()->getService( "IncidentSvc", IID_IIncidentSvc, (IInterface*&)m_pIncidentSvc );
00066 if ( status.isSuccess() ) {
00067 m_pIncidentSvc->addRef();
00068 }
00069 }
00070 }
00071 return status;
00072 }
00073
00075 StatusCode RndmEngine::finalize() {
00076 StatusCode status = Service::finalize();
00077 if ( m_pIncidentSvc ) {
00078 m_pIncidentSvc->release();
00079 }
00080 m_pIncidentSvc = 0;
00081 return status;
00082 }
00083
00085
00086 StreamBuffer& RndmEngine::serialize(StreamBuffer& str) {
00087 return str;
00088 }
00089
00091 StreamBuffer& RndmEngine::serialize(StreamBuffer& str) const {
00092 return str;
00093 }
00094
00096 double RndmEngine::rndm() const {
00097 return DBL_MAX;
00098 }
00099
00101 void RndmEngine::handle (const Incident& ) {
00102 }
00103
00110 StatusCode RndmEngine::rndmArray( std::vector<double>& array, long howmany, long start) const {
00111 long cnt = start;
00112 array.resize(start+howmany);
00113 for ( long i = start, num = start+howmany; i < num; i++ ) {
00114 array[cnt++] = rndm();
00115 }
00116 return StatusCode::SUCCESS;
00117 }
00118