![]() |
|
|||
File indexing completed on 2025-02-21 10:00:28
0001 /***********************************************************************************\ 0002 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations * 0003 * * 0004 * This software is distributed under the terms of the Apache version 2 licence, * 0005 * copied verbatim in the file "LICENSE". * 0006 * * 0007 * In applying this licence, CERN does not waive the privileges and immunities * 0008 * granted to it by virtue of its status as an Intergovernmental Organization * 0009 * or submit itself to any jurisdiction. * 0010 \***********************************************************************************/ 0011 /** 0012 * Helper functions to set/get the application return code. 0013 * 0014 * @author Marco Clemencic 0015 */ 0016 #ifndef APPRETURNCODE_H_ 0017 #define APPRETURNCODE_H_ 0018 0019 #include "GaudiKernel/IProperty.h" 0020 #include <Gaudi/Property.h> 0021 0022 namespace Gaudi { 0023 /// ApplicationMgr return code definitions. 0024 namespace ReturnCode { 0025 0026 constexpr int Success = 0x00; 0027 0028 constexpr int GenericFailure = 0x01; 0029 0030 /// @defgroup loop_stop Loop termination 0031 /// Error codes for abnormal loop termination. 0032 /// @{ 0033 constexpr int FailInput = 0x02; //< Error opening file 0034 constexpr int AlgorithmFailure = 0x03; //< 0035 constexpr int ScheduledStop = 0x04; //< Loop terminated because of user request 0036 constexpr int IncidentFailure = 0x05; //< Fatal error in Incident handling 0037 constexpr int UnhandledException = 0x06; //< 0038 constexpr int CorruptedInput = 0x10; //< Input file showed a corruption 0039 /// @} 0040 /// @{ 0041 /// Error codes for operation failures. 0042 constexpr int FinalizationFailure = 0x0b; 0043 /// @} 0044 constexpr int SignalOffset = 0x80; //< Offset for signal-related return codes 0045 } // namespace ReturnCode 0046 0047 /** 0048 * Set the application return code. 0049 * By default the return code of the application is modified only if the 0050 * original value was 0 (i.e. no error). In this way we keep the first cause 0051 * of error. 0052 * 0053 * @param appmgr IProperty interface of the ApplicationMgr 0054 * @param value value to assign to the return code 0055 * @param force if set to true, the return code is set even if it was already set 0056 * 0057 * @return SUCCESS if it was possible to set the return code or the return code was already set 0058 */ 0059 inline StatusCode setAppReturnCode( SmartIF<IProperty>& appmgr, int value, bool force = false ) { 0060 if ( appmgr ) { 0061 Gaudi::Property<int> returnCode( "ReturnCode", 0 ); 0062 if ( appmgr->getProperty( &returnCode ).isSuccess() ) { 0063 if ( returnCode.value() == 0 || force ) { 0064 returnCode.setValue( value ); 0065 return appmgr->setProperty( returnCode ); 0066 } 0067 // Consider is a success if we do already have an error code. 0068 return StatusCode::SUCCESS; 0069 } 0070 } 0071 return StatusCode::FAILURE; 0072 } 0073 0074 /** 0075 * Get the application (current) return code. 0076 * 0077 * @return the return code or 0 if it was not possible to get it 0078 */ 0079 inline int getAppReturnCode( const SmartIF<IProperty>& appmgr ) { 0080 if ( appmgr ) { 0081 Gaudi::Property<int> returnCode( "ReturnCode", 0 ); 0082 if ( appmgr->getProperty( &returnCode ).isSuccess() ) return returnCode.value(); 0083 } 0084 return 0; 0085 } 0086 } // namespace Gaudi 0087 #endif /* APPRETURNCODE_H_ */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |