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_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_) | |
![]() | |
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 | |
![]() | |
typedef const char * | string_type |
typedef int | numeric_type |
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_) | |
![]() | |
delegate_observer_exception (string_type reason_, string_type file_name_, numeric_type line_number_) | |
![]() | |
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 | |
![]() | |
typedef const char * | string_type |
typedef int | numeric_type |
class etl::delegate_observable |
The object that is being observed.
MAX_OBSERVERS | The 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) |
|
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_exception |
The base class for observer exceptions.
Public Member Functions | |
observer_exception (string_type reason_, string_type file_name_, numeric_type line_number_) | |
![]() | |
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 | |
![]() | |
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_) | |
![]() | |
observer_exception (string_type reason_, string_type file_name_, numeric_type line_number_) | |
![]() | |
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 | |
![]() | |
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 |
class etl::observer< T1, T2, T3, T4, T5, T6, T7 > |
The observer interface for seven notification types.
Additional Inherited Members | |
![]() | |
virtual void | notification (T1)=0 |
class etl::observer< T1, T2, T3, T4, T5, T6 > |
The observer interface for six notification types.
Additional Inherited Members | |
![]() | |
virtual void | notification (T1)=0 |
class etl::observer< T1, T2, T3, T4, T5 > |
The observer interface for five notification types.
Additional Inherited Members | |
![]() | |
virtual void | notification (T1)=0 |
class etl::observer< T1, T2, T3, T4 > |
The observer interface for four notification types.
Additional Inherited Members | |
![]() | |
virtual void | notification (T1)=0 |
class etl::observer< T1, T2, T3 > |
The observer interface for three notification types.
Additional Inherited Members | |
![]() | |
virtual void | notification (T1)=0 |
class etl::observer< T1, T2 > |
The observer interface for two notification types.
Additional Inherited Members | |
![]() | |
virtual void | notification (T1)=0 |
Reimplemented from etl::observer< T1 >.
class etl::observer< T1 > |