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