iceoryx_posh 2.0.3
notification_callback.hpp
1// Copyright (c) 2021 by Apex.AI Inc. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// SPDX-License-Identifier: Apache-2.0
16
17#ifndef IOX_POSH_POPO_EVENT_CALLBACK_HPP
18#define IOX_POSH_POPO_EVENT_CALLBACK_HPP
19
20#include "iceoryx_hoofs/cxx/attributes.hpp"
21
22namespace iox
23{
24namespace popo
25{
26template <typename OriginType, typename ContextDataType>
28
29namespace internal
30{
31struct NoType_t
32{
33};
34
35using GenericCallbackPtr_t = void (*)();
36using GenericCallbackRef_t = void (&)();
37
38using TranslationCallbackRef_t = void (&)(void* const, void* const, GenericCallbackPtr_t const);
39using TranslationCallbackPtr_t = void (*)(void* const, void* const, GenericCallbackPtr_t const);
40
41template <typename T, typename ContextDataType>
42struct TranslateAndCallTypelessCallback
43{
44 static void call(void* const origin, void* const userType, GenericCallbackPtr_t underlyingCallback) noexcept;
45};
46
47template <typename T>
48struct TranslateAndCallTypelessCallback<T, NoType_t>
49{
50 static void call(void* const origin, void* const userType, GenericCallbackPtr_t underlyingCallback) noexcept;
51};
52} // namespace internal
53
56template <typename OriginType, typename ContextDataType>
58{
59 using Ref_t = void (&)(OriginType* const, ContextDataType* const);
60 using Ptr_t = void (*)(OriginType* const, ContextDataType* const);
61
62 Ptr_t m_callback = nullptr;
63 ContextDataType* m_contextData = nullptr;
64};
65
67template <typename OriginType>
68struct NotificationCallback<OriginType, internal::NoType_t>
69{
70 using Ref_t = void (&)(OriginType* const);
71 using Ptr_t = void (*)(OriginType* const);
72
73 Ptr_t m_callback = nullptr;
74 internal::NoType_t* m_contextData = nullptr;
75};
76
80template <typename OriginType, typename ContextDataType = internal::NoType_t>
81NotificationCallback<OriginType, ContextDataType>
82createNotificationCallback(void (&callback)(OriginType* const)) noexcept;
83
88template <typename OriginType, typename ContextDataType>
89NotificationCallback<OriginType, ContextDataType> createNotificationCallback(void (&callback)(OriginType* const,
90 ContextDataType* const),
91 ContextDataType& userValue) noexcept;
92
93} // namespace popo
94} // namespace iox
95
96#include "iceoryx_posh/internal/popo/notification_callback.inl"
97
98#endif
Definition: notification_callback.hpp:27
the struct describes a callback with a user defined type which can be attached to a WaitSet or a List...
Definition: notification_callback.hpp:58