DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
dbe
include
dbe
msghandler.hpp
Go to the documentation of this file.
1
// DUNE DAQ modification notice:
2
// This file has been modified from the original ATLAS dbe source for the DUNE DAQ project.
3
// Fork baseline commit: dbe-02-12-17 (2022-05-12).
4
// Renamed since fork: yes (from dbe/msghandler.h to include/dbe/msghandler.hpp).
5
6
/************************************************************
7
* msghandler.h
8
*
9
* Created on: Dec 3, 2014
10
* Author: Leonidas Georgopoulos
11
*
12
* Copyright (C) 2014 Leonidas Georgopoulos
13
* Distributed under the Boost Software License, Version 1.0.
14
* (See accompanying file LICENSE_1_0.txt or
15
* copy at http://www.boost.org/LICENSE_1_0.txt)
16
*
17
************************************************************/
18
19
#ifndef LUTILS_MSGHANDLER_H_
20
#define LUTILS_MSGHANDLER_H_
21
22
#include <memory>
23
#include <mutex>
24
#include <thread>
25
#include <condition_variable>
26
#include <queue>
27
#include <fstream>
28
#include <iostream>
29
#include <vector>
30
31
#include "
dbe/macro.hpp
"
32
33
namespace
lutils
34
{
35
namespace
program
36
{
37
41
template
<
typename
UI,
typename
M = std::mutex,
typename
T = std::thread,
typename
B =
bool
>
42
class
msghandler
43
{
44
public
:
45
typedef
typename
UI::t_str
t_str
;
46
typedef
std::vector<t_str>
t_levels
;
47
53
static
msghandler
&
ref
();
54
62
void
set
(
t_str
const
& logfile );
63
71
void
setlevel
(
t_str
const
& level,
t_levels
levels );
72
78
void
message
(
t_str
const
& messagein );
79
86
void
message
(
t_str
const
& msglevel,
t_str
const
& messagein );
87
88
private
:
89
typedef
B
t_bool
;
90
91
typedef
T
t_thread
;
92
typedef
M
t_mut
;
93
typedef
std::lock_guard<t_mut>
t_lock
;
94
typedef
std::shared_ptr<t_str>
t_str_ptr
;
95
96
typedef
std::ofstream
t_file
;
97
typedef
std::unique_ptr<t_file>
t_file_ptr
;
98
99
template
<
typename
E>
using
t_container
= std::queue<E>;
100
typedef
t_container<std::pair<t_str, t_str>
>
t_messages
;
101
102
t_messages
m_messages
;
103
t_levels
m_levels
;
104
t_str
m_level
;
105
106
std::condition_variable
m_condition
;
107
std::mutex
m_cond_lock
;
108
109
110
t_str_ptr
m_logfile
;
111
t_file_ptr
m_file
;
112
113
t_thread
*
m_handler
;
114
115
t_bool
m_running
;
116
t_bool
m_have_messages
;
117
118
t_mut
m_loock
;
119
123
void
on
();
124
128
void
handle
();
129
134
template
<
typename
TR = UI>
typename
TR::default_post_ret_type
post
(
t_str
const
& m,
135
t_str
const
& l );
136
template
<
typename
TR = UI>
typename
TR::post_ret_type
post
(
t_str
const
& m,
137
t_str
const
& l );
138
143
void
file
(
t_str
const
& );
144
152
bool
levelcheck
(
t_str
const
& level )
const
;
153
158
void
reopen
(
t_str
const
& );
159
160
~msghandler
();
161
msghandler
();
162
msghandler
(
msghandler
const
& ) =
delete
;
163
msghandler
&
operator=
(
msghandler
const
& ) =
delete
;
164
};
165
166
}
167
/* namespace program */
168
}
/* namespace lutils */
169
170
#include "
detail/msghandler.hxx
"
171
172
#endif
/* LUTILS_MSGHANDLER_H_ */
lutils::program::msghandler::levelcheck
bool levelcheck(t_str const &level) const
Definition
msghandler.hxx:195
lutils::program::msghandler::m_loock
t_mut m_loock
Definition
msghandler.hpp:118
lutils::program::msghandler::message
void message(t_str const &messagein)
Definition
msghandler.hxx:145
lutils::program::msghandler::handle
void handle()
Definition
msghandler.hxx:104
lutils::program::msghandler::~msghandler
~msghandler()
Definition
msghandler.hxx:34
lutils::program::msghandler::post
TR::default_post_ret_type post(t_str const &m, t_str const &l)
Definition
msghandler.hxx:167
lutils::program::msghandler::operator=
msghandler & operator=(msghandler const &)=delete
lutils::program::msghandler::m_logfile
t_str_ptr m_logfile
Definition
msghandler.hpp:110
lutils::program::msghandler::msghandler
msghandler()
Definition
msghandler.hxx:49
lutils::program::msghandler::m_cond_lock
std::mutex m_cond_lock
Definition
msghandler.hpp:107
lutils::program::msghandler::ref
static msghandler & ref()
Definition
msghandler.hxx:259
lutils::program::msghandler::msghandler
msghandler(msghandler const &)=delete
lutils::program::msghandler::t_bool
B t_bool
Definition
msghandler.hpp:89
lutils::program::msghandler::t_file
std::ofstream t_file
Definition
msghandler.hpp:96
lutils::program::msghandler::m_have_messages
t_bool m_have_messages
Definition
msghandler.hpp:116
lutils::program::msghandler::on
void on()
Definition
msghandler.hxx:86
lutils::program::msghandler::t_container
std::queue< E > t_container
Definition
msghandler.hpp:99
lutils::program::msghandler::t_lock
std::lock_guard< t_mut > t_lock
Definition
msghandler.hpp:93
lutils::program::msghandler::t_mut
M t_mut
Definition
msghandler.hpp:92
lutils::program::msghandler::t_str
UI::t_str t_str
Definition
msghandler.hpp:45
lutils::program::msghandler::m_condition
std::condition_variable m_condition
Definition
msghandler.hpp:106
lutils::program::msghandler::t_str_ptr
std::shared_ptr< t_str > t_str_ptr
Definition
msghandler.hpp:94
lutils::program::msghandler::reopen
void reopen(t_str const &)
Definition
msghandler.hxx:233
lutils::program::msghandler::t_thread
T t_thread
Definition
msghandler.hpp:91
lutils::program::msghandler::m_handler
t_thread * m_handler
Definition
msghandler.hpp:113
lutils::program::msghandler::file
void file(t_str const &)
Definition
msghandler.hxx:222
lutils::program::msghandler::m_running
t_bool m_running
Definition
msghandler.hpp:115
lutils::program::msghandler::m_level
t_str m_level
Definition
msghandler.hpp:104
lutils::program::msghandler::m_file
t_file_ptr m_file
Definition
msghandler.hpp:111
lutils::program::msghandler::m_messages
t_messages m_messages
Definition
msghandler.hpp:102
lutils::program::msghandler::t_messages
t_container< std::pair< t_str, t_str > > t_messages
Definition
msghandler.hpp:100
lutils::program::msghandler::set
void set(t_str const &logfile)
Definition
msghandler.hxx:77
lutils::program::msghandler::t_file_ptr
std::unique_ptr< t_file > t_file_ptr
Definition
msghandler.hpp:97
lutils::program::msghandler::m_levels
t_levels m_levels
Definition
msghandler.hpp:103
lutils::program::msghandler::t_levels
std::vector< t_str > t_levels
Definition
msghandler.hpp:46
lutils::program::msghandler::setlevel
void setlevel(t_str const &level, t_levels levels)
Definition
msghandler.hxx:65
macro.hpp
msghandler.hxx
lutils::program
Definition
msghandler.hxx:28
lutils
Definition
msghandler.hxx:26
Generated on
for DUNE-DAQ by
1.17.0