DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dbe::interface::messenger::qt Class Reference

#include <messenger.hpp>

Inheritance diagram for dbe::interface::messenger::qt:
[legend]
Collaboration diagram for dbe::interface::messenger::qt:
[legend]

Public Types

typedef std::string t_str
 
- Public Types inherited from dbe::interface::messenger::msglevels
typedef std::string t_str
 
typedef std::vector< t_strt_levels
 

Static Public Member Functions

static HAS_POST post_ret_type post (t_str const &, t_str const &)
 
static std::unique_ptr< batch_guardbatchmode ()
 

Private Types

typedef std::unordered_multiset< t_strt_message_bucket
 
typedef std::array< t_message_bucket, static_cast< int >(messages::sizeme) > t_batches
 

Private Member Functions

 qt ()=delete
 
 qt (qt const &)=delete
 
qt operator= (qt const &)=delete
 

Static Private Member Functions

static post_ret_type direct_post (t_str const &m, t_str const &l)
 
static post_ret_type merge_post (t_str const &m, t_str const &l)
 
static void purge ()
 

Static Private Attributes

static std::mutex m_block
 
static std::atomic< bool > m_batch_mode
 
static t_batches m_batches
 

Friends

class batch_guard
 

Additional Inherited Members

- Static Public Attributes inherited from dbe::interface::messenger::msglevels
static t_str const debug = "DEBUG"
 
static t_str const info = "INFO"
 
static t_str const note = "NOTE"
 
static t_str const warn = "WARN"
 
static t_str const error = "ERROR"
 
static t_str const fail = "FAIL"
 
static t_levels const all_levels = {debug, info, note, warn, error, fail}
 

Detailed Description

Messenger handles posting of messages and delegates them to the main window according to their level to be displayed as needed

Definition at line 174 of file messenger.hpp.

Member Typedef Documentation

◆ t_batches

Definition at line 218 of file messenger.hpp.

◆ t_message_bucket

std::unordered_multiset<t_str> dbe::interface::messenger::qt::t_message_bucket
private

Definition at line 217 of file messenger.hpp.

◆ t_str

Definition at line 179 of file messenger.hpp.

Constructor & Destructor Documentation

◆ qt() [1/2]

dbe::interface::messenger::qt::qt ( )
privatedelete

◆ qt() [2/2]

dbe::interface::messenger::qt::qt ( qt const & )
privatedelete

Member Function Documentation

◆ batchmode()

std::unique_ptr< batch_guard > dbe::interface::messenger::qt::batchmode ( )
static

Set returns a batch_guard object that sets m_batch_mode, which resets it batch object when it is destroyed.

Returns
a batch_guard object bound to this

Definition at line 157 of file messenger.cpp.

158{
159 return std::unique_ptr<batch_guard> ( new batch_guard() );
160}

◆ direct_post()

qt::post_ret_type dbe::interface::messenger::qt::direct_post ( t_str const & m,
t_str const & l )
staticprivate

Definition at line 87 of file messenger.cpp.

88{
89 if ( warn == l )
90 {
91 TLOG_DEBUG(0) << static_cast<int> ( messages::WARN ) << m ;
93 }
94 else if ( error == l )
95 {
96 TLOG_DEBUG(0) << static_cast<int> ( messages::ERROR ) << m ;
98 }
99 else if ( info == l )
100 {
101 TLOG_DEBUG(0) << static_cast<int> ( messages::INFO ) << m ;
103 }
104 else if ( fail == l )
105 {
106 TLOG_DEBUG(0) << static_cast<int> ( messages::FAIL ) << m ;
108 }
109 else if ( note == l )
110 {
111 TLOG_DEBUG(0) << static_cast<int> ( messages::NOTE ) << m ;
113 }
114 else if ( debug == l )
115 {
116 TLOG_DEBUG(0) << static_cast<int> ( messages::DEBUG ) << m ;
118 }
119}
void fail(t_extstr const &, t_extstr const &)
static messenger_proxy & ref()
void info(t_extstr const &, t_extstr const &)
void warn(t_extstr const &, t_extstr const &)
void error(t_extstr const &, t_extstr const &)
#define TLOG_DEBUG(lvl,...)
Definition Logging.hpp:112
static std::map< qt::t_str const, qt::t_str const > titles
Definition messenger.cpp:55

◆ merge_post()

qt::post_ret_type dbe::interface::messenger::qt::merge_post ( t_str const & m,
t_str const & l )
staticprivate

Definition at line 123 of file messenger.cpp.

124{
125 auto codeit = codes.find ( l );
126 assert ( codeit != codes.end() );
127 m_batches[static_cast<int const> ( codeit->second )].insert ( m );
128}
static std::map< qt::t_str const, messages const > codes
Definition messenger.cpp:33

◆ operator=()

qt dbe::interface::messenger::qt::operator= ( qt const & )
privatedelete

◆ post()

qt::post_ret_type dbe::interface::messenger::qt::post ( t_str const & m,
t_str const & l )
static

This method provides posting facilities for messages

Parameters
thelevel of the message to be treated
Astring message to be treatead
Returns
post_ret_type is void

Definition at line 71 of file messenger.cpp.

72{
73 std::lock_guard<std::mutex> lock ( m_block );
74
75 if ( m_batch_mode )
76 {
77 merge_post ( m, l );
78 }
79 else
80 {
81 direct_post ( m, l );
82 }
83}
static std::atomic< bool > m_batch_mode
static post_ret_type merge_post(t_str const &m, t_str const &l)
static post_ret_type direct_post(t_str const &m, t_str const &l)
Definition messenger.cpp:87

◆ purge()

void dbe::interface::messenger::qt::purge ( )
staticprivate

Takes all messages and forms a message for each groups, that is then resent for direct_post

Definition at line 132 of file messenger.cpp.

133{
134 for ( auto clevel = m_batches.begin(); clevel != m_batches.end(); ++clevel )
135 {
136 if ( not clevel->empty() )
137 {
138 t_str merged ( "Summary of messages during batch mode" );
139
140 for(auto it = clevel->begin(); it != clevel->end(); ) {
141 auto cnt = clevel->count(*it);
142
143 t_str cmessage = *it;
144 merged += t_str ( "\n\n" ) + cmessage + t_str ( "\n\n #Occurances=" ) + std::to_string(cnt);
145
146 std::advance(it, cnt);
147 }
148
149 direct_post ( merged, levels[static_cast<messages> ( clevel - m_batches.begin() )] );
150 clevel->clear();
151 }
152 }
153}
static std::map< messages const, qt::t_str const > levels
Definition messenger.cpp:44

Friends And Related Symbol Documentation

◆ batch_guard

friend class batch_guard
friend

Definition at line 177 of file messenger.hpp.

Member Data Documentation

◆ m_batch_mode

std::atomic< bool > dbe::interface::messenger::qt::m_batch_mode
staticprivate

Definition at line 215 of file messenger.hpp.

◆ m_batches

qt::t_batches dbe::interface::messenger::qt::m_batches
staticprivate

Definition at line 219 of file messenger.hpp.

◆ m_block

std::mutex dbe::interface::messenger::qt::m_block
staticprivate

Definition at line 214 of file messenger.hpp.


The documentation for this class was generated from the following files: