Ring Daemon 16.0.0
Loading...
Searching...
No Matches
ring_signal.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2004-2025 Savoir-faire Linux Inc.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17#pragma once
18
19#ifdef HAVE_CONFIG_H
20#include "config.h"
21#endif
22
28
29#ifdef ENABLE_VIDEO
31#endif
32
33#ifdef ENABLE_PLUGIN
35#endif
36
37#include "jami.h"
38#include "logger.h"
39#include "trace-tools.h"
40#include "tracepoint.h"
41
42#ifdef __APPLE__
43#include <TargetConditionals.h>
44#endif
45
46#include <exception>
47#include <memory>
48#include <map>
49#include <utility>
50#include <string>
51
52namespace jami {
53
54using SignalHandlerMap = std::map<std::string, std::shared_ptr<libjami::CallbackWrapperBase>>;
56
57/*
58 * Find related user given callback and call it with given
59 * arguments.
60 */
61#pragma GCC diagnostic push
62#pragma GCC diagnostic ignored "-Wunused-parameter"
63template<typename Ts, typename... Args>
65{
67
68 const auto& handlers = getSignalHandlers();
70 try {
71 auto cb = *wrap;
73 wrap.file_, wrap.linum_);
74 cb(args...);
76 } catch (std::exception& e) {
77 JAMI_ERR("Exception during emit signal %s:\n%s", Ts::name, e.what());
78 }
79 }
80
82}
83#pragma GCC diagnostic pop
84
85template<typename Ts>
86std::pair<std::string, std::shared_ptr<libjami::CallbackWrapper<typename Ts::cb_type>>>
88{
89 return std::make_pair((const std::string&) Ts::name,
91}
92
93} // namespace jami
#define JAMI_ERR(...)
Definition logger.h:218
std::map< std::string, std::shared_ptr< libjami::CallbackWrapperBase > > SignalHandlerMap
Definition ring_signal.h:54
void emitSignal(Args... args)
Definition ring_signal.h:64
SignalHandlerMap & getSignalHandlers()
std::pair< std::string, std::shared_ptr< libjami::CallbackWrapper< typename Ts::cb_type > > > exported_callback()
Definition ring_signal.h:87
#define jami_tracepoint(...)
Definition tracepoint.h:53
#define jami_tracepoint_if_enabled(...)
Definition tracepoint.h:54