ATLAS Offline Software
Loading...
Searching...
No Matches
Check.h File Reference
#include "AsgMessaging/MsgStreamMacros.h"
#include "boost/preprocessor/facilities/overload.hpp"
#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(...)
 Helper macro for checking the status code returned by a function call.
#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.

Macro Definition Documentation

◆ ASG_CHECK

#define ASG_CHECK ( ...)
Value:
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 43 of file Check.h.

43#define ASG_CHECK(...) \
44 BOOST_PP_OVERLOAD(ASG_CHECK_, __VA_ARGS__)(__VA_ARGS__)

◆ 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 )
#define ATH_UNLIKELY(x)

Definition at line 46 of file Check.h.

46#define ASG_CHECK_1( EXP ) \
47 do { \
48 const StatusCode sc__(EXP); \
49 if( ATH_UNLIKELY ( ! sc__.isSuccess() ) ) { \
50 ATH_MSG_ERROR( "Failed to call \"" << #EXP << "\"" ); \
51 return sc__; \
52 } \
53 } while( 0 )

◆ 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 55 of file Check.h.

55#define ASG_CHECK_2( EXP, RET ) \
56 do { \
57 const StatusCode sc__(EXP); \
58 if( ATH_UNLIKELY ( ! sc__.isSuccess() ) ) { \
59 ATH_MSG_ERROR( "Failed to call \"" << #EXP << "\"" ); \
60 return RET; \
61 } \
62 } while( 0 )

◆ 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 )
#define endmsg
MsgStream & msg
Definition testRead.cxx:32

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 76 of file Check.h.

76#define ASG_CHECK_SA( SOURCE, EXP ) \
77 do { \
78 const StatusCode sc__(EXP); \
79 if( ATH_UNLIKELY ( ! sc__.isSuccess() ) ) { \
80 static MsgStream msg( SOURCE ); \
81 msg << MSGSTREAM_REPORT_PREFIX << MSG::ERROR \
82 << "Failed to call \"" << #EXP << "\"" << endmsg; \
83 return sc__; \
84 } \
85 } while( 0 )