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 <condition_variable>
23
#include <fstream>
24
#include <iostream>
25
#include <memory>
26
#include <mutex>
27
#include <queue>
28
#include <thread>
29
#include <vector>
30
31
#include "
dbe/macro.hpp
"
32
33
namespace
lutils
{
34
namespace
program
{
35
39
template
<
typename
UI,
typename
M = std::mutex,
typename
T = std::thread,
typename
B =
bool
>
40
class
msghandler
41
{
42
public
:
43
typedef
typename
UI::t_str
t_str
;
44
typedef
std::vector<t_str>
t_levels
;
45
51
static
msghandler
&
ref
();
52
60
void
set
(
t_str
const
& logfile);
61
69
void
setlevel
(
t_str
const
& level,
t_levels
levels);
70
76
void
message
(
t_str
const
& messagein);
77
84
void
message
(
t_str
const
& msglevel,
t_str
const
& messagein);
85
86
private
:
87
typedef
B
t_bool
;
88
89
typedef
T
t_thread
;
90
typedef
M
t_mut
;
91
typedef
std::lock_guard<t_mut>
t_lock
;
92
typedef
std::shared_ptr<t_str>
t_str_ptr
;
93
94
typedef
std::ofstream
t_file
;
95
typedef
std::unique_ptr<t_file>
t_file_ptr
;
96
97
template
<
typename
E>
98
using
t_container
= std::queue<E>;
99
typedef
t_container<std::pair<t_str, t_str>
>
t_messages
;
100
101
t_messages
m_messages
;
102
t_levels
m_levels
;
103
t_str
m_level
;
104
105
std::condition_variable
m_condition
;
106
std::mutex
m_cond_lock
;
107
108
t_str_ptr
m_logfile
;
109
t_file_ptr
m_file
;
110
111
t_thread
*
m_handler
;
112
113
t_bool
m_running
;
114
t_bool
m_have_messages
;
115
116
t_mut
m_loock
;
117
121
void
on
();
122
126
void
handle
();
127
132
template
<
typename
TR = UI>
133
typename
TR::default_post_ret_type
post
(
t_str
const
& m,
t_str
const
& l);
134
template
<
typename
TR = UI>
135
typename
TR::post_ret_type
post
(
t_str
const
& m,
t_str
const
& l);
136
141
void
file
(
t_str
const
&);
142
150
bool
levelcheck
(
t_str
const
& level)
const
;
151
156
void
reopen
(
t_str
const
&);
157
158
~msghandler
();
159
msghandler
();
160
msghandler
(
msghandler
const
&) =
delete
;
161
msghandler
&
operator=
(
msghandler
const
&) =
delete
;
162
};
163
164
}
165
/* namespace program */
166
}
/* namespace lutils */
167
168
#include "
detail/msghandler.hxx
"
169
170
#endif
/* LUTILS_MSGHANDLER_H_ */
lutils::program::msghandler::levelcheck
bool levelcheck(t_str const &level) const
Definition
msghandler.hxx:187
lutils::program::msghandler::m_loock
t_mut m_loock
Definition
msghandler.hpp:116
lutils::program::msghandler::message
void message(t_str const &messagein)
Definition
msghandler.hxx:135
lutils::program::msghandler::handle
void handle()
Definition
msghandler.hxx:103
lutils::program::msghandler::post
TR::default_post_ret_type post(t_str const &m, t_str const &l)
Definition
msghandler.hxx:159
lutils::program::msghandler::operator=
msghandler & operator=(msghandler const &)=delete
lutils::program::msghandler::m_logfile
t_str_ptr m_logfile
Definition
msghandler.hpp:108
lutils::program::msghandler::msghandler
msghandler()
Definition
msghandler.hxx:46
lutils::program::msghandler::m_cond_lock
std::mutex m_cond_lock
Definition
msghandler.hpp:106
lutils::program::msghandler::ref
static msghandler & ref()
Definition
msghandler.hxx:247
lutils::program::msghandler::msghandler
msghandler(msghandler const &)=delete
lutils::program::msghandler::t_bool
B t_bool
Definition
msghandler.hpp:87
lutils::program::msghandler::t_file
std::ofstream t_file
Definition
msghandler.hpp:94
lutils::program::msghandler::m_have_messages
t_bool m_have_messages
Definition
msghandler.hpp:114
lutils::program::msghandler::on
void on()
Definition
msghandler.hxx:86
lutils::program::msghandler::t_container
std::queue< E > t_container
Definition
msghandler.hpp:98
lutils::program::msghandler::t_lock
std::lock_guard< t_mut > t_lock
Definition
msghandler.hpp:91
lutils::program::msghandler::t_mut
M t_mut
Definition
msghandler.hpp:90
lutils::program::msghandler::t_str
UI::t_str t_str
Definition
msghandler.hpp:43
lutils::program::msghandler::m_condition
std::condition_variable m_condition
Definition
msghandler.hpp:105
lutils::program::msghandler::t_str_ptr
std::shared_ptr< t_str > t_str_ptr
Definition
msghandler.hpp:92
lutils::program::msghandler::reopen
void reopen(t_str const &)
Definition
msghandler.hxx:223
lutils::program::msghandler::t_thread
T t_thread
Definition
msghandler.hpp:89
lutils::program::msghandler::m_handler
t_thread * m_handler
Definition
msghandler.hpp:111
lutils::program::msghandler::file
void file(t_str const &)
Definition
msghandler.hxx:211
lutils::program::msghandler::m_running
t_bool m_running
Definition
msghandler.hpp:113
lutils::program::msghandler::m_level
t_str m_level
Definition
msghandler.hpp:103
lutils::program::msghandler::m_file
t_file_ptr m_file
Definition
msghandler.hpp:109
lutils::program::msghandler::m_messages
t_messages m_messages
Definition
msghandler.hpp:101
lutils::program::msghandler::t_messages
t_container< std::pair< t_str, t_str > > t_messages
Definition
msghandler.hpp:99
lutils::program::msghandler::set
void set(t_str const &logfile)
Definition
msghandler.hxx:76
lutils::program::msghandler::t_file_ptr
std::unique_ptr< t_file > t_file_ptr
Definition
msghandler.hpp:95
lutils::program::msghandler::m_levels
t_levels m_levels
Definition
msghandler.hpp:102
lutils::program::msghandler::t_levels
std::vector< t_str > t_levels
Definition
msghandler.hpp:44
lutils::program::msghandler::setlevel
void setlevel(t_str const &level, t_levels levels)
Definition
msghandler.hxx:63
macro.hpp
msghandler.hxx
lutils::program
Definition
msghandler.hxx:26
lutils
Definition
msghandler.hxx:25
Generated on
for DUNE-DAQ by
1.18.0