Mir
Public Member Functions | Protected Member Functions | List of all members
mir::ObserverRegistrar< Observer > Class Template Referenceabstract

Register observers for a subsystem. More...

#include <observer_registrar.h>

Public Member Functions

virtual void register_interest (std::weak_ptr< Observer > const &observer)=0
 Add an observer to the set notified of all observations. More...
 
virtual void register_interest (std::weak_ptr< Observer > const &observer, Executor &executor)=0
 Add an observer with specified execution environment. More...
 
virtual void unregister_interest (Observer const &observer)=0
 Remove an observer from the set notified of all observations. More...
 

Protected Member Functions

 ObserverRegistrar ()=default
 
virtual ~ObserverRegistrar ()=default
 
 ObserverRegistrar (ObserverRegistrar const &)=delete
 
ObserverRegistraroperator= (ObserverRegistrar const &)=delete
 

Detailed Description

template<class Observer>
class mir::ObserverRegistrar< Observer >

Register observers for a subsystem.

Template Parameters
ObserverThe Observer type to register

Constructor & Destructor Documentation

template<class Observer >
mir::ObserverRegistrar< Observer >::ObserverRegistrar ( )
protecteddefault
template<class Observer >
virtual mir::ObserverRegistrar< Observer >::~ObserverRegistrar ( )
protectedvirtualdefault
template<class Observer >
mir::ObserverRegistrar< Observer >::ObserverRegistrar ( ObserverRegistrar< Observer > const &  )
protecteddelete

Member Function Documentation

template<class Observer >
ObserverRegistrar& mir::ObserverRegistrar< Observer >::operator= ( ObserverRegistrar< Observer > const &  )
protecteddelete
template<class Observer >
virtual void mir::ObserverRegistrar< Observer >::register_interest ( std::weak_ptr< Observer > const &  observer)
pure virtual

Add an observer to the set notified of all observations.

The ObserverRegistrar does not take any ownership of observer, and will automatically remove it when observer expires.

Parameters
[in]observerThe observer to register
template<class Observer >
virtual void mir::ObserverRegistrar< Observer >::register_interest ( std::weak_ptr< Observer > const &  observer,
Executor executor 
)
pure virtual

Add an observer with specified execution environment.

This is threadsafe and can be called in any context.

The ObserverRegistrar does not take any ownership of observer, and will automatically remove it when observer expires.

All calls to observer methods are performed in the context of executor.

The executor should process work in a delayed fashion. Particularly, executor::spawn(work) is expected to not run work in the current stack. Eager execution of work may result in deadlocks if calls to the observer result in calls into the ObserverRegistrar.

Parameters
[in]observerThe observer to register
[in]executorExecution environment for calls to observer methods. The caller is responsible for ensuring executor outlives observer.
template<class Observer >
virtual void mir::ObserverRegistrar< Observer >::unregister_interest ( Observer const &  observer)
pure virtual

Remove an observer from the set notified of all observations.

This is threadsafe and can be called in any context. It is not guaranteed that methods of observer will not be called after this returns.

Parameters
observer[in] The observer to unregister

The documentation for this class was generated from the following file:

Copyright © 2012-2016 Canonical Ltd.
Generated on Wed Oct 11 22:26:23 UTC 2017