/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/EventFilter/HltUtilities/HltStore/HltStore-01-00-04/src/HltStoreSvc.cxx

Go to the documentation of this file.
00001 #include "GaudiKernel/Kernel.h"
00002 #include "GaudiKernel/IInterface.h"
00003 #include "GaudiKernel/StatusCode.h"
00004 //#include "GaudiKernel/ISvcFactory.h"
00005 #include "GaudiKernel/SvcFactory.h"
00006 #include "GaudiKernel/MsgStream.h"
00007 #include "HltStore/HltStoreSvc.h"
00008 
00009 #include <strstream>
00010 #include <algorithm>
00011 
00012 static SvcFactory<HltStoreSvc> s_factory;
00013 //const ISvcFactory& HltStoreSvcFactory = s_factory;
00014 
00015 HltStoreSvc::HltStoreSvc( const std::string& name, ISvcLocator* sl ) : Service(name, sl) 
00016 { }
00017 
00018 HltStoreSvc::~HltStoreSvc() 
00019 { }
00020 
00021 StatusCode HltStoreSvc::queryInterface (const InterfaceID& riid, void** ppvIF ) 
00022 {
00023   if ( IID_IHltStoreSvc.versionMatch(riid) ) { 
00024 //    *ppvIF = static_cast<IHltStoreSvc*> (this); 
00025     *ppvIF = (HltStoreSvc*)this; 
00026   } else { 
00027     return Service::queryInterface(riid, ppvIF) ; 
00028   }
00029   return StatusCode::SUCCESS;
00030 }
00031 
00032 StatusCode HltStoreSvc::initialize ( ) 
00033 {
00034   StatusCode sc;
00035 
00036   MsgStream log(messageService(), name());
00037   log << MSG::INFO << name() << ": Start of run initialisation" << endreq;
00038 
00039   sc = Service::initialize();
00040   if ( sc.isFailure() ) return sc;
00041   
00042   /*
00043   sc = service( "HltStoreSvc", m_HltStore); 
00044   if( sc.isFailure() ) {
00045     log<<MSG::WARNING<<"Unable to get service HltStore"<<endreq;
00046     return sc;
00047   }
00048   log << MSG::DEBUG << "(*p)" << (unsigned long)m_HltStore << endreq;
00049   */
00050   return StatusCode::SUCCESS;
00051 }
00052 
00053 StatusCode HltStoreSvc::finalize ( ) 
00054 {
00055   ContainerType::iterator pos;
00056   for (pos = m_map.begin(); pos != m_map.end(); ++pos) {
00057 //    delete (*pos).second;
00058   }
00059   m_map.erase(m_map.begin(),m_map.end());
00060   return StatusCode::SUCCESS;
00061 }
00062 
00063   //
00064   // method to print out all keys in the store
00065   //
00066 void HltStoreSvc::printKeys(){
00067   ContainerType::iterator pos;
00068   for (pos = m_map.begin(); pos != m_map.end(); ++pos) {
00069     cout << pos->first << endl;
00070   }
00071 }
00072 
00073 int HltStoreSvc::size(){
00074   return m_map.size();
00075 }
00076 
00077 int HltStoreSvc::max_size(){
00078   return m_map.max_size();
00079 }
00080 
00081 //
00082 // returns string that contains the length of the Store+1, or, if
00083 //that key is already taken in the Store, length+n with n>1 and n the 
00084 //lowest value for which the key is not already taken
00085 //
00086 string HltStoreSvc::sListLength(){
00087   unsigned int iListLength = this->size();
00088   iListLength += 1;
00089   ostrstream ListLength;
00090   
00091   //convert integer into std::string
00092   ListLength <<  iListLength;
00093   ListLength << '\0'; 
00094   string stringListLength = ListLength.str();          
00095   if (this->exists(stringListLength)){
00096     stringListLength = "unset";
00097     for (int i = 0; i < this->max_size(); i++){
00098       iListLength += 1;
00099       ListLength <<  iListLength; 
00100       ListLength << '\0'; 
00101       stringListLength = ListLength.str();
00102       if (!(this->exists(stringListLength))) {
00103         ListLength.freeze(0);
00104         return stringListLength;
00105       }
00106     }
00107   }
00108 
00109   ListLength.freeze(0);
00110   return stringListLength;
00111 }
00112 
00113 //
00114 // return true if named object exists
00115 //
00116 bool HltStoreSvc::exists(const std::string& name) {
00117   return (m_map.find(name) != m_map.end());
00118 }
00119 

Generated on Tue Nov 29 23:12:07 2016 for BOSS_7.0.2 by  doxygen 1.4.7