diff --git a/include/etl/observer.h b/include/etl/observer.h index 50a1e045..7a637b9d 100644 --- a/include/etl/observer.h +++ b/include/etl/observer.h @@ -57,6 +57,7 @@ SOFTWARE. #include "vector.h" #include "exception.h" #include "error_handler.h" +#include "utility.h" namespace etl { @@ -153,7 +154,7 @@ namespace etl if (i_observer_item == observer_list.end()) { // Is there enough room? - ETL_ASSERT(!observer_list.full(), ETL_ERROR(etl::observer_list_full)); + ETL_ASSERT_AND_RETURN(!observer_list.full(), ETL_ERROR(etl::observer_list_full)); // Add it. observer_list.push_back(observer_item(observer)); @@ -231,6 +232,28 @@ namespace etl return observer_list.size(); } +#if ETL_CPP11_SUPPORTED && !defined(ETL_OBSERVER_FORCE_CPP03) + //***************************************************************** + /// Notify all of the observers, sending them the notification. + ///\tparam TNotification the notification type. + ///\param n The notification. + //***************************************************************** + template + void notify_observers(TNotification&& n) + { + typename Observer_List::iterator i_observer_item = observer_list.begin(); + + while (i_observer_item != observer_list.end()) + { + if (i_observer_item->enabled) + { + i_observer_item->p_observer->notification(etl::forward(n)); + } + + ++i_observer_item; + } + } +#else //***************************************************************** /// Notify all of the observers, sending them the notification. ///\tparam TNotification the notification type. @@ -251,6 +274,7 @@ namespace etl ++i_observer_item; } } +#endif protected: