|
Embedded Template Library 1.0
|
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 etl::delegate_observable |
An obserable type that uses delegates to notify observers.
| TNotification | The notification type sent to the observers. |
| Max_Observers | The maximum number of observers that can be accommodated. |
Public Types | |
| typedef etl::delegate< void(TNotification)> | delegate_type |
| The type of the observers. | |
| typedef size_t | size_type |
| The type for sizes. | |
| typedef TNotification | notification_type |
| The type of the notification. | |
Public Member Functions | |
| ETL_CONSTEXPR14 | delegate_observable () |
| Default constructor. | |
| ETL_CONSTEXPR14 bool | add_observer (delegate_type observer) |
| ETL_CONSTEXPR14 bool | remove_observer (const delegate_type &observer) |
| ETL_CONSTEXPR14 void | clear_observers () |
| Clear all observers. | |
| ETL_CONSTEXPR14 size_type | number_of_observers () const |
| Returns the number of observers. | |
| ETL_CONSTEXPR14 void | notify_observers (notification_type n) const |
|
inline |
Add an observer to the list.
| observer | A reference to the observer. |
|
inline |
Notify all of the observers, sending them the notification.
| TNotification | The notification type. |
| n | The notification. |
|
inline |
Remove a particular observer from the list.
| observer | A reference to the observer. |
| 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 |
| 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 |
| class etl::observable |
The object that is being observed.
| TObserver | The observer type. |
| Max_Observers | The 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) |
| void | notify_observers () |
| Notify all of the observers, sending them the notification. | |
|
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.
| observer | A reference to the observer. |
|
inline |
Enable an observer
| observer | A reference to the observer. |
| state | true to enable, false to disable. Default is enable. |
|
inline |
Notify all of the observers, sending them the notification.
| TNotification | The notification type. |
| n | The notification. |
|
inline |
Remove a particular observer from the list.
| observer | A reference to the observer. |
| class etl::observer |
The observer interface for eight notification types.
| class etl::observer< T1, T2, T3, T4, T5, T6, T7 > |
The observer interface for seven notification types.
Additional Inherited Members | |
| Public Member Functions inherited from etl::observer< T1 > | |
| virtual void | notification (T1)=0 |
|
inlinevirtual |
Reimplemented from etl::observer< T1 >.
| class etl::observer< T1, T2, T3, T4, T5, T6 > |
The observer interface for six notification types.
Additional Inherited Members | |
| Public Member Functions inherited from etl::observer< T1 > | |
| virtual void | notification (T1)=0 |
|
inlinevirtual |
Reimplemented from etl::observer< T1 >.
| class etl::observer< T1, T2, T3, T4, T5 > |
The observer interface for five notification types.
Additional Inherited Members | |
| Public Member Functions inherited from etl::observer< T1 > | |
| virtual void | notification (T1)=0 |
|
inlinevirtual |
Reimplemented from etl::observer< T1 >.
| class etl::observer< T1, T2, T3, T4 > |
The observer interface for four notification types.
Additional Inherited Members | |
| Public Member Functions inherited from etl::observer< T1 > | |
| virtual void | notification (T1)=0 |
|
inlinevirtual |
Reimplemented from etl::observer< T1 >.
| class etl::observer< T1, T2, T3 > |
The observer interface for three notification types.
Additional Inherited Members | |
| Public Member Functions inherited from etl::observer< T1 > | |
| virtual void | notification (T1)=0 |
|
inlinevirtual |
Reimplemented from etl::observer< T1 >.
| class etl::observer< T1, T2 > |
The observer interface for two notification types.
Additional Inherited Members | |
| Public Member Functions inherited from etl::observer< T1 > | |
| virtual void | notification (T1)=0 |
|
inlinevirtual |
Reimplemented from etl::observer< T1 >.
| class etl::observer< T1 > |