17 #ifndef mitkMessageHIncluded
18 #define mitkMessageHIncluded
21 #include <itkSimpleFastMutexLock.h>
28 #define mitkNewMessageMacro(msgHandleObject) \
30 ::mitk::Message<> m_##msgHandleObject##Message; \
33 inline void Add##msgHandleObject##Listener(const ::mitk::MessageAbstractDelegate<> &delegate) \
35 m_##msgHandleObject##Message += delegate; \
37 inline void Remove##msgHandleObject##Listener(const ::mitk::MessageAbstractDelegate<> &delegate) \
39 m_##msgHandleObject##Message -= delegate; \
42 #define mitkNewMessageWithReturnMacro(msgHandleObject, returnType) \
44 ::mitk::Message<returnType> m_##msgHandleObject##Message; \
47 inline void Add##msgHandleObject##Listener(const ::mitk::MessageAbstractDelegate<returnType> &delegate) \
49 m_##msgHandleObject##Message += delegate; \
51 inline void Remove##msgHandleObject##Listener(const ::mitk::MessageAbstractDelegate<returnType> &delegate) \
53 m_##msgHandleObject##Message -= delegate; \
56 #define mitkNewMessage1Macro(msgHandleObject, type1) \
58 ::mitk::Message1<type1> m_##msgHandleObject##Message; \
61 void Add##msgHandleObject##Listener(const ::mitk::MessageAbstractDelegate1<type1> &delegate) \
63 m_##msgHandleObject##Message += delegate; \
65 void Remove##msgHandleObject##Listener(const ::mitk::MessageAbstractDelegate1<type1> &delegate) \
67 m_##msgHandleObject##Message -= delegate; \
70 #define mitkNewMessage2Macro(msgHandleObject, type1, type2) \
72 ::mitk::Message2<type1, type2> m_##msgHandleObject##Message; \
75 void Add##msgHandleObject##Listener(const ::mitk::MessageAbstractDelegate2<type1, type2> &delegate) \
77 m_##msgHandleObject##Message += delegate; \
79 void Remove##msgHandleObject##Listener(const ::mitk::MessageAbstractDelegate2<type1, type2> &delegate) \
81 m_##msgHandleObject##Message -= delegate; \
86 template <
typename A =
void>
96 template <
typename T,
typename A =
void>
101 virtual A
Execute(T t)
const = 0;
106 template <
typename T,
typename U,
typename A =
void>
111 virtual A
Execute(T t, U u)
const = 0;
116 template <
typename T,
typename U,
typename V,
typename A =
void>
121 virtual A
Execute(T t, U u, V v)
const = 0;
126 template <
typename T,
typename U,
typename V,
typename W,
typename A =
void>
131 virtual A
Execute(T t, U u, V v, W w)
const = 0;
144 template <
class R,
typename A =
void>
151 : m_Object(object), m_MemberFunctionPointer(memberFunctionPointer)
159 return (m_Object->*m_MemberFunctionPointer)();
168 if ((
void *)this->m_Object != (
void *)cmd->m_Object)
170 if (this->m_MemberFunctionPointer != cmd->m_MemberFunctionPointer)
178 A (R::*m_MemberFunctionPointer)();
192 template <
class R,
typename T,
typename A =
void>
199 : m_Object(object), m_MemberFunctionPointer(memberFunctionPointer)
207 return (m_Object->*m_MemberFunctionPointer)(t);
216 if ((
void *)this->m_Object != (
void *)cmd->m_Object)
218 if (this->m_MemberFunctionPointer != cmd->m_MemberFunctionPointer)
226 A (R::*m_MemberFunctionPointer)(T);
229 template <
class R,
typename T,
typename U,
typename A =
void>
236 : m_Object(object), m_MemberFunctionPointer(memberFunctionPointer)
244 return (m_Object->*m_MemberFunctionPointer)(t, u);
253 if ((
void *)this->m_Object != (
void *)cmd->m_Object)
255 if (this->m_MemberFunctionPointer != cmd->m_MemberFunctionPointer)
263 A (R::*m_MemberFunctionPointer)(T, U);
266 template <
class R,
typename T,
typename U,
typename V,
typename A =
void>
273 : m_Object(object), m_MemberFunctionPointer(memberFunctionPointer)
281 return (m_Object->*m_MemberFunctionPointer)(t, u, v);
290 if ((
void *)this->m_Object != (
void *)cmd->m_Object)
292 if (this->m_MemberFunctionPointer != cmd->m_MemberFunctionPointer)
304 A (R::*m_MemberFunctionPointer)(T, U, V);
307 template <
class R,
typename T,
typename U,
typename V,
typename W,
typename A =
void>
314 : m_Object(object), m_MemberFunctionPointer(memberFunctionPointer)
322 return (m_Object->*m_MemberFunctionPointer)(t, u, v, w);
327 const MessageDelegate4<R, T, U, V, W, A> *cmd =
dynamic_cast<const MessageDelegate4<R, T, U, V, W, A> *
>(c);
331 if ((
void *)this->m_Object != (
void *)cmd->m_Object)
333 if (this->m_MemberFunctionPointer != cmd->m_MemberFunctionPointer)
345 A (R::*m_MemberFunctionPointer)(T, U, V, W);
348 template <
typename AbstractDelegate>
380 AbstractDelegate *msgCmd = delegate.Clone();
385 if ((*iter)->operator==(msgCmd))
402 if ((*iter)->operator==(&delegate))
571 template <
typename A =
void>
580 ListenerList listeners;
588 for (
auto iter = listeners.begin(); iter != listeners.end(); ++iter)
599 template <
typename T,
typename A =
void>
608 ListenerList listeners;
616 for (
auto iter = listeners.begin(); iter != listeners.end(); ++iter)
627 template <
typename T,
typename U,
typename A =
void>
636 ListenerList listeners;
644 for (
auto iter = listeners.begin(); iter != listeners.end(); ++iter)
647 (*iter)->Execute(t, u);
655 template <
typename T,
typename U,
typename V,
typename A =
void>
664 ListenerList listeners;
672 for (
typename ListenerList::iterator iter = listeners.begin(); iter != listeners.end(); ++iter)
675 (*iter)->Execute(t, u, v);
683 template <
typename T,
typename U,
typename V,
typename W,
typename A =
void>
692 ListenerList listeners;
700 for (
typename ListenerList::iterator iter = listeners.begin(); iter != listeners.end(); ++iter)
703 (*iter)->Execute(t, u, v, w);
Super::ListenerList ListenerList
void RemoveListener(const AbstractDelegate &delegate) const
MessageDelegate(R *object, A(R::*memberFunctionPointer)())
void AddListener(const AbstractDelegate &delegate) const
virtual A Execute() const
virtual ~MessageAbstractDelegate1()
MessageAbstractDelegate3< T, U, V, A > * Clone() const
void operator()(T t, U u, V v, W w)
virtual MessageAbstractDelegate1 * Clone() const =0
MessageDelegate4(R *object, A(R::*memberFunctionPointer)(T, U, V, W))
bool operator==(const MessageAbstractDelegate2< T, U, A > *c) const
Super::ListenerList ListenerList
MessageDelegate2(R *object, A(R::*memberFunctionPointer)(T, U))
bool operator==(const MessageAbstractDelegate3< T, U, V, A > *c) const
MessageBase< MessageAbstractDelegate< A > > Super
virtual MessageAbstractDelegate3 * Clone() const =0
void operator+=(const AbstractDelegate &delegate) const
DataCollection - Class to facilitate loading/accessing structured data.
virtual bool operator==(const MessageAbstractDelegate3 *cmd) const =0
MessageBase< MessageAbstractDelegate1< T, A > > Super
virtual A Execute(T t, U u, V v) const
Super::ListenerList ListenerList
itk::SimpleFastMutexLock m_Mutex
MessageAbstractDelegate4< T, U, V, W, A > * Clone() const
virtual A Execute(T t) const
void Send(T t, U u, V v, W w)
bool HasListeners() const
virtual A Execute(T t) const =0
virtual ~MessageAbstractDelegate2()
void operator-=(const AbstractDelegate &delegate) const
virtual A Execute() const =0
const ListenerList & GetListeners() const
MessageBase< MessageAbstractDelegate2< T, U, A > > Super
virtual ~MessageAbstractDelegate3()
virtual ~MessageDelegate()
void operator()(T t, U u)
MessageBase & operator=(const MessageBase &o)
MessageDelegate1(R *object, A(R::*memberFunctionPointer)(T))
virtual ~MessageDelegate4()
MessageAbstractDelegate2< T, U, A > * Clone() const
virtual ~MessageAbstractDelegate()
virtual bool operator==(const MessageAbstractDelegate1 *cmd) const =0
virtual bool operator==(const MessageAbstractDelegate2 *cmd) const =0
virtual ~MessageDelegate1()
virtual A Execute(T t, U u) const
Event/message/notification class.
MessageAbstractDelegate< A > * Clone() const
MessageDelegate3(R *object, A(R::*memberFunctionPointer)(T, U, V))
void operator()(T t, U u, V v)
Super::ListenerList ListenerList
virtual ~MessageDelegate2()
bool operator==(const MessageAbstractDelegate< A > *c) const
std::vector< AbstractDelegate * > ListenerList
virtual MessageAbstractDelegate4 * Clone() const =0
virtual MessageAbstractDelegate2 * Clone() const =0
virtual A Execute(T t, U u, V v, W w) const =0
virtual ~MessageAbstractDelegate4()
MessageBase< MessageAbstractDelegate3< T, U, V, A > > Super
bool operator==(const MessageAbstractDelegate4< T, U, V, W, A > *c) const
static void swap(T &x, T &y)
bool operator==(const MessageAbstractDelegate1< T, A > *c) const
MessageBase< MessageAbstractDelegate4< T, U, V, W, A > > Super
virtual A Execute(T t, U u) const =0
Super::ListenerList ListenerList
virtual MessageAbstractDelegate * Clone() const =0
ListenerList m_Listeners
List of listeners.
virtual bool operator==(const MessageAbstractDelegate *cmd) const =0
MessageBase(const MessageBase &o)
virtual A Execute(T t, U u, V v) const =0
virtual ~MessageDelegate3()
virtual bool operator==(const MessageAbstractDelegate4 *cmd) const =0
virtual A Execute(T t, U u, V v, W w) const
MessageAbstractDelegate1< T, A > * Clone() const