Embedded Template Library 1.0
observer

Classes

class  etl::delegate_observer_exception
 
class  etl::delegate_observer_list_full
 
class  etl::delegate_observable< TNotification, MAX_OBSERVERS >
 
class  etl::observer_exception
 
class  etl::observer_list_full
 
class  etl::observable< TObserver, MAX_OBSERVERS >
 
class  etl::observer< T1, T2, T3, T4, T5, T6, T7, T8 >
 
class  etl::observer< T1, T2, T3, T4, T5, T6, T7 >
 
class  etl::observer< T1, T2, T3, T4, T5, T6 >
 
class  etl::observer< T1, T2, T3, T4, T5 >
 
class  etl::observer< T1, T2, T3, T4 >
 
class  etl::observer< T1, T2, T3 >
 
class  etl::observer< T1, T2 >
 
class  etl::observer< T1 >
 

Detailed Description

A templated implementation to simplify the creation of the observer pattern and attempts to eliminate certain runtime errors by turning them into compile errors. The pattern consists of two template classes.


Class Documentation

◆ etl::delegate_observer_exception

class etl::delegate_observer_exception

The base class for delegate observer exceptions.

Public Member Functions

 delegate_observer_exception (string_type reason_, string_type file_name_, numeric_type line_number_)
 
- Public Member Functions inherited from etl::exception
ETL_CONSTEXPR exception (string_type reason_, string_type, numeric_type line_)
 Constructor.
 
ETL_CONSTEXPR string_type what () const
 
ETL_CONSTEXPR string_type file_name () const
 
ETL_CONSTEXPR numeric_type line_number () const
 

Additional Inherited Members

- Public Types inherited from etl::exception
typedef const char * string_type
 
typedef int numeric_type
 

◆ etl::delegate_observer_list_full

class etl::delegate_observer_list_full

The exception thrown when the delegate observer list is full.

Public Member Functions

 delegate_observer_list_full (string_type file_name_, numeric_type line_number_)
 
- Public Member Functions inherited from etl::delegate_observer_exception
 delegate_observer_exception (string_type reason_, string_type file_name_, numeric_type line_number_)
 
- Public Member Functions inherited from etl::exception
ETL_CONSTEXPR exception (string_type reason_, string_type, numeric_type line_)
 Constructor.
 
ETL_CONSTEXPR string_type what () const
 
ETL_CONSTEXPR string_type file_name () const
 
ETL_CONSTEXPR numeric_type line_number () const
 

Additional Inherited Members

- Public Types inherited from etl::exception
typedef const char * string_type
 
typedef int numeric_type
 

◆ etl::delegate_observable

class etl::delegate_observable
template<typename TNotification, const size_t MAX_OBSERVERS>
class etl::delegate_observable< TNotification, MAX_OBSERVERS >

The object that is being observed.

Template Parameters
MAX_OBSERVERSThe maximum number of observers that can be accommodated.

Public Types

typedef etl::delegate< void(TNotification)> observer_type
 
typedef size_t size_type
 
typedef TNotification notification_type
 

Public Member Functions

void add_observer (observer_type &observer)
 
bool remove_observer (observer_type &observer)
 
void enable_observer (observer_type &observer, bool state=true)
 
void disable_observer (observer_type &observer)
 Disable an observer.
 
void clear_observers ()
 Clear all observers from the list.
 
size_type number_of_observers () const
 Returns the number of observers.
 
void notify_observers (TNotification n)
 

Member Function Documentation

◆ add_observer()

template<typename TNotification , const size_t MAX_OBSERVERS>
void etl::delegate_observable< TNotification, MAX_OBSERVERS >::add_observer ( observer_type observer)
inline

Add an observer to the list. If asserts or exceptions are enabled then an etl::observable_observer_list_full is emitted if the observer list is already full.

Parameters
observerA reference to the observer.

◆ enable_observer()

template<typename TNotification , const size_t MAX_OBSERVERS>
void etl::delegate_observable< TNotification, MAX_OBSERVERS >::enable_observer ( observer_type observer,
bool  state = true 
)
inline

