address.h
1 
5 #pragma once
6 
7 #include <memory>
8 #include <string_view>
9 
10 #include <ucp/api/ucp.h>
11 
12 #include <ucxx/address_builder.h>
13 #include <ucxx/component.h>
14 #include <ucxx/worker.h>
15 
16 namespace ucxx {
17 
18 class Address;
19 
26 class Address : public Component {
27  private:
28  ucp_address_t* _handle{nullptr};
29  size_t _length{0};
30 
47  Address(std::shared_ptr<Worker> worker, ucp_address_t* address, size_t length);
48 
49  public:
50  Address() = delete;
51  Address(const Address&) = delete;
52  Address& operator=(Address const&) = delete;
53  Address(Address&& o) = delete;
54  Address& operator=(Address&& o) = delete;
55 
56  ~Address();
57 
58  // Allow internal construction without exposing factory functions.
59  friend class detail::ConstructorFactory;
60 
76  [[nodiscard]] ucp_address_t* getHandle() const;
77 
86  [[nodiscard]] size_t getLength() const;
87 
99  [[nodiscard]] std::string_view getStringView() const;
100 };
101 
102 } // namespace ucxx
Component encapsulating the address of a UCP worker.
Definition: address.h:26
size_t getLength() const
Get the length of the ucp_address_t* handle.
ucp_address_t * getHandle() const
Get the underlying ucp_address_t* handle.
std::string_view getStringView() const
Get a non-owning view of the address as a string.
A UCXX component class to prevent early destruction of parent object.
Definition: component.h:21
Definition: address.h:16