xAOD::TReturnCode Class Reference

#include <TReturnCode.h>

List of all members.

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.
TReturnCodeoperator= (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.

Detailed Description

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.

Author:
Attila Krasznahorkay <Attila.Krasznahorkay@cern.ch>
Revision
598368
Date
2014-05-22 12:23:54 +0200 (Thu, 22 May 2014)

Member Enumeration Documentation

Enumeration listing the possible return codes.

Enumerator:
kFailure 

The function call failed.

kSuccess 

The function call succeeded

kRecoverable 

The function call didn't succeed, but there's no fatal failure either


Constructor & Destructor Documentation

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.

Parameters:
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.

Parameters:
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.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 15 Apr 2017 for RootCore Packages by  doxygen 1.6.1