ATLAS Offline Software
Loading...
Searching...
No Matches
MessagePrinterOverlay.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7
8
9//
10// includes
11//
12
14
17#include <cstdlib>
18
19//
20// method implementations
21//
22
23namespace asg
24{
25 MessagePrinterOverlay ::
26 MessagePrinterOverlay (IMessagePrinter *val_printer) noexcept
27 : m_saved (getCurrent()), m_current (val_printer)
28 {
29 using namespace msgAsgMessaging;
30
31 if (val_printer == nullptr)
32 {
33 ANA_MSG_FATAL ("nullptr passed illegally");
34 std::abort ();
35 }
36 getCurrent() = val_printer;
37 }
38
39
40
41 MessagePrinterOverlay ::
42 ~MessagePrinterOverlay () noexcept
43 {
44 using namespace msgAsgMessaging;
45
46 if (getCurrent() != m_current)
47 {
48 ANA_MSG_FATAL ("the overlay message printer changed underhand this should never happen");
49 std::abort ();
50 }
52 }
53
54
55
56 IMessagePrinter& MessagePrinterOverlay ::
57 current () noexcept
58 {
59 return *getCurrent();
60 }
61
62
63
64 IMessagePrinter*& MessagePrinterOverlay ::
65 getCurrent () noexcept
66 {
67 static MessagePrinter defaultPrinter;
68 static IMessagePrinter *pointer = &defaultPrinter;
69 return pointer;
70 }
71}
#define ANA_MSG_FATAL(xmsg)
Macro printing fatal messages.
IMessagePrinter * m_current
the current message printer we should have when we restore
IMessagePrinter * m_saved
the stored message printer we need to restore
static IMessagePrinter *& getCurrent() noexcept
get a reference to the pointer to the current IMessagePrinter