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_str > t_levels

Static Public Member Functions

static HAS_POST post_ret_type post (t_str const &, t_str const &)
static std::unique_ptr< batch_guard > batchmode ()

Private Types

typedef std::unordered_multiset< t_str > t_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 173 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 217 of file messenger.hpp.

◆ t_message_bucket

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

Definition at line 216 of file messenger.hpp.

◆ t_str

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

134{
135 return std::unique_ptr<batch_guard>(new batch_guard());
136}

◆ direct_post()

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

Definition at line 73 of file messenger.cpp.

74{
75 if (warn == l) {
76 TLOG_DEBUG(0) << static_cast<int>(messages::WARN) << m;
78 } else if (error == l) {
79 TLOG_DEBUG(0) << static_cast<int>(messages::ERROR) << m;
81 } else if (info == l) {
82 TLOG_DEBUG(0) << static_cast<int>(messages::INFO) << m;
84 } else if (fail == l) {
85 TLOG_DEBUG(0) << static_cast<int>(messages::FAIL) << m;
87 } else if (note == l) {
88 TLOG_DEBUG(0) << static_cast<int>(messages::NOTE) << m;
90 } else if (debug == l) {
91 TLOG_DEBUG(0) << static_cast<int>(messages::DEBUG) << m;
93 }
94}
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:116
static std::map< qt::t_str const, qt::t_str const > titles
Definition messenger.cpp:47

◆ merge_post()

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

Definition at line 99 of file messenger.cpp.

100{
101 auto codeit = codes.find(l);
102 assert(codeit != codes.end());
103 m_batches[static_cast<int>(codeit->second)].insert(m);
104}
static std::map< qt::t_str const, messages const > codes
Definition messenger.cpp:35

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

60{
61 std::lock_guard<std::mutex> lock(m_block);
62
63 if (m_batch_mode) {
64 merge_post(m, l);
65 } else {
66 direct_post(m, l);
67 }
68}
static std::atomic< bool > m_batch_mode
static post_ret_type merge_post(t_str const &m, t_str const &l)
Definition messenger.cpp:99
static post_ret_type direct_post(t_str const &m, t_str const &l)
Definition messenger.cpp:73

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

110{
111 for (auto clevel = m_batches.begin(); clevel != m_batches.end(); ++clevel) {
112 if (not clevel->empty()) {
113 t_str merged("Summary of messages during batch mode");
114
115 for (auto it = clevel->begin(); it != clevel->end();) {
116 auto cnt = clevel->count(*it);
117
118 t_str cmessage = *it;
119 merged += t_str("\n\n") + cmessage + t_str("\n\n #Occurances=") + std::to_string(cnt);
120
121 std::advance(it, cnt);
122 }
123
124 direct_post(merged, levels[static_cast<messages>(clevel - m_batches.begin())]);
125 clevel->clear();
126 }
127 }
128}
static std::map< messages const, qt::t_str const > levels
Definition messenger.cpp:41

◆ batch_guard

friend class batch_guard
friend

Definition at line 175 of file messenger.hpp.

Member Data Documentation

◆ m_batch_mode

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

Definition at line 214 of file messenger.hpp.

◆ m_batches

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

Definition at line 218 of file messenger.hpp.

◆ m_block

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

Definition at line 213 of file messenger.hpp.


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