Sen API
Sen Libraries
Loading...
Searching...
No Matches
sen::ObjectProvider Class Referenceabstract

Base class for an entity that is able to produce objects. More...

#include <object_provider.h>

Inheritance diagram for sen::ObjectProvider:

Public Member Functions

 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.

Protected Member Functions

virtual void notifyObjectsAdded (const ObjectAdditionList &additions)
 Calls onObjectAdded on all the registered listeners.
virtual void notifyObjectsRemoved (const ObjectRemovalList &removals)
 Calls onObjectRemoved on all the registered listeners.
virtual void listenerAdded (ObjectProviderListener *listener, bool notifyAboutExistingObjects)
 Does nothing by default.
virtual void listenerRemoved (ObjectProviderListener *listener, bool notifyAboutExistingObjects)
 Does nothing by default.
virtual void notifyAddedOnExistingObjects (ObjectProviderListener *listener)=0
 Subclasses must call onObjectAdded on the listener for all the existing objects.
virtual void notifyRemovedOnExistingObjects (ObjectProviderListener *listener)=0
 Subclasses must call onObjectRemoved on the listener for all the existing objects.
void notifyRemovedOnExistingObjectsForAllListeners ()
 Same as notifyRemovedOnExistingObjects but for all registered listeners.
void callOnObjectsAdded (ObjectProviderListener *listener, const ObjectAdditionList &additions) const
void callOnObjectsRemoved (ObjectProviderListener *listener, const ObjectRemovalList &removals) const
const std::vector< ObjectProviderListener * > & getListeners () const noexcept

Friends

class ObjectFilter

Detailed Description

Base class for an entity that is able to produce objects.

Constructor & Destructor Documentation

◆ ObjectProvider()

sen::ObjectProvider::ObjectProvider ( )
default

◆ ~ObjectProvider()

virtual sen::ObjectProvider::~ObjectProvider ( )
virtual

Member Function Documentation

◆ 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
listenerthe entity that will be notified about objects.
notifyAboutExistingObjectsif 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
listenerthe listener that was previously added.
notifyAboutExistingObjectsif 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

Does nothing by default.

◆ listenerRemoved()

virtual void sen::ObjectProvider::listenerRemoved ( ObjectProviderListener * listener,
bool notifyAboutExistingObjects )
protectedvirtual

Does nothing by default.

◆ 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: