The Gaudi Framework  v37r0 (b608885e)
AppReturnCode.h
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 \***********************************************************************************/
16 #ifndef APPRETURNCODE_H_
17 #define APPRETURNCODE_H_
18 
19 #include "GaudiKernel/IProperty.h"
20 #include <Gaudi/Property.h>
21 
22 namespace Gaudi {
24  namespace ReturnCode {
25 
26  constexpr int Success = 0x00;
27 
28  constexpr int GenericFailure = 0x01;
29 
33  constexpr int FailInput = 0x02; //< Error opening file
34  constexpr int AlgorithmFailure = 0x03; //<
35  constexpr int ScheduledStop = 0x04; //< Loop terminated because of user request
36  constexpr int IncidentFailure = 0x05; //< Fatal error in Incident handling
37  constexpr int UnhandledException = 0x06; //<
38  constexpr int CorruptedInput = 0x10; //< Input file showed a corruption
42  constexpr int FinalizationFailure = 0x0b;
44  constexpr int SignalOffset = 0x80; //< Offset for signal-related return codes
45  } // namespace ReturnCode
46 
59  inline StatusCode setAppReturnCode( SmartIF<IProperty>& appmgr, int value, bool force = false ) {
60  if ( appmgr ) {
61  Gaudi::Property<int> returnCode( "ReturnCode", 0 );
62  if ( appmgr->getProperty( &returnCode ).isSuccess() ) {
63  if ( returnCode.value() == 0 || force ) {
64  returnCode.setValue( value );
65  return appmgr->setProperty( returnCode );
66  }
67  // Consider is a success if we do already have an error code.
68  return StatusCode::SUCCESS;
69  }
70  }
71  return StatusCode::FAILURE;
72  }
73 
79  inline int getAppReturnCode( const SmartIF<IProperty>& appmgr ) {
80  if ( appmgr ) {
81  Gaudi::Property<int> returnCode( "ReturnCode", 0 );
82  if ( appmgr->getProperty( &returnCode ).isSuccess() ) return returnCode.value();
83  }
84  return 0;
85  }
86 } // namespace Gaudi
87 #endif /* APPRETURNCODE_H_ */
Gaudi::ReturnCode::Success
constexpr int Success
Definition: AppReturnCode.h:26
Gaudi::ReturnCode::SignalOffset
constexpr int SignalOffset
Definition: AppReturnCode.h:44
Gaudi::ReturnCode::FinalizationFailure
constexpr int FinalizationFailure
Error codes for operation failures.
Definition: AppReturnCode.h:42
Gaudi::getAppReturnCode
int getAppReturnCode(const SmartIF< IProperty > &appmgr)
Get the application (current) return code.
Definition: AppReturnCode.h:79
Gaudi::ReturnCode::FailInput
constexpr int FailInput
Definition: AppReturnCode.h:33
Gaudi::Property::setValue
bool setValue(const ValueType &v)
Definition: Property.h:241
StatusCode
Definition: StatusCode.h:65
Gaudi::ReturnCode::IncidentFailure
constexpr int IncidentFailure
Definition: AppReturnCode.h:36
Gaudi::setAppReturnCode
StatusCode setAppReturnCode(SmartIF< IProperty > &appmgr, int value, bool force=false)
Set the application return code.
Definition: AppReturnCode.h:59
Gaudi::Property::value
const ValueType & value() const
Definition: Property.h:239
Gaudi::ReturnCode::ScheduledStop
constexpr int ScheduledStop
Definition: AppReturnCode.h:35
Gaudi::ReturnCode::CorruptedInput
constexpr int CorruptedInput
Definition: AppReturnCode.h:38
SmartIF< IProperty >
Gaudi::ReturnCode::UnhandledException
constexpr int UnhandledException
Definition: AppReturnCode.h:37
Gaudi::ReturnCode::AlgorithmFailure
constexpr int AlgorithmFailure
Definition: AppReturnCode.h:34
Gaudi
Header file for std:chrono::duration-based Counters.
Definition: __init__.py:1
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
IProperty.h
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101
Gaudi::ReturnCode::GenericFailure
constexpr int GenericFailure
Definition: AppReturnCode.h:28
Gaudi::Property< int >
Property.h