endpoint_builder.h
1 
5 #pragma once
6 
7 #include <cstdint>
8 #include <memory>
9 #include <string>
10 #include <utility>
11 
12 #include <ucp/api/ucp.h>
13 
14 namespace ucxx {
15 
16 class Address;
17 class Endpoint;
18 class Listener;
19 class Worker;
20 
28 class EndpointBuilder final {
29  public:
37  EndpointBuilder(std::shared_ptr<Worker> worker, std::string ipAddress, uint16_t port);
38 
45  EndpointBuilder(std::shared_ptr<Listener> listener, ucp_conn_request_h connRequest);
46 
53  EndpointBuilder(std::shared_ptr<Worker> worker, std::shared_ptr<Address> address);
54 
57 
65  EndpointBuilder& operator=(EndpointBuilder&&) noexcept;
66 
72  operator std::shared_ptr<Endpoint>();
73 
80  EndpointBuilder& endpointErrorHandling(bool enable = true);
81 
89  [[nodiscard]] std::shared_ptr<Endpoint> build();
90 
91  private:
92  struct Impl;
93  std::unique_ptr<Impl> _impl;
94 };
95 
104 [[nodiscard]] inline EndpointBuilder endpointBuilder(std::shared_ptr<Worker> worker,
105  std::string ipAddress,
106  uint16_t port)
107 {
108  return EndpointBuilder(std::move(worker), std::move(ipAddress), port);
109 }
110 
118 [[nodiscard]] inline EndpointBuilder endpointBuilder(std::shared_ptr<Listener> listener,
119  ucp_conn_request_h connRequest)
120 {
121  return EndpointBuilder(std::move(listener), connRequest);
122 }
123 
131 [[nodiscard]] inline EndpointBuilder endpointBuilder(std::shared_ptr<Worker> worker,
132  std::shared_ptr<Address> address)
133 {
134  return EndpointBuilder(std::move(worker), std::move(address));
135 }
136 
137 } // namespace ucxx
Builder class for constructing std::shared_ptr<ucxx::Endpoint> objects.
Definition: endpoint_builder.h:28
EndpointBuilder(std::shared_ptr< Worker > worker, std::shared_ptr< Address > address)
Constructor for EndpointBuilder from a worker address.
EndpointBuilder & endpointErrorHandling(bool enable=true)
Configure endpoint error handling.
EndpointBuilder(std::shared_ptr< Worker > worker, std::string ipAddress, uint16_t port)
Constructor for EndpointBuilder from hostname and port.
std::shared_ptr< Endpoint > build()
Build and return the Endpoint.
EndpointBuilder(EndpointBuilder &&) noexcept
Move constructor.
EndpointBuilder(const EndpointBuilder &other)
Copy constructor (deep-copies internal state).
~EndpointBuilder()
EndpointBuilder destructor.
EndpointBuilder & operator=(const EndpointBuilder &other)
Copy assignment operator (deep-copies internal state).
EndpointBuilder(std::shared_ptr< Listener > listener, ucp_conn_request_h connRequest)
Constructor for EndpointBuilder from a connection request.
Component encapsulating a UCP endpoint.
Definition: endpoint.h:69
Component encapsulating a UCP worker.
Definition: worker.h:62
Definition: address.h:16
EndpointBuilder endpointBuilder(std::shared_ptr< Worker > worker, std::string ipAddress, uint16_t port)
Create an EndpointBuilder from hostname and port.
Definition: endpoint_builder.h:104