Enable an observer

Parameters
observerA reference to the observer.
statetrue to enable, false to disable. Default is enable.

◆ notify_observers()

template<typename TNotification , const size_t MAX_OBSERVERS>
void etl::delegate_observable< TNotification, MAX_OBSERVERS >::notify_observers ( TNotification  n)
inline

Notify all of the observers, sending them the notification.

Template Parameters
TNotificationThe notification type.
Parameters
nThe notification.

◆ remove_observer()

template<typename TNotification , const size_t MAX_OBSERVERS>
bool etl::delegate_observable< TNotification, MAX_OBSERVERS >::remove_observer ( observer_type observer)
inline

Remove a particular observer from the list.

Parameters
observerA reference to the observer.
Returns
true if the observer was removed, false if not.

◆ etl::observer_exception

class etl::observer_exception

The base class for observer exceptions.

Public Member Functions

 observer_exception (string_type reason_, string_type file_name_, numeric_type line_number_)
 
- Public Member Functions inherited from etl::exception
ETL_CONSTEXPR exception (string_type reason_, string_type, numeric_type line_)
 Constructor.
 
ETL_CONSTEXPR string_type what () const
 
ETL_CONSTEXPR string_type file_name () const
 
ETL_CONSTEXPR numeric_type line_number () const
 

Additional Inherited Members

- Public Types inherited from etl::exception
typedef const char * string_type
 
typedef int numeric_type
 

◆ etl::observer_list_full

class etl::observer_list_full

The exception thrown when the observer list is full.

Public Member Functions

 observer_list_full (string_type file_name_, numeric_type line_number_)
 
- Public Member Functions inherited from etl::observer_exception
 observer_exception (string_type reason_, string_type file_name_, numeric_type line_number_)
 
- Public Member Functions inherited from etl::exception
ETL_CONSTEXPR exception (string_type reason_, string_type, numeric_type line_)
 Constructor.
 
ETL_CONSTEXPR string_type what () const
 
ETL_CONSTEXPR string_type file_name () const
 
ETL_CONSTEXPR numeric_type line_number () const
 

Additional Inherited Members

- Public Types inherited from etl::exception
typedef const char * string_type
 
typedef int numeric_type
 

◆ etl::observable

class etl::observable
template<typename TObserver, const size_t MAX_OBSERVERS>
class etl::observable< TObserver, MAX_OBSERVERS >

The object that is being observed.

Template Parameters
TObserverThe observer type.
MAX_OBSERVERSThe maximum number of observers that can be accommodated.

Public Types

typedef size_t size_type
 
typedef etl::vector< observer_item, MAX_OBSERVERS > Observer_List
 

Public Member Functions

void add_observer (TObserver &observer)
 
bool remove_observer (TObserver &observer)
 
void enable_observer (TObserver &observer, bool state=true)
 
void disable_observer (TObserver &observer)
 Disable an observer.
 
void clear_observers ()
 Clear all observers from the list.
 
size_type number_of_observers () const
 Returns the number of observers.
 
template<typename TNotification >
void notify_observers (TNotification n)
 

Member Function Documentation

◆ add_observer()

template<typename TObserver , const size_t MAX_OBSERVERS>
void etl::observable< TObserver, MAX_OBSERVERS >::add_observer ( TObserver &  observer)
inline

Add an observer to the list. If asserts or exceptions are enabled then an etl::observable_observer_list_full is emitted if the observer list is already full.

Parameters
observerA reference to the observer.

◆ enable_observer()

template<typename TObserver , const size_t MAX_OBSERVERS>
void etl::observable< TObserver, MAX_OBSERVERS >::enable_observer ( TObserver &  observer,
bool  state = true 
)
inline

Enable an observer

Parameters
observerA reference to the observer.
statetrue to enable, false to disable. Default is enable.

◆ notify_observers()

