Ring Daemon
Loading...
Searching...
No Matches
jami_signal.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2004-2026 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 "tracepoint.h"
40
41#ifdef __APPLE__
42#include <TargetConditionals.h>
43#endif
44
45#include <exception>
46#include <memory>
47#include <map>
48#include <utility>
49#include <string>
50
51namespace jami {
52
53using SignalHandlerMap = std::map<std::string, std::shared_ptr<libjami::CallbackWrapperBase>>;
55
56/*
57 * Find related user given callback and call it with given
58 * arguments.
59 */
60#pragma GCC diagnostic push
61#pragma GCC diagnostic ignored "-Wunused-parameter"
62template<typename Ts, typename... Args>
63void
65{
67
68 const auto& handlers = getSignalHandlers();
70 try {
71 auto cb = *wrap;
73 cb(args...);
75 } catch (std::exception& e) {
76 JAMI_ERR("Exception during emit signal %s:\n%s", Ts::name, e.what());
77 }
78 }
79
81}
82#pragma GCC diagnostic pop
83
84template<typename Ts>
85std::pair<std::string, std::shared_ptr<libjami::CallbackWrapper<typename Ts::cb_type>>>
87{
88 return std::make_pair((const std::string&) Ts::name,
90}
91
92} // namespace jami
#define JAMI_ERR(...)
Definition logger.h:230
std::map< std::string, std::shared_ptr< libjami::CallbackWrapperBase > > SignalHandlerMap
Definition jami_signal.h:53
void emitSignal(Args... args)
Definition jami_signal.h:64
SignalHandlerMap & getSignalHandlers()
std::pair< std::string, std::shared_ptr< libjami::CallbackWrapper< typename Ts::cb_type > > > exported_callback()
Definition jami_signal.h:86
#define jami_tracepoint(...)
Definition tracepoint.h:48
#define jami_tracepoint_if_enabled(...)
Definition tracepoint.h:49