Finding a Subscriber’s Related Entities
These Subscriber operations are useful for obtaining a handle to related entities:
- get_participant(): Gets the DomainParticipant with which a Subscriber was created.
- lookup_datareader(): Finds a DataReader created by the Subscriber with a Topic of a particular name. Note that if multiple DataReaders were created by the same Subscriber with the same Topic, any one of them may be returned by this method.
You can use this operation on a built-in Subscriber to access the built-in DataReaders for the built-in topics. The built-in DataReader is created when this operation is called on a built-in topic for the first time.
If you are going to modify the transport properties for the built-in DataReaders, do so before using this operation. Built-in transports are implicitly registered when the DomainParticipant is enabled or the first DataWriter/DataReader is created. To ensure that built-in DataReaders receive all the discovery traffic, you should lookup the DataReader before the DomainParticipant is enabled. Therefore the suggested sequence when looking up built-in DataReaders is:
- Create a disabled DomainParticipant (see ENTITYFACTORY QosPolicy).
- If you want to use non-default values, modify the built-in transport properties (see Setting Builtin Transport Properties of Default Transport Instance—get/set_builtin_transport_properties()).
- Call get_builtin_subscriber() (see Built-in DataReaders).
- Call lookup_datareader().
- Call enable() on the DomainParticipant (see Enabling DDS Entities).
- DDS_Subscriber_as_Entity(): This method is provided for C applications and is necessary when invoking the parent class Entity methods on Subscribers. For example, to call the Entity method get_status_changes() on a Subscriber, my_sub, do the following:
DDS_Entity_get_status_changes(DDS_Subscriber_as_Entity(my_sub))
- DDS_Subscriber_as_Entity() is not provided in the C++, C++/CLI, C# and Java APIs because the object-oriented features of those languages make it unnecessary.
© 2016 RTI