DetVerSvc Class Reference

#include <DetVerSvc.h>

Inheritance diagram for DetVerSvc:

IDetVerSvc List of all members.

Public Member Functions

 DetVerSvc (const std::string &name, ISvcLocator *svcloc)
virtual ~DetVerSvc ()
virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvUnknown)
virtual StatusCode initialize ()
virtual StatusCode finalize ()
int phase ()

Static Public Member Functions

static const InterfaceID & interfaceID ()

Private Member Functions

int fromRun (unsigned int run)

Private Attributes

int m_phase
std::string m_conf

Detailed Description

Definition at line 7 of file DetVerSvc.h.


Constructor & Destructor Documentation

DetVerSvc::DetVerSvc ( const std::string name,
ISvcLocator *  svcloc 
)

Definition at line 12 of file DetVerSvc.cxx.

References m_conf.

00013     : Service(name, svcloc),
00014       m_phase(-1)
00015 {
00016     declareProperty("Config", m_conf);
00017 }

DetVerSvc::~DetVerSvc (  )  [virtual]

Definition at line 19 of file DetVerSvc.cxx.

00020 {
00021 }


Member Function Documentation

StatusCode DetVerSvc::finalize (  )  [virtual]

Definition at line 49 of file DetVerSvc.cxx.

References Bes_Common::INFO.

00049                                  {
00050     MsgStream log(messageService(), name());
00051     log << MSG::INFO << name() << ": End of Run finalize" << endreq;
00052 
00053     return StatusCode::SUCCESS;
00054 }

int DetVerSvc::fromRun ( unsigned int  run  )  [private]

Definition at line 84 of file DetVerSvc.cxx.

References m_conf.

Referenced by phase().

00085 {
00086     std::vector<int>  runList;
00087     //parse m_conf
00088     int iTmp;
00089     std::ifstream  fs(m_conf.c_str());
00090     fs >> iTmp;
00091     while ( ! fs.eof() ) {
00092         runList.push_back(iTmp);
00093         fs >> iTmp;
00094     }
00095 
00096     //return phase from run
00097     int iPhase = 1;
00098     for ( std::vector<int>::iterator it = runList.begin(); it != runList.end(); ++it ) {
00099         if ( run < (*it) ) {
00100             break;
00101         }
00102         ++iPhase;
00103     }
00104     return iPhase;
00105 }

StatusCode DetVerSvc::initialize (  )  [virtual]

Definition at line 33 of file DetVerSvc.cxx.

References Bes_Common::FATAL, Bes_Common::INFO, and m_conf.

00034 {
00035     Service::initialize();
00036 
00037     MsgStream log(messageService(), name());
00038     log << MSG::INFO << name() << ": Start of run initialisation" << endreq;
00039 
00040     //assert m_conf is a valid file
00041     if ( access( m_conf.c_str(), F_OK ) < 0 ) {
00042         log << MSG::FATAL << "Cann't find config file: " << m_conf << endreq;
00043         return StatusCode::FAILURE;
00044     }
00045 
00046     return StatusCode::SUCCESS;
00047 }

static const InterfaceID& IDetVerSvc::interfaceID (  )  [inline, static, inherited]

Definition at line 13 of file IDetVerSvc.h.

References IID_IDetVerSvc().

00013 { return IID_IDetVerSvc; }

int DetVerSvc::phase (  )  [virtual]

Implements IDetVerSvc.

Definition at line 56 of file DetVerSvc.cxx.

References fromRun(), m_phase, DetVerSvcPack::pf_helper, and deljobs::string.

00057 {
00058     if ( m_phase < 0) {  //phase has not been retrieved
00059         SmartIF<IJobOptionsSvc> iSvc(serviceLocator()->service("JobOptionsSvc"));
00060         if ( iSvc.isValid() ) {
00061             std::string  dll;  //sub so name
00062             const std::vector<const Property*>* ps = 0;
00063             if ( (ps = iSvc->getProperties("RawDataInputSvc")) != 0 ) {
00064                 dll = "libDetVerSvc_IRaw.so";  //case 0: Input RAW
00065             }
00066             else if ( (ps = iSvc->getProperties("EventCnvSvc")) != 0 ) {
00067                 dll = "libDetVerSvc_IRoot.so";  //case 1: Input root
00068             }
00069             else if ( (ps = iSvc->getProperties("RealizationSvc")) != 0 ) {
00070                 dll = "libDetVerSvc_Sim.so";  //case 2: simulation
00071             }
00072             //else //    //Unknown job type !!!!!
00073 
00074             void *dl_handler = dlopen(dll.c_str(), RTLD_LAZY|RTLD_GLOBAL);
00075             if ( dl_handler != 0 ) {
00076                 m_phase = fromRun( (*DetVerSvcPack::pf_helper)(serviceLocator()) );
00077             }
00078             dlclose(dl_handler);
00079         }
00080     }
00081     return m_phase;
00082 }

StatusCode DetVerSvc::queryInterface ( const InterfaceID &  riid,
void **  ppvUnknown 
) [virtual]

Definition at line 23 of file DetVerSvc.cxx.

References IID_IDetVerSvc().

00024 {
00025     if ( IID_IDetVerSvc.versionMatch(riid) ) { 
00026         *ppvInterface = static_cast<IDetVerSvc*> (this); 
00027     } else { 
00028         return Service::queryInterface(riid, ppvInterface) ; 
00029     }
00030     return StatusCode::SUCCESS;
00031 }


Member Data Documentation

std::string DetVerSvc::m_conf [private]

Definition at line 25 of file DetVerSvc.h.

Referenced by DetVerSvc(), fromRun(), and initialize().

int DetVerSvc::m_phase [private]

Definition at line 24 of file DetVerSvc.h.

Referenced by phase().


Generated on Tue Nov 29 23:18:16 2016 for BOSS_7.0.2 by  doxygen 1.4.7