TBBMessageSvc.h
Go to the documentation of this file.
1 #ifndef MESSAGESVC_TBBMESSAGESVC_H
2 #define MESSAGESVC_TBBMESSAGESVC_H 1
3 // Include files
4 #include "MessageSvc.h"
5 
7 
8 // just needed for the thread id
9 #include <thread>
10 
11 #include <thread>
12 
20 class TBBMessageSvc: public MessageSvc {
21 public:
23  TBBMessageSvc(const std::string& name, ISvcLocator* pSvcLocator);
24 
25  ~TBBMessageSvc() override;
26 
28  StatusCode initialize() override;
29 
31  StatusCode finalize() override;
32 
34 
36  void reportMessage(const Message& msg) override;
37 
39  void reportMessage(const Message& msg, int outputLevel) override;
40 
42  void reportMessage(const StatusCode& code, const std::string& source = "") override;
43 
44 protected:
45 private:
46 
47  // ============================================================================
48  // Helper tasks for message reporting.
49  // ============================================================================
52  public:
54  m_svc(svc),
55  m_sender(std::this_thread::get_id()) {}
56  protected:
59  };
60 
63  public:
65  MessageTaskCommon(svc),
66  m_msg(msg), m_level(level) {}
67  virtual void run() override {
69  }
70  private:
72  int m_level;
73  };
74 
77  public:
79  MessageTaskCommon(svc),
80  m_msg(msg) {}
81  virtual void run() override {
82  const int level = m_svc.outputLevel(m_msg.getSource());
83  m_svc.i_reportMessage(m_msg, level);
84  }
85  private:
87  };
88 
91  public:
92  StatusCodeMessage(TBBMessageSvc& svc, const StatusCode &sc, const std::string& source):
93  MessageTaskCommon(svc),
94  m_sc(sc),
95  m_source(source) {}
96  virtual void run() override {
97  m_svc.i_reportMessage(m_sc, m_source);
98  }
99  private:
102  };
103 
105 };
106 
107 #endif // MESSAGESVC_TBBMESSAGESVC_H
Gaudi::SerialTaskQueue m_messageQueue
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
virtual void run() override
Method to be implemented by the actual task classes.
Definition: TBBMessageSvc.h:67
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:289
virtual void i_reportMessage(const Message &msg, int outputLevel)
Internal implementation of reportMessage(const Message&,int) without lock.
Definition: MessageSvc.cpp:395
void reportMessage(const Message &msg) override
Implementation of IMessageSvc::reportMessage()
Base class for the task to be executed by the serial queue.
STL namespace.
Class for a generic serial queue of tasks (modeled on the Intel Threading Building Blocks Design Patt...
MessageWithoutLevel(TBBMessageSvc &svc, Message msg)
Definition: TBBMessageSvc.h:78
TBBMessageSvc(const std::string &name, ISvcLocator *pSvcLocator)
Standard constructor.
STL class.
Specialized class to report a message with explicit output level.
Definition: TBBMessageSvc.h:62
virtual void run() override
Method to be implemented by the actual task classes.
Definition: TBBMessageSvc.h:96
Specialized class to report a StatusCode message.
Definition: TBBMessageSvc.h:90
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
void reportMessage(const Message &message) override
Definition: MessageSvc.cpp:453
virtual void run() override
Method to be implemented by the actual task classes.
Definition: TBBMessageSvc.h:81
StatusCodeMessage(TBBMessageSvc &svc, const StatusCode &sc, const std::string &source)
Definition: TBBMessageSvc.h:92
StatusCode finalize() override
Finalization of the service.
The Message class.
Definition: Message.h:15
int outputLevel() const override
Definition: MessageSvc.cpp:621
MessageWithLevel(TBBMessageSvc &svc, Message msg, int level)
Definition: TBBMessageSvc.h:64
StatusCode initialize() override
Initialization of the service.
MessageTaskCommon(TBBMessageSvc &svc)
Definition: TBBMessageSvc.h:53
Common base class for the different reportMessage cases.
Definition: TBBMessageSvc.h:51
Specialized class to report a message with implicit output level.
Definition: TBBMessageSvc.h:76
~TBBMessageSvc() override
Destructor.