eclipse-cyclonedds / cyclonedds-cxx

Other
96 stars 75 forks source link

Question - Need a way to get the GUID for any entity in C++ #466

Open ashishkcork opened 10 months ago

ashishkcork commented 10 months ago

Hi, I am using the cyconedds-cxx and fairly new to this. I am am trying to get the GUID of different entities like domain-participant, publisher, subscriber, reader, writer. Is there a way to get this? Little struggling to get this through the current documentation and examples.

I see that many of these classes have this API called instance_handle() which has another member called handle(). which is of this type. typedef uint64_t dds_instance_handle_t;

I have an option access to link the cyclonedds (C library). -- There I see the API to get the GUID.

void foo(dds_entity_t handle) { dds_guid_t guid_h; dds_get_guid(handle, &guid_h) }

where this dds_entity_t coming from C library. typedef int32_t dds_entity_t;

I was thinking if we can get the corresponding dds_entity_t from the C++ dds_instance_handle_t so that I can somehow get the GUID of any entity.

Any pointers/help will be highly appreciated. It's not an issue, Just want to know the answer, kind of question.

eboasson commented 9 months ago

Hi @ashishkcork, I suppose this is yet another one of those cases where the C++ API doesn't fully cover the C API. It should, and I am it sure it would if C++ was my preferred language ...

Anyway:

I was thinking if we can get the corresponding dds_entity_t from the C++ dds_instance_handle_t so that I can somehow get the GUID of any entity.

I can help you with:

DomainParticipant dp();
dds_entity_t c_handle = dp->get_ddsc_entity();

should work (mind the -> instead of .; this should work for C++ participants, readers and writers) Then you can indeed do dds_get_guid(c_handle...) like you were thinking.

ashishkumarforgit commented 9 months ago

Thanks for the help. Very much appreciated.