1.5. Set listenersΒΆ
As explained in Listeners, each Fast DDS Statistics Backend monitor has two listeners:
PhysicalListener
: Registers events about changes in the physical aspects of the communication (hosts, users, processes, and locators).DomainListener
: Registers events about changes in the DDS network (domain, participants, topics, data readers, and data writers).
Since the physical aspects of the communication can be shared across different DDS domains and Fast DDS Discovery
Server networks, only one PhysicalListener
can be set for the entire application.
Important
Even though the PhysicalListener
can be set at any time, it is recommended to set it prior to initializing any
monitoring, so that no physical events are missed.
Furthermore, it is possible to change the DomainListener
, CallbackMask
, and DataKindMask
of any
monitor at any time.
// Set a physical listener with all callbacks enabled
CustomPhysicalListener physical_listener;
StatisticsBackend::set_physical_listener(&physical_listener, CallbackMask::all());
// Init a monitor in DDS domain 0 with no listener associated
EntityId domain_monitor_id = StatisticsBackend::init_monitor(0);
// Add a domain listener to the monitor with all callbacks enabled and that does no notify
// of any statistics data
CustomDomainListener domain_listener;
StatisticsBackend::set_domain_listener(
domain_monitor_id, &domain_listener, CallbackMask::all(), DataKindMask::none());
set_domain_listener()
throws BadParameter
if the given monitor ID is not yet registered.