ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
CP::OutOfValidityEventHelper Class Referencefinal

a helper to translate a CP::CorrectionCode into a ::StatusCode More...

#include <OutOfValidityEventHelper.h>

Inheritance diagram for CP::OutOfValidityEventHelper:
Collaboration diagram for CP::OutOfValidityEventHelper:

Public Member Functions

template<typename T >
 OutOfValidityEventHelper (T *owner, const std::string &propertyName="outOfValidity", const std::string &propertyDescription="how to handle out of validity results")
 standard constructor More...
 
::StatusCode initialize ()
 standard initialize More...
 
::StatusCode check (const CP::CorrectionCode &code, const char *context) const
 check the correction code and do the proper thing More...
 
bool msgLvl (const MSG::Level lvl) const
 Test the output level of the object. More...
 
MsgStream & msg () const
 The standard message stream. More...
 
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream. More...
 

Private Attributes

unsigned m_action {unsigned (OutOfValidityAction::ABORT)}
 the action to take More...
 
bool m_isInitialized = false
 whether we have been initialized More...
 
std::function< MsgStream &()> m_msg
 the message stream we use More...
 

Detailed Description

a helper to translate a CP::CorrectionCode into a ::StatusCode

The prolem is OutOfValidityRange which does not have an equivalent in StatusCode and which does not have a unique, correct handling in all situations. This helper allows to configure a variety of behaviors via properties.

Definition at line 35 of file OutOfValidityEventHelper.h.

Constructor & Destructor Documentation

◆ OutOfValidityEventHelper()

template<typename T >
CP::OutOfValidityEventHelper::OutOfValidityEventHelper ( T *  owner,
const std::string &  propertyName = "outOfValidity",
const std::string &  propertyDescription = "how to handle out of validity results" 
)

standard constructor

Definition at line 69 of file OutOfValidityEventHelper.h.

72  : asg::AsgMessagingForward (owner)
73  {
74  owner->declareProperty (propertyName, m_action,
75  propertyDescription);
76  }

Member Function Documentation

◆ check()

StatusCode CP::OutOfValidityEventHelper::check ( const CP::CorrectionCode code,
const char *  context 
) const

check the correction code and do the proper thing

Definition at line 32 of file OutOfValidityEventHelper.cxx.

35  {
36  assert (m_isInitialized);
37 
38  switch (code)
39  {
41  return StatusCode::SUCCESS;
43  return StatusCode::FAILURE;
45  switch (OutOfValidityAction (m_action))
46  {
48  ANA_MSG_ERROR ("encountered OutOfValidity: " << context);
49  return StatusCode::FAILURE;
51  ANA_MSG_WARNING ("encountered OutOfValidity: " << context);
52  return StatusCode::SUCCESS;
54  return StatusCode::SUCCESS;
55  }
56  }
57  ANA_MSG_ERROR (__FILE__ << ":" << __LINE__ << ": invalid enum value encountered " << code << " " << int (m_action));
58  return StatusCode::FAILURE;
59  }

◆ initialize()

StatusCode CP::OutOfValidityEventHelper::initialize ( )

standard initialize

Definition at line 24 of file OutOfValidityEventHelper.cxx.

26  {
27  m_isInitialized = true;
28  return StatusCode::SUCCESS;
29  }

◆ msg() [1/2]

MsgStream & asg::AsgMessagingForward::msg ( ) const
inherited

The standard message stream.

Returns
A reference to the default message stream of this object.

Definition at line 24 of file AsgMessagingForward.cxx.

25  {
26  return m_msg();
27  }

◆ msg() [2/2]

MsgStream & asg::AsgMessagingForward::msg ( const MSG::Level  lvl) const
inherited

The standard message stream.

Parameters
lvlThe message level to set the stream to
Returns
A reference to the default message stream, set to level "lvl"

Definition at line 29 of file AsgMessagingForward.cxx.

30  {
31  MsgStream& msg = m_msg ();
32  msg << lvl;
33  return msg;
34  }

◆ msgLvl()

bool asg::AsgMessagingForward::msgLvl ( const MSG::Level  lvl) const
inherited

Test the output level of the object.

Parameters
lvlThe message level to test against
Returns
boolean Indicting if messages at given level will be printed
true If messages at level "lvl" will be printed

Definition at line 11 of file AsgMessagingForward.cxx.

12  {
13  MsgStream& msg = m_msg();
14  if (msg.level() <= lvl)
15  {
16  msg << lvl;
17  return true;
18  } else
19  {
20  return false;
21  }
22  }

Member Data Documentation

◆ m_action

unsigned CP::OutOfValidityEventHelper::m_action {unsigned (OutOfValidityAction::ABORT)}
private

the action to take

Definition at line 56 of file OutOfValidityEventHelper.h.

◆ m_isInitialized

bool CP::OutOfValidityEventHelper::m_isInitialized = false
private

whether we have been initialized

This is only used in debug mode to indicate a programming fault. Otherwise it is too easy for users to forget to initialize this object.

Definition at line 64 of file OutOfValidityEventHelper.h.

◆ m_msg

std::function<MsgStream& ()> asg::AsgMessagingForward::m_msg
privateinherited

the message stream we use

This used to be a simple pointer to the MsgStream itself, but in AthenaMT the actual object used is local to the thread. So instead of pointing to it directly we are now using a function to look it up, which will get the thread-local object.

Definition at line 77 of file AsgMessagingForward.h.


The documentation for this class was generated from the following files:
asg::AsgMessagingForward::m_msg
std::function< MsgStream &()> m_msg
the message stream we use
Definition: AsgMessagingForward.h:77
asg::AsgMessagingForward
base class to forward messages to another class
Definition: AsgMessagingForward.h:29
CP::OutOfValidityAction::SILENT
@ SILENT
don't print anything and return success
ANA_MSG_ERROR
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:294
CP::OutOfValidityEventHelper::m_isInitialized
bool m_isInitialized
whether we have been initialized
Definition: OutOfValidityEventHelper.h:64
asg::AsgMessagingForward::msg
MsgStream & msg() const
The standard message stream.
Definition: AsgMessagingForward.cxx:24
CP::OutOfValidityEventHelper::m_action
unsigned m_action
the action to take
Definition: OutOfValidityEventHelper.h:56
CP::OutOfValidityAction::ABORT
@ ABORT
print an error message and return a failure status code (triggering an abort)
CP::CorrectionCode::OutOfValidityRange
@ OutOfValidityRange
Input object is out of validity range.
Definition: CorrectionCode.h:37
CP::CorrectionCode::Error
@ Error
Some error happened during the object correction.
Definition: CorrectionCode.h:36
CP::OutOfValidityAction
OutOfValidityAction
the action to perform on encountering an OutOfValidityRange in OutOfValidityHelper
Definition: OutOfValidityHelper.h:36
ANA_MSG_WARNING
#define ANA_MSG_WARNING(xmsg)
Macro printing warning messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:292
pmontree.code
code
Definition: pmontree.py:443
CP::OutOfValidityAction::WARNING
@ WARNING
print a warning message and return a success status code.
CP::CorrectionCode::Ok
@ Ok
The correction was done successfully.
Definition: CorrectionCode.h:38