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 179 of file messenger.hpp.

Member Typedef Documentation

◆ t_batches

typedef std::array<t_message_bucket, static_cast<int>( messages::sizeme ) > dbe::interface::messenger::qt::t_batches
private

Definition at line 223 of file messenger.hpp.

◆ t_message_bucket

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

Definition at line 222 of file messenger.hpp.

◆ t_str

Definition at line 184 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 162 of file messenger.cpp.

163{
164 return std::unique_ptr<batch_guard> ( new batch_guard() );
165}

◆ direct_post()

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

Definition at line 92 of file messenger.cpp.

93{
94 if ( warn == l )
95 {
96 TLOG_DEBUG(0) << static_cast<int> ( messages::WARN ) << m ;
98 }
99 else if ( error == l )
100 {
101 TLOG_DEBUG(0) << static_cast<int> ( messages::ERROR ) << m ;
103 }
104 else if ( info == l )
105 {
106 TLOG_DEBUG(0) << static_cast<int> ( messages::INFO ) << m ;
108 }
109 else if ( fail == l )
110 {
111 TLOG_DEBUG(0) << static_cast<int> ( messages::FAIL ) << m ;
113 }
114 else if ( note == l )
115 {
116 TLOG_DEBUG(0) << static_cast<int> ( messages::NOTE ) << m ;
118 }
119 else if ( debug == l )
120 {
121 TLOG_DEBUG(0) << static_cast<int> ( messages::DEBUG ) << m ;
123 }
124}
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:60

◆ merge_post()

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

Definition at line 128 of file messenger.cpp.

129{
130 auto codeit = codes.find ( l );
131 assert ( codeit != codes.end() );
132 m_batches[static_cast<int> ( codeit->second )].insert ( m );
133}
static std::map< qt::t_str const, messages const > codes
Definition messenger.cpp:38

◆ 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 76 of file messenger.cpp.

77{
78 std::lock_guard<std::mutex> lock ( m_block );
79
80 if ( m_batch_mode )
81 {
82 merge_post ( m, l );
83 }
84 else
85 {
86 direct_post ( m, l );
87 }
88}
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:92

◆ 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 137 of file messenger.cpp.

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

◆ batch_guard

friend class batch_guard
friend

Definition at line 182 of file messenger.hpp.

Member Data Documentation

◆ m_batch_mode

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

Definition at line 220 of file messenger.hpp.

◆ m_batches

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

Definition at line 224 of file messenger.hpp.

◆ m_block

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

Definition at line 219 of file messenger.hpp.


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