RTI Connext Modern C++ API
Version 5.2.0
|
<<reference-type>> Automatically manages the association of an Entity and a Listener More...
#include <rti/core/ListenerBinder.hpp>
Inherits dds::core::Reference< DELEGATE >.
Public Member Functions | |
Listener * | get () |
Retrieves the listener. | |
const Listener * | get () const |
Retrieves the listener. | |
Public Member Functions inherited from dds::core::Reference< DELEGATE > | |
Reference (dds::core::null_type &) | |
Reference (const Reference &ref) | |
template<typename D > | |
Reference (const Reference< D > &ref) | |
~Reference () | |
template<typename R > | |
bool | operator== (const R &ref) const |
template<typename R > | |
bool | operator!= (const R &ref) const |
Reference & | operator= (const null_type) |
bool | is_nil () const |
bool | operator== (const null_type) const |
bool | operator!= (const null_type nil) const |
const DELEGATE_REF_T & | delegate () const OMG_NOEXCEPT |
DELEGATE_REF_T & | delegate () OMG_NOEXCEPT |
DELEGATE * | operator-> () OMG_NOEXCEPT |
const DELEGATE * | operator-> () const OMG_NOEXCEPT |
Related Functions | |
(Note that these are not member functions.) | |
template<typename Entity , typename Listener > | |
ListenerBinder< Entity, Listener > | bind_listener (Entity entity, Listener *the_listener, dds::core::status::StatusMask mask) |
Creates a ListenerBinder that automatically resets the listener when all references go out of scope. | |
template<typename Entity , typename Listener > | |
ListenerBinder< Entity, Listener > | bind_and_manage_listener (Entity entity, Listener *the_listener, dds::core::status::StatusMask mask) |
Creates a ListenerBinder that automatically resets the listener and deletes it when all references go out of scope. | |
<<reference-type>> Automatically manages the association of an Entity and a Listener
Ties the association listener/Entity to the existence of references to this type–that is, the constructor sets the listener and creates a reference and when the last reference is destroyed it resets the listener. Depending on how it is created it will also delete the listener or not:
rti::core::bind_listener()
creates a ListenerBinder that doesn't own the listener and won't delete itrti::core::bind_and_manage_listener()
creates a ListenerBinder that owns the listener and will delete it.The goal is to simplify the destruction of an Entity by the application, which otherwise would have to reset the listener or close the Entity explicitly.
Example:
To create a ListenerBinder use rti::core::bind_listener() or rti::core::bind_and_manage_listener(). To retrieve the listener use ListenerBinder::get().
If the Entity changes its listener while references to this ListenerBinder still exist, the ListenerBinder will not reset the listener.
Entity | A subclass of dds::core::Entity |
Listener | The listener type, by default Entity::Listener |
|
inline |
Retrieves the listener.
|
inline |
Retrieves the listener.
|
related |
Creates a ListenerBinder that automatically resets the listener when all references go out of scope.
The ListenerBinder created from this function does not delete the listener, it simply sets the listener back to NULL in the Entity. The application is responsible for the life-cycle of the listener.
To also delete the listener when all references go out of scope, see bind_and_manage_listener().
|
related |
Creates a ListenerBinder that automatically resets the listener and deletes it when all references go out of scope.
Example: