The Gaudi Framework  v29r0 (ff2e7097)
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 {
22 public:
24  TBBMessageSvc( const std::string& name, ISvcLocator* pSvcLocator );
25 
26  ~TBBMessageSvc() override;
27 
29  StatusCode initialize() override;
30 
32  StatusCode finalize() override;
33 
35 
37  void reportMessage( const Message& msg ) override;
38 
40  void reportMessage( const Message& msg, int outputLevel ) override;
41 
43  void reportMessage( const StatusCode& code, const std::string& source = "" ) override;
44 
45 protected:
46 private:
47  // ============================================================================
48  // Helper tasks for message reporting.
49  // ============================================================================
52  {
53  public:
54  MessageTaskCommon( TBBMessageSvc& svc ) : m_svc( svc ), m_sender( std::this_thread::get_id() ) {}
55 
56  protected:
59  };
60 
63  {
64  public:
66  : MessageTaskCommon( svc ), m_msg( msg ), m_level( level )
67  {
68  }
69  virtual void run() override { m_svc.i_reportMessage( m_msg, m_level ); }
70 
71  private:
73  int m_level;
74  };
75 
78  {
79  public:
80  MessageWithoutLevel( TBBMessageSvc& svc, Message msg ) : MessageTaskCommon( svc ), m_msg( msg ) {}
81  virtual void run() override
82  {
83  const int level = m_svc.outputLevel( m_msg.getSource() );
84  m_svc.i_reportMessage( m_msg, level );
85  }
86 
87  private:
89  };
90 
93  {
94  public:
95  StatusCodeMessage( TBBMessageSvc& svc, const StatusCode& sc, const std::string& source )
96  : MessageTaskCommon( svc ), m_sc( sc ), m_source( source )
97  {
98  }
99  virtual void run() override { m_svc.i_reportMessage( m_sc, m_source ); }
100 
101  private:
104  };
105 
107 };
108 
109 #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:69
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:366
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:80
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:99
Specialized class to report a StatusCode message.
Definition: TBBMessageSvc.h:92
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
boost::thread_specific_ptr< MSG::Level > m_level
void reportMessage(const Message &message) override
Definition: MessageSvc.cpp:424
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:95
StatusCode finalize() override
Finalization of the service.
The Message class.
Definition: Message.h:15
int outputLevel() const override
Definition: MessageSvc.cpp:592
MessageWithLevel(TBBMessageSvc &svc, Message msg, int level)
Definition: TBBMessageSvc.h:65
StatusCode initialize() override
Initialization of the service.
MessageTaskCommon(TBBMessageSvc &svc)
Definition: TBBMessageSvc.h:54
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:77
~TBBMessageSvc() override
Destructor.