10 #define MYGUI_COMBINE(a, b) MYGUI_COMBINE1(a, b)
11 #define MYGUI_COMBINE1(a, b) a##b
13 #define MYGUI_I_DELEGATE MYGUI_COMBINE(IDelegate, MYGUI_SUFFIX)
15 #define MYGUI_C_STATIC_DELEGATE MYGUI_COMBINE(CStaticDelegate, MYGUI_SUFFIX)
16 #define MYGUI_C_METHOD_DELEGATE MYGUI_COMBINE(CMethodDelegate, MYGUI_SUFFIX)
18 #define MYGUI_C_DELEGATE MYGUI_COMBINE(CDelegate, MYGUI_SUFFIX)
19 #define MYGUI_C_MULTI_DELEGATE MYGUI_COMBINE(CMultiDelegate, MYGUI_SUFFIX)
28 virtual bool isType(
const std::type_info& _type) = 0;
31 virtual bool compare(IDelegateUnlink* _unlink)
const
47 virtual bool isType(
const std::type_info& _type)
61 return cast->mFunc == mFunc;
63 virtual bool compare(IDelegateUnlink* _unlink)
const
80 MYGUI_C_METHOD_DELEGATE(IDelegateUnlink* _unlink, T* _object, Method _method) : mUnlink(_unlink), mObject(_object), mMethod(_method) { }
82 virtual bool isType(
const std::type_info& _type)
96 return cast->mObject == mObject && cast->mMethod == mMethod;
99 virtual bool compare(IDelegateUnlink* _unlink)
const
101 return mUnlink == _unlink;
105 IDelegateUnlink* mUnlink;
145 IDelegate* del = _event.mDelegate;
148 if (mDelegate !=
nullptr && !mDelegate->compare(del))
160 return mDelegate ==
nullptr;
175 mDelegate = _delegate;
182 IDelegate* del = _event.mDelegate;
185 if (mDelegate !=
nullptr && !mDelegate->compare(del))
195 if (mDelegate ==
nullptr)
return;
200 IDelegate* mDelegate;
222 for (ConstListDelegateIterator iter = mListDelegates.begin(); iter != mListDelegates.end(); ++iter)
224 if (*iter)
return false;
231 for (ListDelegateIterator iter = mListDelegates.begin(); iter != mListDelegates.end(); ++iter)
241 void clear(IDelegateUnlink* _unlink)
243 for (ListDelegateIterator iter = mListDelegates.begin(); iter != mListDelegates.end(); ++iter)
245 if ((*iter) && (*iter)->compare(_unlink))
255 for (ListDelegateIterator iter = mListDelegates.begin(); iter != mListDelegates.end(); ++iter)
257 if ((*iter) && (*iter)->compare(_delegate))
262 mListDelegates.push_back(_delegate);
268 for (ListDelegateIterator iter = mListDelegates.begin(); iter != mListDelegates.end(); ++iter)
270 if ((*iter) && (*iter)->compare(_delegate))
273 if ((*iter) != _delegate)
delete (*iter);
284 ListDelegateIterator iter = mListDelegates.begin();
285 while (iter != mListDelegates.end())
287 if (
nullptr == (*iter))
289 iter = mListDelegates.erase(iter);
302 ListDelegate del = _event.mListDelegates;
307 mListDelegates = del;
313 ListDelegate del = _event.mListDelegates;
318 mListDelegates = del;
332 void safe_clear(ListDelegate& _delegates)
334 for (ListDelegateIterator iter = mListDelegates.begin(); iter != mListDelegates.end(); ++iter)
338 IDelegate* del = (*iter);
340 delete_is_not_found(del, _delegates);
345 void delete_is_not_found(IDelegate* _del, ListDelegate& _delegates)
347 for (ListDelegateIterator iter = _delegates.begin(); iter != _delegates.end(); ++iter)
349 if ((*iter) && (*iter)->compare(_del))
359 ListDelegate mListDelegates;
364 #undef MYGUI_COMBINE1
366 #undef MYGUI_I_DELEGATE
368 #undef MYGUI_C_STATIC_DELEGATE
369 #undef MYGUI_C_METHOD_DELEGATE
371 #undef MYGUI_C_DELEGATE
372 #undef MYGUI_C_MULTI_DELEGATE
375 #undef MYGUI_TEMPLATE
376 #undef MYGUI_TEMPLATE_PARAMS
377 #undef MYGUI_TEMPLATE_ARGS
378 #undef MYGUI_T_TEMPLATE_PARAMS
379 #undef MYGUI_T_TEMPLATE_ARGS
382 #undef MYGUI_TYPENAME