address.h
1 
5 #pragma once
6 
7 #include <memory>
8 #include <string>
9 #include <string_view>
10 
11 #include <ucp/api/ucp.h>
12 
13 #include <ucxx/component.h>
14 #include <ucxx/worker.h>
15 
16 namespace ucxx {
17 
24 class Address : public Component {
25  private:
26  ucp_address_t* _handle{nullptr};
27  size_t _length{0};
28 
46  Address(std::shared_ptr<Worker> worker, ucp_address_t* address, size_t length);
47 
48  public:
49  Address() = delete;
50  Address(const Address&) = delete;
51  Address& operator=(Address const&) = delete;
52  Address(Address&& o) = delete;
53  Address& operator=(Address&& o) = delete;
54 
55  ~Address();
56 
67  friend std::shared_ptr<Address> createAddressFromWorker(std::shared_ptr<Worker> worker);
68 
79  friend std::shared_ptr<Address> createAddressFromString(std::string_view addressString);
80 
96  [[nodiscard]] ucp_address_t* getHandle() const;
97 
106  [[nodiscard]] size_t getLength() const;
107 
119  [[nodiscard]] std::string_view getStringView() const;
120 
129  [[deprecated("Removing in UCXX 0.51. Switch to `getStringView`.")]] [[nodiscard]] std::string
130  getString() const;
131 };
132 
133 } // namespace ucxx
Component encapsulating the address of a UCP worker.
Definition: address.h:24
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.
friend std::shared_ptr< Address > createAddressFromString(std::string_view addressString)
Constructor for shared_ptr<ucxx::Address> from string.
friend std::shared_ptr< Address > createAddressFromWorker(std::shared_ptr< Worker > worker)
Constructor for shared_ptr<ucxx::Address> from worker.
std::string_view getStringView() const
Get a non-owning view of the address as a string.
std::string getString() const
Get the address as a string.
A UCXX component class to prevent early destruction of parent object.
Definition: component.h:17
Definition: address.h:16