Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

DetDataSvc.cpp

Go to the documentation of this file.
00001 // $Header: /nfs/slac/g/glast/ground/cvs/GaudiSvc/src/DetectorDataSvc/DetDataSvc.cpp,v 1.1.1.2 2001/04/18 18:32:49 tlindner Exp $
00002 #define  DETECTORDATASVC_DETDATASVC_CPP
00003 
00004 
00005 // Include files
00006 #include "GaudiKernel/SvcFactory.h"
00007 #include "GaudiKernel/ISvcLocator.h"
00008 #include "GaudiKernel/IConversionSvc.h"
00009 #include "GaudiKernel/IAddressCreator.h"
00010 #include "GaudiKernel/MsgStream.h"
00011 #include "DetDataSvc.h"
00012 
00013 
00014 // Instantiation of a static factory class used by clients to create
00015 // instances of this service
00016 static SvcFactory<DetDataSvc> s_factory;
00017 const ISvcFactory& DetDataSvcFactory = s_factory;
00018 
00019 
00020 // Service initialisation
00021 StatusCode DetDataSvc::initialize()   {
00022 
00023   StatusCode sc;
00024   MsgStream log(msgSvc(), name());
00025 
00026   // Call base class initialisation
00027   sc  = DataSvc::initialize();
00028   if( sc.isFailure() ) return sc;
00029 
00030   // Set Data Loader
00031   IConversionSvc* cnv_svc;
00032   sc = serviceLocator()->service("DetectorPersistencySvc", cnv_svc);
00033   if( sc .isFailure() ) {
00034   }
00035 
00036   sc = setDataLoader( cnv_svc );
00037   if( sc .isFailure() ) {
00038   }
00039   //--------------------------------------------------------------------------------------------
00040   // Setup Detector Description
00041   //--------------------------------------------------------------------------------------------
00042 
00043   // Initialize the detector data transient store
00044   log << MSG::DEBUG << "Storage type used is: " << m_detStorageType << endreq;
00045   log << MSG::DEBUG << "Setting DetectorDataSvc root node... " << endreq;
00046 
00047   IAddressCreator*     ddCreator = 0;
00048 
00049   sc = serviceLocator()->service("DetectorPersistencySvc", ddCreator);
00050   
00051   if( sc.isFailure() ) {
00052     log << MSG::ERROR << " Unnable to locate DetectorPersistencySvc." << endreq; 
00053     return StatusCode::FAILURE; 
00054   }
00055 
00056   if( m_usePersistency ) {
00057 
00058     IOpaqueAddress* rootAddr;
00059     if( m_detDbLocation.empty() || "empty" == m_detDbLocation ) { 
00060 
00061       // if the name of DBlocation is not given - construct it!
00062             // retrieve the value of DDDB or XMLDDBROOT
00063 
00064       if( 0 != getenv("DDDB") ) {
00065         m_detDbLocation  = getenv("DDDB");
00066         m_detDbLocation += "/dddb.xml";
00067       }
00068       else if ( 0 != getenv("XMLDDDBROOT") ) {
00069         m_detDbLocation  = getenv("XMLDDDBROOT");
00070         m_detDbLocation += "/DDDB/dddb.xml";
00071       }
00072     }
00073     if( m_detDbLocation.empty() || "empty" == m_detDbLocation ) { 
00074       log << MSG::ERROR << "Detector data location name not set. Detector data will not be found." << endreq;
00075       return StatusCode::FAILURE;
00076     }
00077     else {
00078       sc = ddCreator->createAddress( (unsigned char)m_detStorageType,
00079                                       CLID_Catalog, m_detDbLocation, 
00080                                       m_detDbRootName, 0, rootAddr );
00081       if( sc.isSuccess() ) {
00082         std::string dbrName = "/" + m_detDbRootName;
00083         sc = setRoot( dbrName, rootAddr );
00084         if( sc.isFailure() ) {
00085           log << MSG::ERROR << "Unable to set detector data store root" << endreq;
00086           return sc;
00087         }
00088       }
00089       else {
00090         log << MSG::ERROR << "Unable to create dddress for  /dd" << endreq;
00091         return sc;
00092       }
00093     }
00094   }
00095   else {
00096     log << MSG::INFO << "Detector description not requested to be loaded" << endreq;
00097   }
00098 
00099   return StatusCode::SUCCESS;
00100 }
00101 
00102 
00104 DetDataSvc::DetDataSvc(const std::string& name,ISvcLocator* svc) : DataSvc(name,svc)   {
00105 
00106   declareProperty("DetStorageType",  m_detStorageType = XML_StorageType );
00107   declareProperty("DetDbLocation",   m_detDbLocation  = "empty" );
00108   declareProperty("DetDbRootName",   m_detDbRootName  = "dd" );
00109   declareProperty("UsePersistency",  m_usePersistency = false );
00110 }
00111 
00112 
00114 DetDataSvc::~DetDataSvc()  {
00115   setDataLoader(0);
00116   clearStore();
00117 }

Generated at Wed Nov 21 12:22:29 2001 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000