ATLAS Offline Software
PerfMonUtils.cxx
Go to the documentation of this file.
1 
3 /*
4  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 // PerfMonUtils.cxx
8 // Implementation file for a few PerfMon utilities
9 // Author: S.Binet<binet@cern.ch>
11 
12 // STL includes
13 #include <vector>
14 #include <string>
15 
16 // Framework includes
17 #include "GaudiKernel/IProperty.h"
18 #include "Gaudi/Property.h"
19 #include "GaudiKernel/SmartIF.h"
20 #include "GaudiKernel/MsgStream.h"
21 #include "GaudiKernel/IAuditorSvc.h"
22 #include "GaudiKernel/IAuditor.h"
23 
24 // PerfMonComps includes
25 #include "PerfMonUtils.h"
26 
27 namespace PerfMon {
28 
29 
30 
32 makeAuditor( const std::string& audName, IAuditorSvc* audSvc,
33  MsgStream& msg )
34 {
35  if ( 0 == audSvc ) {
36  msg << MSG::ERROR << "Null pointer to IAuditorSvc !!" << endmsg;
37  return StatusCode::FAILURE;
38  }
39 
40  if ( 0 != audSvc->getAuditor( audName ) ) {
41  msg << MSG::VERBOSE << "AuditorSvc already knows about ["
42  << audName << "]... good."
43  << endmsg;
44  return StatusCode::SUCCESS;
45  }
46 
47  const std::string propName = "Auditors";
48  SmartIF<IProperty> audSvcProp(audSvc);
49  if ( 0 == audSvcProp ) {
50  msg << MSG::ERROR
51  << "Could not dyn-cast IAuditorSvc to an IProperty !!" << endmsg;
52  return StatusCode::FAILURE;
53  }
54 
55  StringArrayProperty audNames;
56  audNames.assign( audSvcProp->getProperty(propName) );
57  std::vector<std::string> updatedNames( audNames.value() );
58  updatedNames.push_back( audName );
59  audNames.set( updatedNames );
60  audNames.setName( propName );
61  if ( !audSvcProp->setProperty( audNames ).isSuccess() ) {
62  msg << MSG::ERROR
63  << "Could not add [" << audName << "] to the list of auditors of"
64  << " [AuditorSvc] !!"
65  << endmsg
66  << audSvcProp->getProperty(propName)
67  << endmsg;
68  return StatusCode::FAILURE;
69  }
70 
71  // make sure the auditor has been created...
72  IAuditor* aud = audSvc->getAuditor( audName );
73  if ( 0 == aud ) {
74  msg << MSG::ERROR
75  << "Failed to make AuditorSvc instantiating ["
76  << audName << "] !!"
77  << endmsg;
78  return StatusCode::FAILURE;
79  }
80  // aud->release();
81 
82  return StatusCode::SUCCESS;
83 }
84 
85 
86 
87 
88 } //> end namespace PerfMon
89 
PerfMon::makeAuditor
StatusCode makeAuditor(const std::string &audName, IAuditorSvc *audSvc, MsgStream &msg)
simple function to factorize boring things such as asking the AuditorSvc if an auditor is there (and ...
Definition: PerfMonUtils.cxx:32
PerfMon
Definition: LinFitSglPass.h:20
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
PerfMonUtils.h
L1CaloPhase1Monitoring.propName
propName
Definition: L1CaloPhase1Monitoring.py:451
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:14
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7