#include <TReturnCode.h>
Public Types | |
enum | EReturnCode { kFailure = 0, kSuccess = 1, kRecoverable = 2 } |
Enumeration listing the possible return codes. More... | |
Public Member Functions | |
TReturnCode (EReturnCode code) | |
Constructor with a return code value. | |
TReturnCode (const TReturnCode &parent) | |
Copy constructor. | |
~TReturnCode () | |
Destructor. | |
TReturnCode & | operator= (const TReturnCode &rhs) |
Assignment operator. | |
EReturnCode | code () const |
The code stored internally. | |
bool | isSuccess () const |
Function checking if the function call succeeded. | |
bool | isFailure () const |
Function checking if the function call failed. | |
bool | isRecoverable () const |
Function checking if the function call produced a recoverable issue. | |
operator bool () const | |
Automatic conversion operator to a boolean. | |
void | setChecked () const |
Mark the return code as checked, ignoring it thereby. | |
void | ignore () const |
Ignore the return code, marking it as checked. | |
Static Public Member Functions | |
static void | enableFailure () |
Enable failure (with a backtrace) on an unchecked return code. | |
static void | disableFailure () |
Disable failure (no backtrace) on an unchecked return code. |
A light-weight version of StatusCode for the xAODRootAccess package
In order to force users to check return codes from the classes of xAODRootAccess (especially xAOD::TEvent), the functions now return such objects instead of booleans. The user must check the value of the returned object in all cases, using one of the member functions of the class.
The code then keeps track internally of unchecked return codes, and complains at the end of the job about them.
xAOD::TReturnCode::TReturnCode | ( | EReturnCode | code | ) |
Constructor with a return code value.
This constructor is called implicitly in 99% of all the use cases, by the code just returning an enumeration value from a function. Which gets converted into an xAOD::TReturnCode object automatically by the compiler.
code | The return code of the function |
xAOD::TReturnCode::TReturnCode | ( | const TReturnCode & | parent | ) |
Copy constructor.
The copy constructor makes sure that when we pass around return codes by value, it would be enough to just check the value of the last object in the chain. The objects that get copied can get destructed without them complaining that they were not checked.
Even if the parent object was checked, the copied object will need to be checked as well. This is how we make sure that an expression like:
xAOD::TReturnCode rc = bla();
if( rc.isFailure() ) {
std::cout << "Error" << std::endl;
return rc;
}
would work as expected.
parent | The parent object that needs to be copied |
xAOD::TReturnCode::~TReturnCode | ( | ) |
Destructor.
The destructor does the heavy lifting of the class. If the object is still unchecked at the time that it's destructed, it will either crash the application, or just register the missing check in the global registry.