Line |
Branch |
Exec |
Source |
1 |
|
|
/************************************************************************ |
2 |
|
|
* |
3 |
|
|
* Copyright (C) 2009-2024 IRCAD France |
4 |
|
|
* Copyright (C) 2012-2019 IHU Strasbourg |
5 |
|
|
* |
6 |
|
|
* This file is part of Sight. |
7 |
|
|
* |
8 |
|
|
* Sight is free software: you can redistribute it and/or modify it under |
9 |
|
|
* the terms of the GNU Lesser General Public License as published by |
10 |
|
|
* the Free Software Foundation, either version 3 of the License, or |
11 |
|
|
* (at your option) any later version. |
12 |
|
|
* |
13 |
|
|
* Sight is distributed in the hope that it will be useful, |
14 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 |
|
|
* GNU Lesser General Public License for more details. |
17 |
|
|
* |
18 |
|
|
* You should have received a copy of the GNU Lesser General Public |
19 |
|
|
* License along with Sight. If not, see <https://www.gnu.org/licenses/>. |
20 |
|
|
* |
21 |
|
|
***********************************************************************/ |
22 |
|
|
|
23 |
|
|
#pragma once |
24 |
|
|
|
25 |
|
|
#include <sight/core/config.hpp> |
26 |
|
|
|
27 |
|
|
#include "core/macros.hpp" |
28 |
|
|
|
29 |
|
|
#include <map> |
30 |
|
|
#include <vector> |
31 |
|
|
|
32 |
|
|
namespace sight::core::com |
33 |
|
|
{ |
34 |
|
|
|
35 |
|
|
struct signal_base; |
36 |
|
|
|
37 |
|
|
/** |
38 |
|
|
* @brief This class proposes a storage for signals. |
39 |
|
|
*/ |
40 |
|
|
class SIGHT_CORE_CLASS_API signals |
41 |
|
|
{ |
42 |
|
|
public: |
43 |
|
|
|
44 |
|
|
using key_t = std::string; |
45 |
|
|
using signal_key_type = key_t; |
46 |
|
|
using signal_key_container_t = std::vector<key_t>; |
47 |
|
|
|
48 |
3/6
✓ Branch 1 taken 87715 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3325 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
|
91041 |
SIGHT_CORE_API signals() = default; |
49 |
|
87656 |
SIGHT_CORE_API virtual ~signals() = default; |
50 |
|
|
|
51 |
|
|
/// Copy constructor forbidden |
52 |
|
|
signals& operator=(const signals&) = delete; |
53 |
|
|
|
54 |
|
|
/// Registers SignalBase in m_signals |
55 |
|
|
SIGHT_CORE_API signals& operator()(const key_t& _key, const SPTR(signal_base)& _signal); |
56 |
|
|
|
57 |
|
|
/// Returns the SignalBase associated to the key, if key does not exist, the ptr is null |
58 |
|
|
SIGHT_CORE_API SPTR(signal_base) operator[](const key_t& _key) const; |
59 |
|
|
|
60 |
|
|
/// Returns all key_t registered in m_signals |
61 |
|
|
[[nodiscard]] SIGHT_CORE_API signal_key_container_t get_signal_keys() const; |
62 |
|
|
|
63 |
|
|
protected: |
64 |
|
|
|
65 |
|
|
/// Copy constructor forbidden |
66 |
|
|
signals(const signals& /*unused*/); |
67 |
|
|
|
68 |
|
|
/// Association < key , SPTR( SignalBase ) > |
69 |
|
|
using signal_map_type = std::map<key_t, SPTR(signal_base)>; |
70 |
|
|
signal_map_type m_signals; |
71 |
|
|
}; |
72 |
|
|
|
73 |
|
|
} // namespace sight::core::com |
74 |
|
|
|