diff --git a/include/etl/observer.h b/include/etl/observer.h index 522fa84f..d22aa0a6 100644 --- a/include/etl/observer.h +++ b/include/etl/observer.h @@ -232,31 +232,9 @@ namespace etl return observer_list.size(); } -#if ETL_USING_CPP11 && !defined(ETL_OBSERVER_FORCE_CPP03_IMPLEMENTATION) //***************************************************************** /// 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. + ///\tparam TNotification The notification type. ///\param n The notification. //***************************************************************** template @@ -274,7 +252,6 @@ namespace etl ++i_observer_item; } } -#endif protected: diff --git a/test/test_observer.cpp b/test/test_observer.cpp index ef193ba1..027504f4 100644 --- a/test/test_observer.cpp +++ b/test/test_observer.cpp @@ -30,43 +30,46 @@ SOFTWARE. #include "etl/observer.h" -//***************************************************************************** -// Notification1 -//***************************************************************************** -struct Notification1 +namespace { -}; + //***************************************************************************** + // Notification1 + //***************************************************************************** + struct Notification1 + { + }; -//***************************************************************************** -// Notification2 -//***************************************************************************** -struct Notification2 -{ -}; + //***************************************************************************** + // Notification2 + //***************************************************************************** + struct Notification2 + { + }; -//***************************************************************************** -// Notification3 -//***************************************************************************** -struct Notification3 -{ -}; + //***************************************************************************** + // Notification3 + //***************************************************************************** + struct Notification3 + { + }; -//***************************************************************************** -// Generic notification. -//***************************************************************************** -template -struct Notification -{ -}; + //***************************************************************************** + // Generic notification. + //***************************************************************************** + template + struct Notification + { + }; -//***************************************************************************** -// The observer base type. -// Declare what notifications you want to observe and how they are passed to 'notification'. -// The Notification1 is passed by value. -// The Notification2 is passed by reference. -// The Notification3 is passed by const reference. -//***************************************************************************** -typedef etl::observer ObserverType; + //***************************************************************************** + // The observer base type. + // Declare what notifications you want to observe and how they are passed to 'notification'. + // The Notification1 is passed by value. + // The Notification2 is passed by reference. + // The Notification3 is passed by const reference. + //***************************************************************************** + typedef etl::observer ObserverType; +} //***************************************************************************** // The concrete observable 1 class. @@ -77,13 +80,14 @@ public: Notification1 data1; Notification2 data2; + Notification1& data3 = data1; //********************************* // Notify all of the observers. //********************************* void send_notifications() { - notify_observers(data1); + notify_observers(data3); notify_observers(data2); } };