DomainParticipant Listener¶
DomainParticipantListener is an abstract class defining the callbacks that will be triggered in response to state changes on the DomainParticipant.
By default, all these callbacks are empty and do nothing.
Implementations of this class shall override the callbacks that are needed on the application.
Callbacks that are not overridden will maintain their empty implementation.
DomainParticipantListener inherits from Topic Listener, Publisher Listener and Subscriber Listener. Therefore, it has the ability to react to every kind of event that is reported to any of its attached Entities.
Since events are always notified to the most specific Entity Listener that can handle the event,
callbacks that DomainParticipantListener inherits from other Listeners will only be called if no other Entity handled the event,
either because it had no Listener attached, or because the callback was disabled by the StatusMask on the Entity.
Example¶
class CustomDomainParticipantListener :
public DomainParticipantListener
{
void on_inconsistent_topic(
Topic& /* topic */,
const InconsistentTopicStatus& /* status */) noexcept override
{
std::cout << "Inconsistent topic found" << std::endl;
}
void on_publication_matched(
DataWriter& /* writer */,
const PublicationMatchedStatus& /* info */) noexcept override
{
std::cout << "Publication matched" << std::endl;
}
void on_offered_deadline_missed(
DataWriter& /* writer */,
const OfferedDeadlineMissedStatus& /* status */) noexcept override
{
std::cout << "Offered deadline missed in datawriter" << std::endl;
}
void on_offered_incompatible_qos(
DataWriter& /* writer */,
const OfferedIncompatibleQosStatus& /* status */) noexcept override
{
std::cout << "Offered incompatible QoS in datawriter" << std::endl;
}
void on_liveliness_lost(
DataWriter& /* writer */,
const LivelinessLostStatus& /* status */) noexcept override
{
std::cout << "Liveliness lost in datawriter" << std::endl;
}
void on_data_on_readers(
Subscriber& /* subscriber */) noexcept override
{
std::cout << "Data on readers" << std::endl;
}
void on_data_available(
DataReader& /* reader */) noexcept override
{
std::cout << "Data available on datareader" << std::endl;
}
void on_subscription_matched(
DataReader& /* reader */,
const SubscriptionMatchedStatus& /* info */) noexcept override
{
std::cout << "Subscription matched" << std::endl;
}
void on_requested_deadline_missed(
DataReader& /* reader */,
const RequestedDeadlineMissedStatus& /* status */) noexcept override
{
std::cout << "Requested deadline missed in datareader" << std::endl;
}
void on_liveliness_changed(
DataReader& /* reader */,
const LivelinessChangedStatus& /* status */) noexcept override
{
std::cout << "Liveliness changed in datareader" << std::endl;
}
void on_sample_rejected(
DataReader& /* reader */,
const SampleRejectedStatus& /* status */) noexcept override
{
std::cout << "Sample rejected in datareader" << std::endl;
}
void on_requested_incompatible_qos(
DataReader& /* reader */,
const RequestedIncompatibleQosStatus& /* status */) noexcept override
{
std::cout << "Requested incompatible QoS in datareader" << std::endl;
}
void on_sample_lost(
DataReader& /* reader */,
const SampleLostStatus& /* status */) noexcept override
{
std::cout << "Sample lost in datareader" << std::endl;
}
};