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 
6 #include "GaudiKernel/SerialTaskQueue.h"
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  virtual ~TBBMessageSvc();
26 
28  virtual StatusCode initialize();
29 
31  virtual StatusCode finalize();
32 
34 
36  virtual void reportMessage(const Message& msg);
37 
39  virtual void reportMessage(const Message& msg, int outputLevel);
40 
42  virtual void reportMessage(const StatusCode& code, const std::string& source = "");
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:
58  std::thread::id m_sender;
59  };
60 
63  public:
65  MessageTaskCommon(svc),
66  m_msg(msg), m_level(level) {}
67  virtual void run() {
69  }
70  private:
72  int m_level;
73  };
74 
77  public:
79  MessageTaskCommon(svc),
80  m_msg(msg) {}
81  virtual void run() {
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() {
98  }
99  private:
101  std::string m_source;
102  };
103 
105 };
106 
107 #endif // MESSAGESVC_TBBMESSAGESVC_H
Gaudi::SerialTaskQueue m_messageQueue
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
virtual void i_reportMessage(const Message &msg, int outputLevel)
Internal implementation of reportMessage(const Message&,int) without lock.
Definition: MessageSvc.cpp:447
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
virtual void run()
Method to be implemented by the actual task classes.
Definition: TBBMessageSvc.h:96
TBBMessageSvc(const std::string &name, ISvcLocator *pSvcLocator)
Standard constructor.
Specialized class to report a message with explicit output level.
Definition: TBBMessageSvc.h:62
Specialized class to report a StatusCode message.
Definition: TBBMessageSvc.h:90
virtual void run()
Method to be implemented by the actual task classes.
Definition: TBBMessageSvc.h:67
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
virtual ~TBBMessageSvc()
Destructor.
void reportMessage(const Message &message) override
Definition: MessageSvc.cpp:506
StatusCodeMessage(TBBMessageSvc &svc, const StatusCode &sc, const std::string &source)
Definition: TBBMessageSvc.h:92
The Message class.
Definition: Message.h:14
virtual void reportMessage(const Message &msg)
Implementation of IMessageSvc::reportMessage()
MessageWithLevel(TBBMessageSvc &svc, Message msg, int level)
Definition: TBBMessageSvc.h:64
const std::string & getSource() const
Get the message source.
Definition: Message.cpp:115
virtual StatusCode initialize()
Initialization of the service.
int outputLevel() const override
Definition: MessageSvc.cpp:689
MessageTaskCommon(TBBMessageSvc &svc)
Definition: TBBMessageSvc.h:53
Common base class for the different reportMessage cases.
Definition: TBBMessageSvc.h:51
virtual StatusCode finalize()
Finalization of the service.
virtual void run()
Method to be implemented by the actual task classes.
Definition: TBBMessageSvc.h:81
Specialized class to report a message with implicit output level.
Definition: TBBMessageSvc.h:76