#ifndef DPL_EVENT_SUPPORT_H
#define DPL_EVENT_SUPPORT_H
+#include <functional>
#include <dpl/event/event_listener.h>
#include <dpl/event/abstract_event_dispatcher.h>
#include <dpl/event/main_event_dispatcher.h>
#include <dpl/event/thread_event_dispatcher.h>
#include <dpl/event/generic_event_call.h>
#include <dpl/waitable_event.h>
-#include <dpl/fast_delegate.h>
#include <memory>
#include <dpl/exception.h>
#include <dpl/thread.h>
typedef EventSupport<EventType> EventSupportType;
typedef EventListener<EventType> EventListenerType;
- typedef FastDelegate1<const EventType &> DelegateType;
+
+ typedef void DelegateSignature(const EventType&);
+ typedef std::function<DelegateSignature> DelegateType;
class EventSupportData; // Forward declaration
typedef EventSupportData *EventSupportDataPtr;
typedef std::map<EventListenerType *, Thread *> EventListenerList;
EventListenerList m_eventListenerList;
+ struct DelegateCompare
+ {
+ bool operator()(const DelegateType& a, const DelegateType& b) const
+ {
+ return a.template target<DelegateSignature>() <
+ b.template target<DelegateSignature>();
+ }
+ };
+
// Delegate list
- typedef std::map<DelegateType, Thread *> DelegateList;
+ typedef std::map<DelegateType, Thread *, DelegateCompare> DelegateList;
DelegateList m_delegateList;
// Event support operation mutex
Mutex::ScopedLock lock(&m_listenerDelegateMutex);
// Delegate must not be empty
- Assert(!delegate.empty());
+ Assert(delegate);
// Delegate must not already exists
Assert(m_delegateList.find(delegate) == m_delegateList.end());
Mutex::ScopedLock lock(&m_listenerDelegateMutex);
// Delegate must not be empty
- Assert(!delegate.empty());
+ Assert(delegate);
// Delegate must exist
typename DelegateList::iterator iterator =
#ifndef DPL_GENERIC_EVENT_CALL_H
#define DPL_GENERIC_EVENT_CALL_H
+#include <functional>
+
#include <dpl/event/abstract_event_call.h>
#include <dpl/event/event_listener.h>
#include <dpl/noncopyable.h>
-#include <dpl/fast_delegate.h>
#include <dpl/log/log.h>
#include <dpl/assert.h>
{
public:
typedef EventListener<EventType> EventListenerType;
- typedef FastDelegate1<const EventType &> DelegateType;
+ typedef std::function<void(const EventType &)> DelegateType;
protected:
SupportDataType m_supportData;
#ifndef DPL_PROPERTY_H
#define DPL_PROPERTY_H
+#include <functional>
+
#include <dpl/event/model.h>
#include <dpl/event/event_support.h>
#include <dpl/assert.h>
#include <dpl/noncopyable.h>
#include <dpl/read_write_mutex.h>
-#include <dpl/fast_delegate.h>
#include <dpl/once.h>
namespace DPL {
Type Get() const
{
- Assert(!this->m_readValue.empty());
+ Assert(this->m_readValue);
return this->m_readValue(m_model);
}
void Set(const Type &value)
{
- Assert(!this->m_writeValue.empty());
+ Assert(this->m_writeValue);
this->m_writeValue(value, m_model);
}
};
Type Get() const
{
- Assert(!this->m_readValue.empty());
+ Assert(this->m_readValue);
m_once.Call(Once::Delegate(this, &ThisType::OnceEnsure));
return this->m_value;
}
void Set(const Type &value)
{
- Assert(!this->m_writeValue.empty());
+ Assert(this->m_writeValue);
this->m_writeValue(value, m_model);
this->m_value = value;
typedef typename EventSupport<PropertyEvent<Type> >::DelegateType
DelegateType;
- typedef FastDelegate<Type(Model *)>
+ typedef std::function<Type(Model *)>
ReadDelegateType;
- typedef FastDelegate<void (const Type &, Model *)>
+ typedef std::function<void (const Type &, Model *)>
WriteDelegateType;
protected:
Testproperty5;
MyModel() :
- Caption(this, "Foo caption"),
- Testproperty0(this, "", &ReadSomething),
+ Caption(this, std::string("Foo caption")),
+ Testproperty0(this, std::string(""), &ReadSomething),
Testproperty1(this),
Testproperty2(this),
Testproperty3(this),
- Testproperty4(this, "test", &ReadSomething, &WriteSomething),
+ Testproperty4(this, std::string("test"), &ReadSomething, &WriteSomething),
Testproperty5(this, &ReadSomething2)
{}
};