mirror of
https://github.com/ETLCPP/etl.git
synced 2026-06-16 00:46:03 +08:00
Fixed move parameter in notify_observers
This commit is contained in:
parent
5577170fd2
commit
fa7f6dc9d7
@ -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 <typename TNotification>
|
||||
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<TNotification>(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 <typename TNotification>
|
||||
@ -274,7 +252,6 @@ namespace etl
|
||||
++i_observer_item;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@ -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 <const int ID>
|
||||
struct Notification
|
||||
{
|
||||
};
|
||||
//*****************************************************************************
|
||||
// Generic notification.
|
||||
//*****************************************************************************
|
||||
template <const int ID>
|
||||
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<Notification1, Notification2&, const Notification3&> 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<Notification1, Notification2&, const Notification3&> 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);
|
||||
}
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user