BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
HltStoreSvc.cxx
Go to the documentation of this file.
1#include "GaudiKernel/IInterface.h"
2#include "GaudiKernel/Kernel.h"
3#include "GaudiKernel/StatusCode.h"
4// #include "GaudiKernel/ISvcFactory.h"
5#include "GaudiKernel/MsgStream.h"
6#include "GaudiKernel/SvcFactory.h"
8
9#include <algorithm>
10#include <strstream>
11
12static SvcFactory<HltStoreSvc> s_factory;
13// const ISvcFactory& HltStoreSvcFactory = s_factory;
15HltStoreSvc::HltStoreSvc( const std::string& name, ISvcLocator* sl ) : Service( name, sl ) {}
16
18
19StatusCode HltStoreSvc::queryInterface( const InterfaceID& riid, void** ppvIF ) {
20 if ( IID_IHltStoreSvc.versionMatch( riid ) )
21 {
22 // *ppvIF = static_cast<IHltStoreSvc*> (this);
23 *ppvIF = (HltStoreSvc*)this;
24 }
25 else { return Service::queryInterface( riid, ppvIF ); }
26 return StatusCode::SUCCESS;
27}
28
30 StatusCode sc;
31
32 MsgStream log( msgSvc(), name() );
33 log << MSG::INFO << name() << ": Start of run initialisation" << endmsg;
34
35 sc = Service::initialize();
36 if ( sc.isFailure() ) return sc;
37
38 /*
39 sc = service( "HltStoreSvc", m_HltStore);
40 if( sc.isFailure() ) {
41 log<<MSG::WARNING<<"Unable to get service HltStore"<<endmsg;
42 return sc;
43 }
44 log << MSG::DEBUG << "(*p)" << (unsigned long)m_HltStore << endmsg;
45 */
46 return StatusCode::SUCCESS;
47}
48
50 ContainerType::iterator pos;
51 for ( pos = m_map.begin(); pos != m_map.end(); ++pos )
52 {
53 // delete (*pos).second;
54 }
55 m_map.erase( m_map.begin(), m_map.end() );
56 return StatusCode::SUCCESS;
57}
58
59//
60// method to print out all keys in the store
61//
63 ContainerType::iterator pos;
64 for ( pos = m_map.begin(); pos != m_map.end(); ++pos ) { cout << pos->first << endl; }
65}
66
67int HltStoreSvc::size() { return m_map.size(); }
68
69int HltStoreSvc::max_size() { return m_map.max_size(); }
70
71//
72// returns string that contains the length of the Store+1, or, if
73// that key is already taken in the Store, length+n with n>1 and n the
74// lowest value for which the key is not already taken
75//
77 unsigned int iListLength = this->size();
78 iListLength += 1;
79 ostrstream ListLength;
80
81 // convert integer into std::string
82 ListLength << iListLength;
83 ListLength << '\0';
84 string stringListLength = ListLength.str();
85 if ( this->exists( stringListLength ) )
86 {
87 stringListLength = "unset";
88 for ( int i = 0; i < this->max_size(); i++ )
89 {
90 iListLength += 1;
91 ListLength << iListLength;
92 ListLength << '\0';
93 stringListLength = ListLength.str();
94 if ( !( this->exists( stringListLength ) ) )
95 {
96 ListLength.freeze( 0 );
97 return stringListLength;
98 }
99 }
100 }
101
102 ListLength.freeze( 0 );
103 return stringListLength;
104}
105
106//
107// return true if named object exists
108//
109bool HltStoreSvc::exists( const std::string& name ) {
110 return ( m_map.find( name ) != m_map.end() );
111}
DECLARE_COMPONENT(BesBdkRc)
IMessageSvc * msgSvc()
void printKeys()
string sListLength()
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvIF)
virtual StatusCode finalize()
ContainerType m_map
HltStoreSvc(const std::string &name, ISvcLocator *sl)
bool exists(const std::string &name)
virtual StatusCode initialize()
Forward and external declarations.