iceoryx2
C++ Bindings
Loading...
Searching...
No Matches
service_builder.hpp
Go to the documentation of this file.
1// Copyright (c) 2024 Contributors to the Eclipse Foundation
2//
3// See the NOTICE file(s) distributed with this work for additional
4// information regarding copyright ownership.
5//
6// This program and the accompanying materials are made available under the
7// terms of the Apache Software License 2.0 which is available at
8// https://www.apache.org/licenses/LICENSE-2.0, or the MIT license
9// which is available at https://opensource.org/licenses/MIT.
10//
11// SPDX-License-Identifier: Apache-2.0 OR MIT
12
13#ifndef IOX2_SERVICE_BUILDER_HPP
14#define IOX2_SERVICE_BUILDER_HPP
15
20#include "iox2/service_type.hpp"
21
22namespace iox2 {
23
25template <ServiceType S>
27 public:
28 ServiceBuilder(ServiceBuilder&& rhs) noexcept;
29 auto operator=(ServiceBuilder&& rhs) noexcept -> ServiceBuilder&;
31
33 auto operator=(const ServiceBuilder&) -> ServiceBuilder& = delete;
34
37 template <typename Payload>
39
42 auto event() && -> ServiceBuilderEvent<S>;
43
46 template <typename RequestPayload, typename ResponsePayload>
48
51 template <typename KeyType>
53
56 template <typename KeyType>
58
59 private:
60 template <ServiceType>
61 friend class Node;
62 ServiceBuilder(iox2_node_h_ref node_handle, iox2_service_name_ptr service_name_ptr);
63 void drop();
64
65 iox2_service_builder_h m_handle = nullptr;
66};
67
68template <ServiceType S>
69inline ServiceBuilder<S>::ServiceBuilder(iox2_node_h_ref node_handle, iox2_service_name_ptr service_name_ptr)
70 : m_handle { iox2_node_service_builder(node_handle, nullptr, service_name_ptr) } {
71}
72
73template <ServiceType S>
74inline void ServiceBuilder<S>::drop() {
75 if (m_handle != nullptr) {
76 iox2_service_builder_drop(m_handle);
77 m_handle = nullptr;
78 }
79}
80
81template <ServiceType S>
83 *this = std::move(rhs);
84}
85
86template <ServiceType S>
88 if (this != &rhs) {
89 drop();
90 m_handle = rhs.m_handle;
91 rhs.m_handle = nullptr;
92 }
93
94 return *this;
95}
96
97template <ServiceType S>
99 drop();
100}
101
102template <ServiceType S>
104 auto* handle = m_handle;
105 m_handle = nullptr;
106 return ServiceBuilderEvent<S> { handle };
107}
108
109template <ServiceType S>
110template <typename Payload>
112 auto* handle = m_handle;
113 m_handle = nullptr;
115}
116
117template <ServiceType S>
118template <typename RequestPayload, typename ResponsePayload>
119inline auto ServiceBuilder<
125
126template <ServiceType S>
127template <typename KeyType>
129 auto* handle = m_handle;
130 m_handle = nullptr;
132}
133
134template <ServiceType S>
135template <typename KeyType>
137 auto* handle = m_handle;
138 m_handle = nullptr;
140}
141} // namespace iox2
142#endif
Builder to create new [MessagingPattern::Blackboard] based [Service]s.
Builder to create new [MessagingPattern::Event] based [Service]s.
Builder to create new [MessagingPattern::PublishSubscribe] based [Service]s.
Builder to create or open [Service]s.
auto blackboard_creator() &&-> ServiceBuilderBlackboardCreator< KeyType, S >
auto operator=(ServiceBuilder &&rhs) noexcept -> ServiceBuilder &
ServiceBuilder(ServiceBuilder &&rhs) noexcept
ServiceBuilder(const ServiceBuilder &)=delete
auto blackboard_opener() &&-> ServiceBuilderBlackboardOpener< KeyType, S >
auto request_response() &&-> ServiceBuilderRequestResponse< RequestPayload, void, ResponsePayload, void, S >
auto event() &&-> ServiceBuilderEvent< S >
auto publish_subscribe() &&-> ServiceBuilderPublishSubscribe< Payload, void, S >
auto operator=(const ServiceBuilder &) -> ServiceBuilder &=delete