The Gaudi Framework  master (37c0b60a)
ChronoAuditor.cpp
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 // ChronoAuditor:
12 // An auditor that monitors time
13 
14 #include "ChronoAuditor.h"
15 
17 
18 StatusCode ChronoAuditor::initialize() {
19  return CommonAuditor::initialize().andThen( [&]() -> StatusCode {
20  m_chronoSvc = serviceLocator()->service( "ChronoStatSvc" );
21  if ( !m_chronoSvc.get() ) {
22  error() << "Cannot get ChronoStatSvc" << endmsg;
23  return StatusCode::FAILURE;
24  }
25  return StatusCode::SUCCESS;
26  } );
27 }
28 
29 void ChronoAuditor::i_before( CustomEventTypeRef evt, std::string_view caller ) {
30  chronoSvc()->chronoStart( i_id( evt, caller ) );
31 }
32 
33 void ChronoAuditor::i_after( CustomEventTypeRef evt, std::string_view caller, const StatusCode& ) {
34  chronoSvc()->chronoStop( i_id( evt, caller ) );
35 }
IOTest.evt
evt
Definition: IOTest.py:107
StatusCode::andThen
StatusCode andThen(F &&f, ARGS &&... args) const
Chain code blocks making the execution conditional a success result.
Definition: StatusCode.h:163
ChronoAuditor::chronoSvc
SmartIF< IChronoStatSvc > & chronoSvc()
Definition: ChronoAuditor.h:40
ChronoAuditor.h
ChronoAuditor::i_id
std::string i_id(CustomEventTypeRef evt, std::string_view caller)
Compute the id string to be used for the chrono entity.
Definition: ChronoAuditor.h:38
Auditor::initialize
virtual StatusCode initialize()
Definition: Auditor.cpp:79
StatusCode
Definition: StatusCode.h:65
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202
ChronoAuditor::i_after
void i_after(CustomEventTypeRef evt, std::string_view caller, const StatusCode &sc) override
Default (catch-all) "after" Auditor hook.
Definition: ChronoAuditor.cpp:33
ChronoAuditor::i_before
void i_before(CustomEventTypeRef evt, std::string_view caller) override
Default (catch-all) "before" Auditor hook.
Definition: ChronoAuditor.cpp:29
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition: PluginServiceV1.h:46
ChronoAuditor
Definition: ChronoAuditor.h:24
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101