template<typename TObserver , const size_t MAX_OBSERVERS>
template<typename TNotification >
void etl::observable< TObserver, MAX_OBSERVERS >::notify_observers ( TNotification  n)
inline

Notify all of the observers, sending them the notification.

Template Parameters
TNotificationThe notification type.
Parameters
nThe notification.

◆ remove_observer()

template<typename TObserver , const size_t MAX_OBSERVERS>
bool etl::observable< TObserver, MAX_OBSERVERS >::remove_observer ( TObserver &  observer)
inline

Remove a particular observer from the list.

Parameters
observerA reference to the observer.
Returns
true if the observer was removed, false if not.

◆ etl::observer

class etl::observer
template<typename T1, typename T2 = void, typename T3 = void, typename T4 = void, typename T5 = void, typename T6 = void, typename T7 = void, typename T8 = void>
class etl::observer< T1, T2, T3, T4, T5, T6, T7, T8 >

The observer interface for eight notification types.

Public Member Functions

virtual void notification (T1)=0
 
virtual void notification (T2)=0
 
virtual void notification (T3)=0
 
virtual void notification (T4)=0
 
virtual void notification (T5)=0
 
virtual void notification (T6)=0
 
virtual void notification (T7)=0
 
virtual void notification (T8)=0
 

◆ etl::observer< T1, T2, T3, T4, T5, T6, T7 >

class etl::observer< T1, T2, T3, T4, T5, T6, T7 >
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
class etl::observer< T1, T2, T3, T4, T5, T6, T7 >

The observer interface for seven notification types.

Public Member Functions

virtual void notification (T1)=0
 
virtual void notification (T2)=0
 
virtual void notification (T3)=0
 
virtual void notification (T4)=0
 
virtual void notification (T5)=0
 
virtual void notification (T6)=0
 
virtual void notification (T7)=0
 

◆ etl::observer< T1, T2, T3, T4, T5, T6 >

class etl::observer< T1, T2, T3, T4, T5, T6 >
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
class etl::observer< T1, T2, T3, T4, T5, T6 >

The observer interface for six notification types.

Public Member Functions

virtual void notification (T1)=0
 
virtual void notification (T2)=0
 
virtual void notification (T3)=0
 
virtual void notification (T4)=0
 
virtual void notification (T5)=0
 
virtual void notification (T6)=0
 

◆ etl::observer< T1, T2, T3, T4, T5 >

class etl::observer< T1, T2, T3, T4, T5 >
template<typename T1, typename T2, typename T3, typename T4, typename T5>
class etl::observer< T1, T2, T3, T4, T5 >

The observer interface for five notification types.

Public Member Functions

virtual void notification (T1)=0
 
virtual void notification (T2)=0
 
virtual void notification (T3)=0
 
virtual void notification (T4)=0
 
virtual void notification (T5)=0
 

◆ etl::observer< T1, T2, T3, T4 >

class etl::observer< T1, T2, T3, T4 >
template<typename T1, typename T2, typename T3, typename T4>
class etl::observer< T1, T2, T3, T4 >

The observer interface for four notification types.

Public Member Functions

virtual void notification (T1)=0
 
virtual void notification (T2)=0
 
virtual void notification (T3)=0
 
virtual void notification (T4)=0
 

◆ etl::observer< T1, T2, T3 >

class etl::observer< T1, T2, T3 >
template<typename T1, typename T2, typename T3>
class etl::observer< T1, T2, T3 >

The observer interface for three notification types.

Public Member Functions

virtual void notification (T1)=0
 
virtual void notification (T2)=0
 
virtual void notification (T3)=0
 

◆ etl::observer< T1, T2 >

class etl::observer< T1, T2 >
template<typename T1, typename T2>
class etl::observer< T1, T2 >

The observer interface for two notification types.

Public Member Functions

virtual void notification (T1)=0
 
virtual void notification (T2)=0
 

◆ etl::observer< T1 >

class etl::observer< T1 >
template<typename T1>
class etl::observer< T1 >

The observer interface for one notification type.

Public Member Functions

virtual void notification (T1)=0