iceoryx_doc  1.0.1
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_utils/cxx/attributes.hpp"
21 
22 namespace iox
23 {
24 namespace popo
25 {
26 template <typename OriginType, typename ContextDataType>
28 
29 namespace internal
30 {
31 struct NoType_t
32 {
33 };
34 
35 using GenericCallbackPtr_t = void (*)();
36 using GenericCallbackRef_t = void (&)();
37 
38 using TranslationCallbackRef_t = void (&)(void* const, void* const, GenericCallbackPtr_t const);
39 using TranslationCallbackPtr_t = void (*)(void* const, void* const, GenericCallbackPtr_t const);
40 
41 template <typename T, typename ContextDataType>
43 {
44  static void call(void* const origin, void* const userType, GenericCallbackPtr_t underlyingCallback) noexcept;
45 };
46 
47 template <typename T>
49 {
50  static void call(void* const origin, void* const userType, GenericCallbackPtr_t underlyingCallback) noexcept;
51 };
52 } // namespace internal
53 
56 template <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 
67 template <typename OriginType>
68 struct 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 
80 template <typename OriginType, typename ContextDataType = internal::NoType_t>
81 NotificationCallback<OriginType, ContextDataType> createNotificationCallback(void (&callback)(OriginType* const));
82 
87 template <typename OriginType, typename ContextDataType>
89 createNotificationCallback(void (&callback)(OriginType* const, ContextDataType* const), ContextDataType& userValue);
90 
91 } // namespace popo
92 } // namespace iox
93 
94 #include "iceoryx_posh/internal/popo/notification_callback.inl"
95 
96 #endif
Definition: service_description.hpp:29
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
Definition: notification_callback.hpp:32
Definition: notification_callback.hpp:43