ATLAS Offline Software
Macros
Check.h File Reference
#include "AsgMessaging/MsgStreamMacros.h"
#include "CxxUtils/AthUnlikelyMacros.h"
#include "AthenaBaseComps/AthCheckMacros.h"
Include dependency graph for Check.h:

Go to the source code of this file.

Macros

#define ASG_CHECK(...)   BOOST_PP_OVERLOAD(ASG_CHECK_, __VA_ARGS__)(__VA_ARGS__)
 Helper macro for checking the status code returned by a function call. More...
 
#define ASG_CHECK_1(EXP)
 
#define ASG_CHECK_2(EXP, RET)
 
#define ASG_CHECK_SA(SOURCE, EXP)
 Helper macro for checking the status code of a call outside of an ASG tool. More...
 

Macro Definition Documentation

◆ ASG_CHECK

#define ASG_CHECK (   ...)    BOOST_PP_OVERLOAD(ASG_CHECK_, __VA_ARGS__)(__VA_ARGS__)

Helper macro for checking the status code returned by a function call.

To be able to write code in a compact form, we can use this macro to exchange code like:

if( someFunction().isFailure() ) {
ATH_MSG_FATAL( "Failed to call function someFunction" );
return StatusCode::FAILURE;
}

With something as simple as:

ASG_CHECK( someFunction() );

or for functions that do not return a StatusCode:

ASG_CHECK( someFunction(), -1 );

The macro may only be used inside of member functions of dual-use tools.

Definition at line 40 of file Check.h.

◆ ASG_CHECK_1

#define ASG_CHECK_1 (   EXP)
Value:
do { \
const StatusCode sc__(EXP); \
if( ATH_UNLIKELY ( ! sc__.isSuccess() ) ) { \
ATH_MSG_ERROR( "Failed to call \"" << #EXP << "\"" ); \
return sc__; \
} \
} while( 0 )

Definition at line 43 of file Check.h.

◆ ASG_CHECK_2

#define ASG_CHECK_2 (   EXP,
  RET 
)
Value:
do { \
const StatusCode sc__(EXP); \
if( ATH_UNLIKELY ( ! sc__.isSuccess() ) ) { \
ATH_MSG_ERROR( "Failed to call \"" << #EXP << "\"" ); \
return RET; \
} \
} while( 0 )

Definition at line 52 of file Check.h.

◆ ASG_CHECK_SA

#define ASG_CHECK_SA (   SOURCE,
  EXP 
)
Value:
do { \
const StatusCode sc__(EXP); \
if( ATH_UNLIKELY ( ! sc__.isSuccess() ) ) { \
static MsgStream msg( SOURCE ); \
msg << MSGSTREAM_REPORT_PREFIX << MSG::ERROR \
<< "Failed to call \"" << #EXP << "\"" << endmsg; \
return sc__; \
} \
} while( 0 )

Helper macro for checking the status code of a call outside of an ASG tool.

The other version of this macro can be used to write very compact code inside a dual-use tool. But since it relies on functions provided by the dual-use tool, it can't be used in general code. For instance to check the status code returned by the initialisation function of a dual-use tool.

This version of the macro can be used in such a setup.

Definition at line 70 of file Check.h.

ATH_UNLIKELY
#define ATH_UNLIKELY(x)
Definition: AthUnlikelyMacros.h:17
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
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7