Gaudi Framework, version v23r5

Home   Generated: Wed Nov 28 2012
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Auditor.cpp
Go to the documentation of this file.
1 // $Id: Auditor.cpp,v 1.20 2008/10/27 19:22:21 marcocle Exp $
2 
3 #include "GaudiKernel/Kernel.h"
7 
8 #include "GaudiKernel/Auditor.h"
9 
10 #include "GaudiKernel/MsgStream.h"
12 
13 // Constructor
14 Auditor::Auditor( const std::string& name, ISvcLocator *pSvcLocator )
15 : m_name(name),
16  m_pSvcLocator(pSvcLocator),
17  m_isEnabled(true),
18  m_isInitialized(false),
19  m_isFinalized(false)
20 {
21  m_PropertyMgr = new PropertyMgr();
22 
23  // Declare common Auditor properties with their defaults
24  declareProperty( "OutputLevel", m_outputLevel = MSG::NIL);
25  declareProperty( "Enable", m_isEnabled = true);
26 }
27 
28 // Default Destructor
30  delete m_PropertyMgr;
31 }
32 
33 // IAuditor implementation
35  StatusCode sc;
36 
37  // Bypass the initialization if the auditor is disabled or
38  // has already been initialized.
39  if ( isEnabled( ) && ! m_isInitialized ) {
40 
41  // Setup the default service ... this should be upgraded so as to be configurable.
42  if( m_pSvcLocator == 0 )
43  return StatusCode::FAILURE;
44 
45  // Set up message service
46  m_MS = serviceLocator(); // get default message service
47  if( !m_MS.isValid() ) return StatusCode::FAILURE;
48 
49  // Set the Auditor's properties
50  sc = setProperties();
51  if( !sc.isSuccess() ) return StatusCode::FAILURE;
52 
53  // Check current outputLevel to eventually inform the MessagsSvc
54  if( m_outputLevel != MSG::NIL ) {
56  }
57 
58  {
59  try{
60  // Invoke the initialize() method of the derived class
61  sc = initialize();
62  if( !sc.isSuccess() ) return StatusCode::FAILURE;
63  m_isInitialized = true;
64 
65  return sc;
66  }
67  catch ( const GaudiException& Exception )
68  {
70  MsgStream log ( msgSvc() , name() + ".sysInitialize()" );
71  log << MSG::FATAL << " Exception with tag=" << Exception.tag() << " is catched " << endmsg;
73  MsgStream logEx ( msgSvc() , Exception.tag() );
74  logEx << MSG::ERROR << Exception << endmsg;
75  }
76  catch( const std::exception& Exception )
77  {
79  MsgStream log ( msgSvc() , name() + ".sysInitialize()" );
80  log << MSG::FATAL << " Standard std::exception is catched " << endmsg;
82  MsgStream logEx ( msgSvc() , name() + "*std::exception*" );
83  logEx << MSG::ERROR << Exception.what() << endmsg;
84  }
85  catch(...)
86  {
88  MsgStream log ( msgSvc() , name() + ".sysInitialize()" );
89  log << MSG::FATAL << " UNKNOWN Exception is catched " << endmsg;
90  }
91  }
92  }
94  return StatusCode::FAILURE;
95 }
96 
98  return StatusCode::SUCCESS;
99 }
100 
101 // Implemented for backward compatibility
102 void Auditor::before(StandardEventType evt, INamedInterface* obj){
103  switch (evt) {
104  case Initialize: beforeInitialize(obj); break;
105  case ReInitialize: beforeReinitialize(obj); break;
106  case Execute: beforeExecute(obj); break;
107  case BeginRun: beforeBeginRun(obj); break;
108  case EndRun: beforeEndRun(obj); break;
109  case Finalize: beforeFinalize(obj); break;
110  case Start: break;
111  case Stop: break;
112  case ReStart: break;
113  default: break ;// do nothing
114  }
115 }
116 void Auditor::before(StandardEventType, const std::string&) {}
117 
118 void Auditor::before(CustomEventTypeRef, INamedInterface*){}
119 void Auditor::before(CustomEventTypeRef, const std::string&){}
120 
121 // Implemented for backward compatibility
122 void Auditor::after(StandardEventType evt, INamedInterface* obj, const StatusCode& sc){
123  switch (evt) {
124  case Initialize: afterInitialize(obj); break;
125  case ReInitialize: afterReinitialize(obj); break;
126  case Execute: afterExecute(obj, sc); break;
127  case BeginRun: afterBeginRun(obj); break;
128  case EndRun: afterEndRun(obj); break;
129  case Finalize: afterFinalize(obj); break;
130  case Start: break;
131  case Stop: break;
132  case ReStart: break;
133  default: break ;// do nothing
134  }
135 }
136 void Auditor::after(StandardEventType, const std::string&, const StatusCode&) {}
137 
138 void Auditor::after(CustomEventTypeRef, INamedInterface*, const StatusCode&){}
139 void Auditor::after(CustomEventTypeRef, const std::string&, const StatusCode&){}
140 
142 
144 
146 
148 
150 
152 
154 
156 
158 
160 
162 
164 
167  try{
168  //
169  // Invoke the finalize() method of the derived class if
170  // it has been initialized.
171  if ( m_isInitialized && ! m_isFinalized ) {
172  m_isFinalized = true;
173  sc = finalize();
174  if( !sc.isSuccess() ) return StatusCode::FAILURE;
175  }
176  return sc;
177  //
178  }
179  catch( const GaudiException& Exception )
180  {
182  MsgStream log ( msgSvc() , name() + ".sysFinalize()" );
183  log << MSG::FATAL
184  << " Exception with tag=" << Exception.tag() << " is catched " << endmsg;
187  MsgStream logEx ( msgSvc() , Exception.tag() );
188  logEx << MSG::ERROR
189  << Exception << endmsg;
190  }
191  catch( const std::exception& Exception )
192  {
194  MsgStream log ( msgSvc() , name() + ".sysFinalize()" );
195  log << MSG::FATAL
196  << " Standard std::exception is caught " << endmsg;
198  MsgStream logEx ( msgSvc() , name() + "*std::exception*" );
199  logEx << MSG::ERROR
200  << Exception.what() << endmsg;
201  }
202  catch( ... )
203  {
205  MsgStream log ( msgSvc() , name() + ".sysFinalize()" );
206  log << MSG::FATAL
207  << " UNKNOWN Exception is caught " << endmsg;
208  }
210  return StatusCode::FAILURE ;
211 }
212 
214  m_MS = 0; // release message service
215  return StatusCode::SUCCESS;
216 }
217 
218 const std::string& Auditor::name() const {
219  return m_name;
220 }
221 
222 bool Auditor::isEnabled( ) const {
223  return m_isEnabled;
224 }
225 
227  return m_MS;
228 }
229 
231  if( m_MS != 0) {
232  m_MS->setOutputLevel( name(), level );
233  }
234 }
235 
237  return m_pSvcLocator;
238 }
239 
240 // Use the job options service to set declared properties
242  if( m_pSvcLocator != 0 ) {
243  IJobOptionsSvc* jos;
244  StatusCode sc = service("JobOptionsSvc", jos);
245  if( sc.isSuccess() ) {
246  jos->setMyProperties( name(), this ).ignore();
247  jos->release();
248  return StatusCode::SUCCESS;
249  }
250  }
251  return StatusCode::FAILURE;
252 }
253 
254 // IProperty implementation
255 // Delegate to the Property manager
257  return m_PropertyMgr->setProperty(p);
258 }
260  return m_PropertyMgr->setProperty(s);
261 }
263  return m_PropertyMgr->setProperty(n,v);
264 }
266  return m_PropertyMgr->getProperty(p);
267 }
268 const Property& Auditor::getProperty( const std::string& name) const{
269  return m_PropertyMgr->getProperty(name);
270 }
272  return m_PropertyMgr->getProperty(n,v);
273 }
275  return m_PropertyMgr->getProperties();
276 }

Generated at Wed Nov 28 2012 12:17:15 for Gaudi Framework, version v23r5 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004