ATLAS Offline Software
CorrectionCode.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef PATINTERFACES_CORRECTIONCODE_H
6 #define PATINTERFACES_CORRECTIONCODE_H
7 
8 #include "CxxUtils/nodiscard.h"
9 
10 namespace CP {
11 
32 
33  public:
35  enum ErrorCode {
36  Error = 0,
37  OutOfValidityRange = 1,
38  Ok = 2
39  };
40 
42  CorrectionCode( ErrorCode code = Ok ) noexcept : m_code( code ) { }
43 
45  ErrorCode code() const noexcept {return m_code;}
46 
48  operator ErrorCode() const noexcept { return code(); }
49 
52  bool operator < ( const CorrectionCode& rhs ) const noexcept {
53  return m_code < rhs.m_code;
54  }
55 
57  void ignore() const noexcept { }
58 
63  void setChecked() const noexcept { }
64  static void enableFailure() noexcept {}
65  static void disableFailure() noexcept {}
66 
67  private:
69 
70  }; // class CorrectionCode
71 
72 } // namespace CP
73 
74 namespace asg
75 {
78  template<typename T> struct CheckHelper;
79 
80  template<> struct CheckHelper<CP::CorrectionCode>
81  {
83  static inline bool isSuccess (const CP::CorrectionCode& sc) {
84  return sc == CP::CorrectionCode::Ok; }
85 
87  static inline bool isOutOfValidityRange (const CP::CorrectionCode& sc) {
89 
91  static inline CP::CorrectionCode successCode () {
92  return CP::CorrectionCode::Ok;}
93 
95  static inline CP::CorrectionCode failureCode () {
97  };
98 }
99 
100 #endif // not PATINTERFACES_CORRECTIONCODE_H
operator<
bool operator<(const DataVector< T > &a, const DataVector< T > &b)
Vector ordering relation.
asg::CheckHelper< CP::CorrectionCode >::successCode
static CP::CorrectionCode successCode()
produce a status code to report success
Definition: CorrectionCode.h:91
CP::CorrectionCode::ignore
void ignore() const noexcept
Ignore the correction code.
Definition: CorrectionCode.h:57
asg::CheckHelper
this is an internal traits class for status codes used by the ANA_CHECK* macros
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:174
asg::CheckHelper< CP::CorrectionCode >::failureCode
static CP::CorrectionCode failureCode()
produce a status code to report failure
Definition: CorrectionCode.h:95
CP::CorrectionCode::enableFailure
static void enableFailure() noexcept
Definition: CorrectionCode.h:64
asg
Definition: DataHandleTestTool.h:28
nodiscard.h
Macro wrapping the [[nodiscard]] attribute.
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:562
ATLAS_NODISCARD
#define ATLAS_NODISCARD
Definition: nodiscard.h:18
CP
Select isolated Photons, Electrons and Muons.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:48
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
CP::CorrectionCode::ErrorCode
ErrorCode
Possible values for the correction code.
Definition: CorrectionCode.h:35
CP::CorrectionCode::OutOfValidityRange
@ OutOfValidityRange
Input object is out of validity range.
Definition: CorrectionCode.h:37
asg::CheckHelper< CP::CorrectionCode >::isSuccess
static bool isSuccess(const CP::CorrectionCode &sc)
whether the status code reports a success
Definition: CorrectionCode.h:83
HTXS::ErrorCode
ErrorCode
Error code: whether the classification was successful or failed.
Definition: HiggsTemplateCrossSectionsDefs.h:12
CP::CorrectionCode::Error
@ Error
Some error happened during the object correction.
Definition: CorrectionCode.h:36
CP::CorrectionCode::code
ErrorCode code() const noexcept
The code stored internally.
Definition: CorrectionCode.h:45
CP::CorrectionCode::setChecked
void setChecked() const noexcept
Older functions for backward compatibility with the pre-nondiscard version of this class in which we ...
Definition: CorrectionCode.h:63
pmontree.code
code
Definition: pmontree.py:443
CP::CorrectionCode::m_code
ErrorCode m_code
The stored correction code.
Definition: CorrectionCode.h:68
CP::CorrectionCode::Ok
@ Ok
The correction was done successfully.
Definition: CorrectionCode.h:38
CP::CorrectionCode
Return value from object correction CP tools.
Definition: CorrectionCode.h:31
asg::CheckHelper< CP::CorrectionCode >::isOutOfValidityRange
static bool isOutOfValidityRange(const CP::CorrectionCode &sc)
whether the status code reports out of validity
Definition: CorrectionCode.h:87
CP::CorrectionCode::CorrectionCode
CorrectionCode(ErrorCode code=Ok) noexcept
Constructor with a correction code.
Definition: CorrectionCode.h:42
CP::CorrectionCode::disableFailure
static void disableFailure() noexcept
Definition: CorrectionCode.h:65