blob: c01ee6ce7a00103eb9a67be90e1ddf1536c2a6d4 [file] [log] [blame]
Tomáš Pecka7ff533b2020-07-17 15:01:16 +02001/*
2 * Copyright (C) 2020 CESNET, https://photonics.cesnet.cz/
3 *
4 * Written by Tomáš Pecka <tomas.pecka@fit.cvut.cz>
5 *
6*/
7#pragma once
8
9namespace velia {
10
11class LedOutputCallback;
12
13namespace boost::signals2 {
14
15/**
16 * Wraps a slot in a copyable class. Ensures that destructor of the Slot is called only once.
17 */
18template <typename Ret, typename... Args>
19class SlotWrapper {
20public:
21 explicit SlotWrapper(std::shared_ptr<LedOutputCallback> callback)
22 : m_callback(callback)
23 {
24 }
25
26 Ret operator()(Args... args)
27 {
28 (*m_callback)(args...);
29 }
30
31private:
32 std::shared_ptr<LedOutputCallback> m_callback;
33};
34
35}
36
37}