ATLAS Offline Software
|
an object to change the IMessagePrinter temporarily More...
#include <MessagePrinterOverlay.h>
Public Member Functions | |
MessagePrinterOverlay (IMessagePrinter *val_printer) noexcept | |
overlay with the given message printer More... | |
~MessagePrinterOverlay () noexcept | |
remove the currently overlaid printer More... | |
Static Public Member Functions | |
static IMessagePrinter & | current () noexcept |
get the current IMessagePrinter More... | |
Private Member Functions | |
MessagePrinterOverlay (MessagePrinterOverlay &)=delete | |
MessagePrinterOverlay | operator= (MessagePrinterOverlay &)=delete |
Static Private Member Functions | |
static IMessagePrinter *& | getCurrent () noexcept |
get a reference to the pointer to the current IMessagePrinter More... | |
Private Attributes | |
IMessagePrinter * | m_saved = nullptr |
the stored message printer we need to restore More... | |
IMessagePrinter * | m_current = nullptr |
the current message printer we should have when we restore More... | |
an object to change the IMessagePrinter temporarily
The idea is to use this in unit tests to replace the standard printer with a mock object. The idea is to place this on the stack and it will then replace the standard object for as long as it is on the stack.
Note that this is per se not thread-safe, but given the intended purpose that ought to be fine, i.e. there is only one MessagePrinter for all threads, so if it is replaced in a multi-threaded manner it will cause other problems.
Definition at line 28 of file MessagePrinterOverlay.h.
|
privatedelete |
|
noexcept |
overlay with the given message printer
Definition at line 25 of file MessagePrinterOverlay.cxx.
|
noexcept |
remove the currently overlaid printer
Definition at line 41 of file MessagePrinterOverlay.cxx.
|
staticnoexcept |
get the current IMessagePrinter
Definition at line 56 of file MessagePrinterOverlay.cxx.
|
staticprivatenoexcept |
get a reference to the pointer to the current IMessagePrinter
Definition at line 64 of file MessagePrinterOverlay.cxx.
|
privatedelete |
|
private |
the current message printer we should have when we restore
Definition at line 77 of file MessagePrinterOverlay.h.
|
private |
the stored message printer we need to restore
Definition at line 73 of file MessagePrinterOverlay.h.