Base class for an entity that is able to produce objects.
More...
#include <object_provider.h>
|
| | ObjectProvider ()=default |
| virtual | ~ObjectProvider () |
| virtual void | addListener (ObjectProviderListener *listener, bool notifyAboutExistingObjects) |
| | Registers an event listener.
|
| virtual void | removeListener (ObjectProviderListener *listener, bool notifyAboutExistingObjects) |
| | Un-registers an event listener.
|
| virtual bool | hasListener (ObjectProviderListener *listener) const noexcept |
| | Returns true if the listener has been added.
|
| virtual bool | hasListeners () const noexcept |
| | Returns true if there are registered listeners.
|
Base class for an entity that is able to produce objects.
◆ ObjectProvider()
| sen::ObjectProvider::ObjectProvider |
( |
| ) |
|
|
default |
◆ ~ObjectProvider()
| virtual sen::ObjectProvider::~ObjectProvider |
( |
| ) |
|
|
virtual |
◆ addListener()
| virtual void sen::ObjectProvider::addListener |
( |
ObjectProviderListener * | listener, |
|
|
bool | notifyAboutExistingObjects ) |
|
virtual |
Registers an event listener.
The listener will be notified of objects being added and removed, and this provider will pass itself as the source of the objects.
A listener can be only added once to the same provider. So calling his method with the same listener will do nothing.
This provider will not take ownership of the added listener. But when a listener gets destroyed, it will ensure that it removes itself from the providers it was added to. Note that in this case your listener will not be notified about the removal of existing objects.
- Parameters
-
| listener | the entity that will be notified about objects. |
| notifyAboutExistingObjects | if true, the listener will get an immediate 'onObjectAdded' call for each existing object in the provider. |
Reimplemented in sen::ObjectMux.
◆ removeListener()
| virtual void sen::ObjectProvider::removeListener |
( |
ObjectProviderListener * | listener, |
|
|
bool | notifyAboutExistingObjects ) |
|
virtual |
Un-registers an event listener.
Does nothing if the provided event listener was not added.
- Parameters
-
| listener | the listener that was previously added. |
| notifyAboutExistingObjects | if true, the listener will get a 'onObjectRemoved' call for each existing object in the provider. |
Reimplemented in sen::ObjectMux.
◆ hasListener()
| virtual bool sen::ObjectProvider::hasListener |
( |
ObjectProviderListener * | listener | ) |
const |
|
nodiscardvirtualnoexcept |
Returns true if the listener has been added.
Reimplemented in sen::ObjectMux.
◆ hasListeners()
| virtual bool sen::ObjectProvider::hasListeners |
( |
| ) |
const |
|
nodiscardvirtualnoexcept |
Returns true if there are registered listeners.
Reimplemented in sen::ObjectMux.
◆ notifyObjectsAdded()
| virtual void sen::ObjectProvider::notifyObjectsAdded |
( |
const ObjectAdditionList & | additions | ) |
|
|
protectedvirtual |
Calls onObjectAdded on all the registered listeners.
Reimplemented in sen::ObjectMux.
◆ notifyObjectsRemoved()
| virtual void sen::ObjectProvider::notifyObjectsRemoved |
( |
const ObjectRemovalList & | removals | ) |
|
|
protectedvirtual |
Calls onObjectRemoved on all the registered listeners.
Reimplemented in sen::ObjectMux.
◆ listenerAdded()
| virtual void sen::ObjectProvider::listenerAdded |
( |
ObjectProviderListener * | listener, |
|
|
bool | notifyAboutExistingObjects ) |
|
protectedvirtual |
◆ listenerRemoved()
| virtual void sen::ObjectProvider::listenerRemoved |
( |
ObjectProviderListener * | listener, |
|
|
bool | notifyAboutExistingObjects ) |
|
protectedvirtual |
◆ notifyAddedOnExistingObjects()
| virtual void sen::ObjectProvider::notifyAddedOnExistingObjects |
( |
ObjectProviderListener * | listener | ) |
|
|
protectedpure virtual |
Subclasses must call onObjectAdded on the listener for all the existing objects.
Implemented in sen::ObjectMux.
◆ notifyRemovedOnExistingObjects()
| virtual void sen::ObjectProvider::notifyRemovedOnExistingObjects |
( |
ObjectProviderListener * | listener | ) |
|
|
protectedpure virtual |
Subclasses must call onObjectRemoved on the listener for all the existing objects.
Implemented in sen::ObjectMux.
◆ notifyRemovedOnExistingObjectsForAllListeners()
| void sen::ObjectProvider::notifyRemovedOnExistingObjectsForAllListeners |
( |
| ) |
|
|
protected |
Same as notifyRemovedOnExistingObjects but for all registered listeners.
◆ callOnObjectsAdded()
| void sen::ObjectProvider::callOnObjectsAdded |
( |
ObjectProviderListener * | listener, |
|
|
const ObjectAdditionList & | additions ) const |
|
protected |
◆ callOnObjectsRemoved()
| void sen::ObjectProvider::callOnObjectsRemoved |
( |
ObjectProviderListener * | listener, |
|
|
const ObjectRemovalList & | removals ) const |
|
protected |
◆ getListeners()
| const std::vector< ObjectProviderListener * > & sen::ObjectProvider::getListeners |
( |
| ) |
const |
|
nodiscardprotectednoexcept |
◆ ObjectFilter
| friend class ObjectFilter |
|
friend |
The documentation for this class was generated from the following file: