Skip to content

Add category support to StatusCode

Frank Winklmeier requested to merge fwinkl/Gaudi:StatusCodeNG into master

Add support for categories (domains) to StatusCode by using typed enums and ideas from std::error_code. This change is (mostly) backwards compatible. This is based on the ideas presented at the last Gaudi workshop. The code still needs a bit of polishing but the design should be solid now.

A few remarks:

  • I scratched the idea of re-defining the StatusCode enum integer values as the collateral damage would have been too large (e.g. even on the python side we assume that SUCCESS converts to True)
  • I decided against using std::error_code directly as we don't really need all its flexibility and the code required to plug-in new categories is now quite a bit simpler. But the implementation is based on the same idea.
  • I defined an operator bool that is equivalent with isSuccess(). To be discussed if this is what we want...
  • I kept the type of the StatusCode value as unsigned long. To be discussed if we want to change this to the enum default int...
  • StatusCode values 0(FAILURE) and 1(SUCCESS) are "hard-coded" to success/failure and cannot be overridden. Also StatusCode comparisons using operator== ignore the category for these two values. This means sc==StatusCode::SUCCESS remains equivalent to sc.isSuccess independent of the category of sc.
  • setCode was removed. Could mark it as deprecated first...
  • operator long() was removed. Could mark it as deprecated first...

Some of the above points are probably best discussed during a developers meeting. But immediate feedback is highly appreciated (probably best to just look at the full StatusCode.h file instead of the rather large diff).

The first commit in the MR implements the new StatusCode class but keeping it largely backwards compatible, i.e. implicit bool/long conversions are permitted. The second commit then allows only explicit conversions and also introduces StatusCode::Category and scoped enums for all of our non-default StatusCodes. The latter means client code will have to be adjusted (e.g. clients of the ConversionSvc need to change BAD_STORAGE_TYPE to Status::BAD_STORAGE_TYPE when checking for specific StatusCode return types).

For reference, the following MRs are prerequisites: !477 (merged), !495 (merged), !517 (merged)

Edited by Frank Winklmeier

Merge request reports