Add category support to StatusCode
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 thatSUCCESS
converts toTrue
) - 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 withisSuccess()
. To be discussed if this is what we want... - I kept the type of the
StatusCode
value asunsigned long
. To be discussed if we want to change this to the enum defaultint
... - 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 meanssc==StatusCode::SUCCESS
remains equivalent tosc.isSuccess
independent of the category ofsc
. -
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)