BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
HltStoreSvc Class Reference

#include <HltStoreSvc.h>

Inheritance diagram for HltStoreSvc:

Classes

class  BaseHolder
class  Holder

Public Member Functions

 HltStoreSvc (const std::string &name, ISvcLocator *sl)
 ~HltStoreSvc ()
virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvIF)
virtual StatusCode initialize ()
virtual StatusCode finalize ()
void printKeys ()
int size ()
int max_size ()
string sListLength ()
bool exists (const std::string &name)
template<class T>
bool put (const std::string &name, const T &value)
template<class T>
bool get (const std::string &name, T &value)
bool erase (const std::string &name)
bool clear (void)

Static Public Member Functions

static const InterfaceID & interfaceID ()

Protected Types

typedef map< string, BaseHolder * > ContainerType

Protected Attributes

ContainerType m_map

Detailed Description

Definition at line 16 of file HltStoreSvc.h.

Member Typedef Documentation

◆ ContainerType

typedef map<string, BaseHolder*> HltStoreSvc::ContainerType
protected

Definition at line 35 of file HltStoreSvc.h.

Constructor & Destructor Documentation

◆ HltStoreSvc()

HltStoreSvc::HltStoreSvc ( const std::string & name,
ISvcLocator * sl )

Definition at line 15 of file HltStoreSvc.cxx.

15: Service( name, sl ) {}

Referenced by HltStoreSvc(), and queryInterface().

◆ ~HltStoreSvc()

HltStoreSvc::~HltStoreSvc ( )

Definition at line 17 of file HltStoreSvc.cxx.

17{}

Member Function Documentation

◆ clear()

bool HltStoreSvc::clear ( void )
inline

Definition at line 104 of file HltStoreSvc.h.

104 {
105 for ( ContainerType::iterator it = m_map.begin(); it != m_map.end(); it++ )
106 { delete ( *it ).second; }
107 m_map.erase( m_map.begin(), m_map.end() );
108 return true;
109 }
ContainerType m_map

◆ erase()

bool HltStoreSvc::erase ( const std::string & name)
inline

Definition at line 90 of file HltStoreSvc.h.

90 {
91 ContainerType::iterator it = m_map.find( name );
92 if ( it != m_map.end() )
93 {
94 delete ( *it ).second;
95 m_map.erase( it );
96 return true;
97 }
98 return false;
99 }

◆ exists()

bool HltStoreSvc::exists ( const std::string & name)

Definition at line 109 of file HltStoreSvc.cxx.

109 {
110 return ( m_map.find( name ) != m_map.end() );
111}

Referenced by sListLength().

◆ finalize()

StatusCode HltStoreSvc::finalize ( )
virtual

Definition at line 49 of file HltStoreSvc.cxx.

49 {
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}

◆ get()

template<class T>
bool HltStoreSvc::get ( const std::string & name,
T & value )
inline

Definition at line 70 of file HltStoreSvc.h.

70 {
71 // std::cout << "HltStoreSvc::get() "<<"start"<<std::endl;
72 ContainerType::iterator it = m_map.find( name );
73 // std::cout << "HltStoreSvc::get() "<<"middle"<<std::endl;
74 if ( it != m_map.end() )
75 {
76 if ( Holder<T>* ptr = static_cast<Holder<T>*>( ( *it ).second ) )
77 {
78 value = ptr->value();
79 return true;
80 }
81 }
82 // std::cout << "HltStoreSvc::get() "<<"end"<<std::endl;
83 return false;
84 }

◆ initialize()

StatusCode HltStoreSvc::initialize ( )
virtual

Definition at line 29 of file HltStoreSvc.cxx.

29 {
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}
IMessageSvc * msgSvc()

◆ interfaceID()

const InterfaceID & HltStoreSvc::interfaceID ( )
inlinestatic

Definition at line 30 of file HltStoreSvc.h.

30{ return IID_IHltStoreSvc; }

◆ max_size()

int HltStoreSvc::max_size ( )

Definition at line 69 of file HltStoreSvc.cxx.

69{ return m_map.max_size(); }

Referenced by sListLength().

◆ printKeys()

void HltStoreSvc::printKeys ( )

Definition at line 62 of file HltStoreSvc.cxx.

62 {
63 ContainerType::iterator pos;
64 for ( pos = m_map.begin(); pos != m_map.end(); ++pos ) { cout << pos->first << endl; }
65}

◆ put()

template<class T>
bool HltStoreSvc::put ( const std::string & name,
const T & value )
inline

Definition at line 54 of file HltStoreSvc.h.

54 {
55 Holder<T>* ptr = new Holder<T>( value );
56 if ( BaseHolder* old = m_map[name] )
57 {
58 std::cout << "demanded key already exists, overwrite old one" << std::endl;
59 delete old;
60 }
61 m_map[name] = ptr;
62 return true;
63 }

◆ queryInterface()

StatusCode HltStoreSvc::queryInterface ( const InterfaceID & riid,
void ** ppvIF )
virtual

Definition at line 19 of file HltStoreSvc.cxx.

19 {
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}
HltStoreSvc(const std::string &name, ISvcLocator *sl)

◆ size()

int HltStoreSvc::size ( )

Definition at line 67 of file HltStoreSvc.cxx.

67{ return m_map.size(); }

Referenced by sListLength().

◆ sListLength()

string HltStoreSvc::sListLength ( )

Definition at line 76 of file HltStoreSvc.cxx.

76 {
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}
bool exists(const std::string &name)

Member Data Documentation

◆ m_map

ContainerType HltStoreSvc::m_map
protected

Definition at line 135 of file HltStoreSvc.h.

Referenced by clear(), erase(), exists(), finalize(), get(), max_size(), printKeys(), put(), and size().


The documentation for this class was generated from the following files: