Tomáš Pecka | 7ff533b | 2020-07-17 15:01:16 +0200 | [diff] [blame] | 1 | /* |
| 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 | |
Tomáš Pecka | 261c886 | 2020-11-05 11:23:08 +0100 | [diff] [blame] | 9 | namespace velia::health { |
Tomáš Pecka | 7ff533b | 2020-07-17 15:01:16 +0200 | [diff] [blame] | 10 | |
| 11 | class LedOutputCallback; |
| 12 | |
| 13 | namespace boost::signals2 { |
| 14 | |
| 15 | /** |
| 16 | * Wraps a slot in a copyable class. Ensures that destructor of the Slot is called only once. |
| 17 | */ |
| 18 | template <typename Ret, typename... Args> |
| 19 | class SlotWrapper { |
| 20 | public: |
| 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 | |
| 31 | private: |
| 32 | std::shared_ptr<LedOutputCallback> m_callback; |
| 33 | }; |
| 34 | |
| 35 | } |
| 36 | |
Tomáš Pecka | 261c886 | 2020-11-05 11:23:08 +0100 | [diff] [blame] | 37 | } |