YSTest: yevt.hpp 源文件

YSTest PreAlpha_b500_20140530 The YSLib Test Project

- 首页
- 相关页面
- 模块
- 命名空间
- 类
- 文件

- 文件列表
- 文件成员

全部 类 命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义 组 页
yevt.hpp
浏览该文件的文档.
1 /*
2 © 2010-2014 FrankHB.
3
4 This file is part of the YSLib project, and may only be used,
5 modified, and distributed under the terms of the YSLib project
6 license, LICENSE.TXT. By continuing to use, modify, or distribute
7 this file you indicate that you have read the license and
8 understand and accept it fully.
9 */
10
28 #ifndef YSL_INC_Core_yevt_hpp_
29 #define YSL_INC_Core_yevt_hpp_ 1
30
31 #include "YModules.h"
32 #include YFM_YSLib_Core_YObject
33 #include YFM_YSLib_Core_YFunc
34 #include <ystdex/iterator.hpp> // for ystdex::get_value;
35 #include <ystdex/container.hpp> // for ystdex::erase_all_if;
36 #include <ystdex/utility.hpp> // for ystdex::cloneable;
37
38 namespace YSLib
39 {
40
45 template<typename... _tParams>
46 DeclDerivedI(, GIHEvent, ystdex::cloneable)
47 DeclIEntry(size_t operator()(_tParams...) const)
49 DeclIEntry(GIHEvent* clone() const override)
50 EndDecl
51
52
60 template<typename>
61 class GHEvent;
62
64 template<typename _tRet, typename... _tParams>
65 class GHEvent<_tRet(_tParams...)>
66 : protected std::function<_tRet(_tParams...)>
67 {
68 public:
69 using TupleType = tuple<_tParams...>;
70 using FuncType = _tRet(_tParams...);
71 using BaseType = std::function<FuncType>;
72
73 private:
75 using Comparer = bool(*)(const GHEvent&, const GHEvent&);
76 template<class _tFunctor>
77 struct GEquality
78 {
80
81 using decayed_type = ystdex::decay_t<_tFunctor>;
82
83 #if YB_HAS_NOEXCEPT
84
88 static yconstexpr bool is_noexcept_v = noexcept(std::declval<
89 const decayed_type>() == std::declval<const decayed_type>());
90 #endif
91
92 static bool
93 AreEqual(const GHEvent& x, const GHEvent& y) ynoexcept(is_noexcept_v)
94 {
95 if(const auto p = x.template target<decayed_type>())
96 if(const auto q = y.template target<decayed_type>())
97 return p == q || *p == *q;
98 return false;
99 }
101 };
102
103 Comparer comp_eq;
104
105 public:
110 yconstfn
111 GHEvent(FuncType* f)
112 : BaseType(f), comp_eq(GEquality<FuncType>::AreEqual)
113 {}
118 template<class _fCallable>
119 yconstfn
120 GHEvent(_fCallable f, ystdex::enable_if_t<
121 std::is_constructible<BaseType, _fCallable>::value, int> = 0)
122 : BaseType(f), comp_eq(GetComparer(f, f))
123 {}
129 template<class _fCallable>
130 yconstfn
131 GHEvent(_fCallable&& f, ystdex::enable_if_t<
132 !std::is_constructible<BaseType, _fCallable>::value, int> = 0)
133 : BaseType(ystdex::make_expanded<_tRet(_tParams...)>(yforward(f))),
134 comp_eq(GHEvent::AreAlwaysEqual)
135 {}
141 template<class _type>
142 yconstfn
143 GHEvent(_type& obj, _tRet(_type::*pm)(_tParams...))
144 : GHEvent([&, pm](_tParams... args){
145 return (obj.*pm)(yforward(args)...);
146 })
147 {}
148 yconstfn DefDeCopyCtor(GHEvent)
149 yconstfn DefDeMoveCtor(GHEvent)
150
151 DefDeCopyAssignment(GHEvent)
155 DefDeMoveAssignment(GHEvent)
156
157 yconstfn bool
158 operator==(const GHEvent& h) const
159 {
160 return
161 #if defined(YF_DLL) || defined(YF_BUILD_DLL)
162 BaseType::target_type() == h.BaseType::target_type()
163 #else
164 comp_eq == h.comp_eq
165 #endif
166 && (comp_eq(*this, h));
167 }
168
172 using BaseType::operator();
173
174 private:
176
177 template<typename _type>
178 static yconstfn Comparer
179 GetComparer(_type& x, _type& y, decltype(x == y) = {}) ynothrow
180 {
181 return GEquality<_type>::AreEqual;
182 }
183 template<typename _type, typename _tUnused>
184 static yconstfn Comparer
185 GetComparer(_type&, _tUnused&) ynothrow
186 {
187 return GHEvent::AreAlwaysEqual;
188 }
189
190 static yconstfn bool
191 AreAlwaysEqual(const GHEvent&, const GHEvent&) ynothrow
192 {
193 return true;
194 }
196 };
198
199
204 using EventPriority = u8;
205
206
211 yconstexpr EventPriority DefaultEventPriority(0x80);
212
213
220 template<typename>
221 class GEvent;
222
224 template<typename _tRet, typename... _tParams>
225 class GEvent<_tRet(_tParams...)>
226 {
227 public:
228 using HandlerType = GHEvent<_tRet(_tParams...)>;
229 using TupleType = typename HandlerType::TupleType;
230 using FuncType = typename HandlerType::FuncType;
235 using ContainerType
236 = multimap<EventPriority, HandlerType, std::greater<EventPriority>>;
237 using SizeType = typename ContainerType::size_type;
238
243 ContainerType List;
244
249 yconstfn DefDeCtor(GEvent)
254 template<typename _tHandler,
255 yimpl(typename = ystdex::exclude_self_ctor_t<GEvent, _tHandler>)>
256 GEvent(_tHandler&& h)
257 : List()
258 {
259 Add(yforward(h));
260 }
265 yconstfn DefDeCopyCtor(GEvent)
269 yconstfn DefDeMoveCtor(GEvent)
270
275 template<typename _tHandler,
276 yimpl(typename = ystdex::exclude_self_ctor_t<GEvent, _tHandler>)>
277 inline GEvent&
278 operator=(_tHandler&& _arg)
279 {
280 return *this = GEvent(yforward(_arg));
281 }
285 DefDeCopyAssignment(GEvent)
289 DefDeMoveAssignment(GEvent)
290
295 inline GEvent&
296 operator+=(const HandlerType& h)
297 {
298 return Add(h);
299 }
304 inline GEvent&
305 operator+=(HandlerType&& h)
306 {
307 return Add(std::move(h));
308 }
313 template<typename _type>
314 inline GEvent&
315 operator+=(_type&& _arg)
316 {
317 return Add(HandlerType(yforward(_arg)));
318 }
319
323 GEvent&
324 operator-=(const HandlerType& h)
325 {
326 ystdex::erase_all_if<ContainerType>(List, List.begin(), List.end(),
327 [&](decltype(*List.begin())& pr){
328 return pr.second == h;
329 });
330 return *this;
331 }
336 inline GEvent&
337 operator-=(HandlerType&& h)
338 {
339 return *this -= static_cast<const HandlerType&>(h);
340 }
345 template<typename _type>
346 inline GEvent&
347 operator-=(_type&& _arg)
348 {
349 return *this -= HandlerType(yforward(_arg));
350 }
351
357 inline GEvent&
358 Add(const HandlerType& h, EventPriority prior = DefaultEventPriority)
359 {
360 List.insert(make_pair(prior, h));
361 return *this;
362 }
368 inline GEvent&
369 Add(HandlerType&& h, EventPriority prior = DefaultEventPriority)
370 {
371 List.insert(make_pair(prior, std::move(h)));
372 return *this;
373 }
379 template<typename _type>
380 inline GEvent&
381 Add(_type&& _arg, EventPriority prior = DefaultEventPriority)
382 {
383 return Add(HandlerType(yforward(_arg)), prior);
384 }
390 template<class _tObj, class _type>
391 inline GEvent&
392 Add(_tObj& obj, _tRet(_type::*pm)(_tParams...),
393 EventPriority prior = DefaultEventPriority)
394 {
395 return Add(HandlerType(static_cast<_type&>(obj), std::move(pm)), prior);
396 }
397
402 template<class _tObj, class _type>
403 inline GEvent&
404 Remove(_tObj& obj, _tRet(_type::*pm)(_tParams...))
405 {
406 return *this -= HandlerType(static_cast<_type&>(obj), std::move(pm));
407 }
408
412 bool
413 Contains(const HandlerType& h) const
414 {
415 using ystdex::get_value;
416
417 return std::find(List.cbegin() | get_value, List.cend() | get_value, h)
418 != List.cend();
419 }
424 template<typename _type>
425 inline bool
426 Contains(_type&& _arg) const
427 {
428 return Contains(HandlerType(yforward(_arg)));
429 }
430
436 SizeType
437 operator()(_tParams... args) const
438 {
439 SizeType n(0);
440
441 for(const auto& pr : List)
442 {
443 try
444 {
445 pr.second(yforward(args)...);
446 }
447 catch(std::bad_function_call&)
448 {}
449 ++n;
450 }
451 return n;
452 }
453
457 DefGetter(const ynothrow, SizeType, Size, List.size())
458
462 PDefH(void, Clear, )
463 ImplRet(List.clear())
464
465 /*
466 \brief 交换。
467 \since build 409
468 */
469 PDefH(void, swap, GEvent& e) ynothrow
470 ImplRet(List.swap(e))
471 };
473
479 template<typename _tRet, typename... _tParams>
480 inline GEvent<_tRet(_tParams...)>&
481 AddUnique(GEvent<_tRet(_tParams...)>& evt,
482 const typename GEvent<_tRet(_tParams...)>::HandlerType& h,
483 EventPriority prior = DefaultEventPriority)
484 {
485 return (evt -= h).Add(h, prior);
486 }
487 template<typename _tRet, typename... _tParams>
488 inline GEvent<_tRet(_tParams...)>&
489 AddUnique(GEvent<_tRet(_tParams...)>& evt, typename GEvent<_tRet(_tParams...)>
490 ::HandlerType&& h, EventPriority prior = DefaultEventPriority)
491 {
492 return (evt -= h).Add(std::move(h), prior);
493 }
494 template<typename _type, typename _tRet, typename... _tParams>
495 inline GEvent<_tRet(_tParams...)>&
496 AddUnique(GEvent<_tRet(_tParams...)>& evt, _type&& arg,
497 EventPriority prior = DefaultEventPriority)
498 {
499 return AddUnique(evt, HandlerType(yforward(arg)), prior);
500 }
502 template<class _type, typename _tRet, typename... _tParams>
503 inline GEvent<_tRet(_tParams...)>&
504 AddUnique(GEvent<_tRet(_tParams...)>& evt, _type& obj,
505 _tRet(_type::*pm)(_tParams...), EventPriority prior = DefaultEventPriority)
506 {
507 return AddUnique(evt, HandlerType(static_cast<_type&>(obj), std::move(pm)),
508 prior);
509 }
511
516 template<typename _tRet, typename... _tParams>
517 inline DefSwap(ynothrow, GEvent<_tRet(_tParams...)>)
518
519
520
525 template<typename... _tEventArgs>
526 class GEventGuard
527 {
528 public:
529 using EventType = GEvent<_tEventArgs...>;
530 using HandlerType = GHEvent<_tEventArgs...>;
531 std::reference_wrapper<EventType> Event;
532 HandlerType Handler;
533
534 template<typename _type>
535 GEventGuard(EventType& evt, _type&& handler,
536 EventPriority prior = DefaultEventPriority)
537 : Event(evt), Handler(yforward(handler))
538 {
539 Event.get().Add(Handler, prior);
540 }
541 ~GEventGuard()
542 {
543 Event.get() -= Handler;
544 }
545 };
546
547
552 #define DeclDelegate(_name, _tEventArgs) \
553 using _name = GHEvent<void(_tEventArgs)>;
554
555
561 template<class _tEvent, class _tOwnerPointer = shared_ptr<_tEvent>>
562 class GDependencyEvent : public GDependency<_tEvent, _tOwnerPointer>
563 {
564 public:
565 using DependentType = typename GDependency<_tEvent>::DependentType;
566 using PointerType = typename GDependency<_tEvent>::PointerType;
567 using ConstReferenceType
568 = typename GDependency<_tEvent>::ConstReferenceType;
569 using ReferentType = typename GDependency<_tEvent>::ReferentType;
570 using ReferenceType = typename GDependency<_tEvent>::ReferenceType;
571 using EventType = DependentType;
572 using SEventType = typename EventType::SEventType;
573 using FuncType = typename EventType::FuncType;
574 using HandlerType = typename EventType::HandlerType;
575 using SizeType = typename EventType::SizeType;
576
577 GDependencyEvent(PointerType p = PointerType())
578 : GDependency<_tEvent>(p)
579 {}
580
584 template<typename _type>
585 inline ReferenceType
586 operator+=(_type _arg)
587 {
588 return this->GetNewRef().operator+=(_arg);
589 }
590
594 template<typename _type>
595 inline ReferenceType
596 operator-=(_type _arg)
597 {
598 return this->GetNewRef().operator-=(_arg);
599 }
600
605 template<class _type, typename _tRet, typename... _tParams>
606 inline ReferenceType
607 Add(_type& obj, _tRet(_type::*pm)(_tParams...))
608 {
609 return this->GetNewRef().Add(obj, pm);
610 }
611
616 template<class _type, typename _tRet, typename... _tParams>
617 inline ReferenceType
618 Remove(_type& obj, _tRet(_type::*pm)(_tParams...))
619 {
620 return this->GetNewRef().Remove(obj, pm);
621 }
622
627 template<typename... _tParams>
628 inline SizeType
629 operator()(_tParams&&... args) const
630 {
631 return this->GetRef().operator()(yforward(args)...);
632 }
633
637 DefGetterMem(const ynothrow, SizeType, Size, this->GetRef())
638
639
642 PDefH(void, Clear, )
643 ImplBodyMem(this->GetNewRef(), Clear, )
644 };
645
646
648 template<typename... _tParams>
649 struct EventArgsHead
650 {
651 using type = ystdex::conditional_t<sizeof...(_tParams) == 0, void,
652 ystdex::tuple_element_t<0, tuple<_tParams...>>>;
653 };
654
655 template<typename... _tParams>
656 struct EventArgsHead<tuple<_tParams...>> : EventArgsHead<_tParams...>
657 {};
658
659
665 #define EventT(_tEventHandler) \
666 GEvent<void(typename EventArgsHead<_tEventHandler::TupleType>::type)>
667 #define DepEventT(_tEventHandler) \
668 typename GDependencyEvent(EventT(_tEventHandler))
669
670
676 #define DeclEvent(_tEventHandler, _name) \
677 EventT(_tEventHandler) _name;
678 #define DeclDepEvent(_tEventHandler, _name) \
679 DepEventT(_tEventHandler) _name;
680
681
687 #define DeclEventRef(_tEventHandler, _name) \
688 EventT(_tEventHandler)& _name;
689 #define DeclDepEventRef(_tEventHandler, _name) \
690 DepEventT(_tEventHandler)& _name;
691
692
697 #define DeclIEventEntry(_tEventHandler, _name) \
699 DeclIEntry(const EventT(_tEventHandler)& YPP_Concat(Get, _name)() const)
700 #define DeclIDepEventEntry(_tEventHandler, _name) \
702 DeclIEntry(const DepEventT(_tEventHandler)& YPP_Concat(Get, _name)() const)
703
704
710 #define DefEventGetter(_q, _tEventHandler, _name, _member) \
711 DefGetter(_q, EventT(_tEventHandler)&, _name, _member)
712 #define DefEventGetterBase(_q, _tEventHandler, _name, _base) \
713 DefGetterBase(_q, EventT(_tEventHandler)&, _name, _base)
714 #define DefEventGetterMem(_q, _tEventHandler, _name, _member) \
715 DefGetterMem(_q, EventT(_tEventHandler)&, _name, _member)
716 #define DefDepEventGetter(_q, _tEventHandler, _name, _member) \
717 DefGetter(_q, DepEventT(_tEventHandler)&, _name, _member)
718 #define DefDepEventGetterBase(_q, _tEventHandler, _name, _base) \
719 DefGetterBase(_q, DepEventT(_tEventHandler)&, _name, _base)
720 #define DefDepEventGetterMem(_q, _tEventHandler, _name, _member) \
721 DefGetterMem(_q, DepEventT(_tEventHandler)&, _name, _member)
722
723
724
730 template<typename _type, typename _fCallable = std::function<void(_type&)>>
731 class GHandlerAdaptor
732 {
733 public:
734 using CallerType = ystdex::decay_t<_fCallable>;
735
736 std::reference_wrapper<_type> ObjectRef;
737 CallerType Caller;
738
739 GHandlerAdaptor(_type& obj, CallerType f)
740 : ObjectRef(obj), Caller(f)
741 {}
742 template<typename _fCaller>
743 GHandlerAdaptor(_type& obj, _fCaller&& f)
744 : ObjectRef(obj), Caller(ystdex::make_expanded<CallerType>(yforward(f)))
745 {}
746
748 template<typename... _tParams>
749 void
750 operator()(_tParams&&... args) const
751 {
752 try
753 {
754 Caller(yforward(args)...);
755 }
756 catch(std::bad_function_call&)
757 {}
758 }
759
761 PDefHOp(bool, ==, const GHandlerAdaptor& adaptor) const ynothrow
762 ImplRet(std::addressof(adaptor.ObjectRef.get())
763 == std::addressof(ObjectRef.get()))
764 };
765
766
771 template<class _tEvent, typename _tBaseArgs>
772 class GEventWrapper : public _tEvent,
773 implements GIHEvent<_tBaseArgs>
774 {
775 public:
776 using EventType = _tEvent;
777 using BaseArgsType = _tBaseArgs;
778 using EventArgsType
779 = typename EventArgsHead<typename _tEvent::TupleType>::type;
780
786 inline ImplI(GIHEvent<_tBaseArgs>) size_t
787 operator()(BaseArgsType e) const
788 {
789 return EventType::operator()(EventArgsType(yforward(e)));
790 }
791
793 inline ImplI(GIHEvent<_tBaseArgs>)
794 DefClone(const override, GEventWrapper)
795 };
796
797
803 template<typename _tBaseArgs>
804 class GEventPointerWrapper
805 {
806 public:
807 using ItemType = GIHEvent<_tBaseArgs>;
808 using PointerType = unique_ptr<ItemType>;
809
810 private:
811 #if YB_HAS_NOEXCEPT
812 /*
813 \brief 避免 constexpr 失败的 noexcept 检查。
814 \since build 468
815 */
816 template<typename _type>
817 struct is_noexcept
818 {
819 static yconstexpr bool value
820 = noexcept(PointerType(std::declval<_type>()));
821 };
822 #endif
823
824 PointerType ptr;
825
826 public:
828 template<typename _type>
829 inline
830 GEventPointerWrapper(_type&& p) ynoexcept(is_noexcept<_type>::value)
831 : ptr(yforward(p))
832 {
833 YAssertNonnull(p);
834 }
838 GEventPointerWrapper(const GEventPointerWrapper& item)
839 : ptr(ClonePolymorphic(item.ptr))
840 {}
841 DefDeMoveCtor(GEventPointerWrapper)
842
843 yconstfn DefCvt(const ynothrow, const ItemType&, *ptr)
844 yconstfn DefCvt(const ynothrow, ItemType&, *ptr)
845 };
846
847
852 #define DefExtendEventMap(_n, _b) \
853 DefExtendClass(YF_API, _n, public _b)
854
855 } // namespace YSLib;
856
857 #endif
858
utility.hpp
实用设施。
YSLib::GHandlerAdaptor::ObjectRef
std::reference_wrapper< _type > ObjectRef
Definition: yevt.hpp:736
ImplBodyMem
#define ImplBodyMem(_m, _n,...)
Definition: YBaseMacro.h:116
ystdex::tuple_element_t
typename std::tuple_element< _vIdx, _type >::type tuple_element_t
Definition: tuple.hpp:44
YSLib::GHandlerAdaptor::Caller
CallerType Caller
Definition: yevt.hpp:737
ImplRet
#define ImplRet(...)
Definition: YBaseMacro.h:97
YSLib::GHEvent< _tRet(_tParams...)>::GHEvent
yconstfn GHEvent(FuncType *f)
构造：使用函数指针。
Definition: yevt.hpp:111
YModules.h
YSLib::GEventPointerWrapper::GEventPointerWrapper
GEventPointerWrapper(_type &&p) ynoexcept(is_noexcept< _type >
Definition: yevt.hpp:830
YSLib::GHEvent< _tRet(_tParams...)>::GEquality::AreEqual
static bool AreEqual(const GHEvent &x, const GHEvent &y) ynoexcept(is_noexcept_v)
Definition: yevt.hpp:93
YSLib::GEvent
事件类模板。
Definition: yevt.hpp:221
implements
#define implements
Definition: YBaseMacro.h:272
YSLib::GEventWrapper< EventT(HPaintEvent), YSLib::UI::UIEventArgs && >::EventArgsType
typename EventArgsHead< typename EventT(HPaintEvent)::TupleType >::type EventArgsType
Definition: yevt.hpp:779
YSLib::UI::args
yconstfn const string _tParams && args
Definition: Loader.h:111
YSLib::ClonePolymorphic
auto ClonePolymorphic(const _type &p) -> decltype(&*p)
使用 clone 成员函数复制指定指针指向的多态类类型对象。
Definition: ycutil.h:479
YSLib::GHEvent< _tRet(_tParams...)>::GEquality::decayed_type
ystdex::decay_t< _tFunctor > decayed_type
Definition: yevt.hpp:81
ystdex::conditional_t
typename conditional< _bCond, _type, _type2 >::type conditional_t
Definition: type_op.hpp:277
YSLib::GDependencyEvent::Remove
ReferenceType Remove(_type &obj, _tRet(_type::*pm)(_tParams...))
移除事件响应：目标为指定对象引用和成员函数指针。
Definition: yevt.hpp:618
DefDeCtor
#define DefDeCtor(_t)
Definition: YBaseMacro.h:131
DefDeCopyCtor
#define DefDeCopyCtor(_t)
Definition: YBaseMacro.h:136
YSLib::GEvent< _tRet(_tParams...)>::ContainerType
multimap< EventPriority, HandlerType, std::greater< EventPriority >> ContainerType
容器类型。
Definition: yevt.hpp:236
YSLib::GEvent::DefSwap
#define DefSwap(_q, _t)
使用 RAII 管理的事件辅助类。
Definition: yevt.hpp:517
YSLib::GDependencyEvent::SEventType
typename EventType::SEventType SEventType
Definition: yevt.hpp:572
YSLib::UI::EventMapping::ItemType
GIHEvent< UIEventArgs && > ItemType
Definition: ywgtevt.h:424
YSLib::GHandlerAdaptor::GHandlerAdaptor
GHandlerAdaptor(_type &obj, CallerType f)
Definition: yevt.hpp:739
YSLib::GHEvent< _tRet(_tParams...)>::TupleType
tuple< _tParams...> TupleType
Definition: yevt.hpp:69
YSLib::GHEvent< _tRet(_tParams...)>::GetComparer
static yconstfn Comparer GetComparer(_type &, _tUnused &) ynothrow
Definition: yevt.hpp:185
YSLib::UI::Styles::Handler
std::function< void(PaintEventArgs &&)> Handler
样式处理器。
Definition: ystyle.h:256
YSLib::GEvent< _tRet(_tParams...)>::SizeType
typename ContainerType::size_type SizeType
Definition: yevt.hpp:237
YSLib::EventArgsHead
Definition: yevt.hpp:649
YSLib::GHEvent< _tRet(_tParams...)>
Definition: yevt.hpp:65
ystdex::cloneable
可动态复制的抽象基类。
Definition: utility.hpp:142
YSLib::EventPriority
u8 EventPriority
事件优先级。
Definition: yevt.hpp:204
YSLib::GDependencyEvent::ReferentType
typename GDependency< _tEvent >::ReferentType ReferentType
Definition: yevt.hpp:569
YSLib::UI::UIEventArgs
用户界面事件参数基类。
Definition: ywgtevt.h:59
ystdex::decay_t
typename decay< _type >::type decay_t
Definition: type_op.hpp:271
YSLib::AddUnique
GEvent< _tRet(_tParams...)> & AddUnique(GEvent< _tRet(_tParams...)> &evt, const typename GEvent< _tRet(_tParams...)>::HandlerType &h, EventPriority prior=DefaultEventPriority)
添加单一事件响应：删除后添加。
Definition: yevt.hpp:481
YSLib::GEventPointerWrapper::PointerType
unique_ptr< ItemType > PointerType
Definition: yevt.hpp:808
YSLib::GEventWrapper
事件包装类模板。
Definition: yevt.hpp:772
yforward
#define yforward(_expr)
根据参数类型使用 std::forward 传递对应参数。
Definition: ydef.h:722
YSLib::GEvent< _tRet(_tParams...)>::List
ContainerType List
响应列表。
Definition: yevt.hpp:243
DefGetter
#define DefGetter(_q, _t, _n,...)
Definition: YBaseMacro.h:180
ImplI
#define ImplI(...)
Definition: YBaseMacro.h:308
YSLib::GDependencyEvent
依赖事件项类模板。
Definition: yevt.hpp:562
YSLib::GDependencyEvent::operator+=
ReferenceType operator+=(_type _arg)
添加事件响应。
Definition: yevt.hpp:586
YSLib::GDependencyEvent::operator()
SizeType operator()(_tParams &&...args) const
调用函数。
Definition: yevt.hpp:629
YSLib::Drawing::size_t
size_t
Definition: ygdi.h:352
YSLib::GHEvent< _tRet(_tParams...)>::GHEvent
yconstfn GHEvent(_fCallable f, ystdex::enable_if_t< std::is_constructible< BaseType, _fCallable >::value, int >=0)
使用函数对象。
Definition: yevt.hpp:120
YSLib::GHEvent< _tRet(_tParams...)>::BaseType
std::function< FuncType > BaseType
Definition: yevt.hpp:71
ystdex::swap
void swap(any &x, any &y)
交换对象。
Definition: any.h:729
ystdex::make_expanded
expanded_caller< _fHandler, decay_t< _fCallable > > make_expanded(_fCallable &&f)
构造接受冗余参数的可调用对象。
Definition: functional.hpp:412
ystdex::get_value
const second_tag get_value
Definition: iterator.hpp:785
YSLib::DefaultEventPriority
yconstexpr EventPriority DefaultEventPriority(0x80)
默认事件优先级。
YSLib::GHEvent< _tRet(_tParams...)>::AreAlwaysEqual
static yconstfn bool AreAlwaysEqual(const GHEvent &, const GHEvent &) ynothrow
Definition: yevt.hpp:191
YSLib::GDependencyEvent::FuncType
typename EventType::FuncType FuncType
Definition: yevt.hpp:573
YSLib::GEvent< _tRet(_tParams...)>::TupleType
typename HandlerType::TupleType TupleType
Definition: yevt.hpp:229
DefDeMoveCtor
#define DefDeMoveCtor(_t)
Definition: YBaseMacro.h:141
YSLib::EventArgsHead::type
ystdex::conditional_t< sizeof...(_tParams)==0, void, ystdex::tuple_element_t< 0, tuple< _tParams...>>> type
Definition: yevt.hpp:652
YSLib::GDependencyEvent::PointerType
typename GDependency< _tEvent >::PointerType PointerType
Definition: yevt.hpp:566
YSLib::GDependencyEvent::operator-=
ReferenceType operator-=(_type _arg)
移除事件响应。
Definition: yevt.hpp:596
ynothrow
#define ynothrow
YSLib 无异常抛出保证：若支持 noexcept 关键字， 指定特定的 noexcept 异常规范。
Definition: ydef.h:514
YSLib::GHandlerAdaptor::GHandlerAdaptor
GHandlerAdaptor(_type &obj, _fCaller &&f)
Definition: yevt.hpp:743
YSLib::GHandlerAdaptor::CallerType
ystdex::decay_t< _fCallable > CallerType
Definition: yevt.hpp:734
container.hpp
通用容器操作。
YSLib::GHEvent< _tRet(_tParams...)>::comp_eq
Comparer comp_eq
比较函数：相等关系。
Definition: yevt.hpp:103
YSLib::GEventPointerWrapper
事件项类型。
Definition: yevt.hpp:804
iterator.hpp
通用迭代器。
EndDecl
#define EndDecl
Definition: YBaseMacro.h:316
YSLib::GEventWrapper::ImplI
ImplI(GIHEvent< _tBaseArgs >) size_t operator()(BaseArgsType e) const
委托调用。
Definition: yevt.hpp:786
YSLib::DeclDerivedI
DeclDerivedI(, GIHEvent, ystdex::cloneable) DeclIEntry(size_t operator()(_tParams...) const ) DeclIEntry(GIHEvent *clone() const override) EndDecltemplate< typename > class GHEvent
事件处理器接口模板。
YSLib::GDependencyEvent::GDependencyEvent
GDependencyEvent(PointerType p=PointerType())
Definition: yevt.hpp:577
YSLib::GHEvent< _tRet(_tParams...)>::GHEvent
yconstfn GHEvent(_type &obj, _tRet(_type::*pm)(_tParams...))
构造：使用对象引用和成员函数指针。
Definition: yevt.hpp:143
YSLib::GDependencyEvent::HandlerType
typename EventType::HandlerType HandlerType
Definition: yevt.hpp:574
YAssertNonnull
#define YAssertNonnull(_expr)
Definition: cassert.h:81
YSLib::GEventPointerWrapper::ItemType
GIHEvent< _tBaseArgs > ItemType
Definition: yevt.hpp:807
YSLib::GEventPointerWrapper::GEventPointerWrapper
GEventPointerWrapper(const GEventPointerWrapper &item)
复制构造：深复制。
Definition: yevt.hpp:838
yconstfn
#define yconstfn
指定编译时常量函数。
Definition: ydef.h:463
YSLib::UI::f
_tWidget _fCallable && f
Definition: ywgtevt.h:597
YSLib::GDependencyEvent::SizeType
typename EventType::SizeType SizeType
Definition: yevt.hpp:575
ystdex::exclude_self_ctor_t
enable_if_t<!is_same< _tClass &, remove_rcv_t< _tParam > & >::value, _type > exclude_self_ctor_t
移除选择类类型的特定重载避免构造模板和复制/转移构造函数冲突。
Definition: type_op.hpp:766
YSLib::GEventWrapper< EventT(HPaintEvent), YSLib::UI::UIEventArgs && >::EventType
EventT(HPaintEvent) EventType
Definition: yevt.hpp:776
YSLib::GHEvent< _tRet(_tParams...)>::GetComparer
static yconstfn Comparer GetComparer(_type &x, _type &y, decltype(x==y)={}) ynothrow
Definition: yevt.hpp:179
YSLib::GDependencyEvent::DependentType
typename GDependency< _tEvent >::DependentType DependentType
Definition: yevt.hpp:565
DefClone
#define DefClone(_q, _t)
动态复制。
Definition: YBaseMacro.h:221
YSLib::UI::Contains
Selected const shared_ptr< ListType > const pair< Color, Color > viewer Contains
Definition: textlist.h:124
YSLib::GEventPointerWrapper::ptr
PointerType ptr
Definition: yevt.hpp:824
YSLib::GDependencyEvent::Add
ReferenceType Add(_type &obj, _tRet(_type::*pm)(_tParams...))
添加事件响应：使用对象引用和成员函数指针。
Definition: yevt.hpp:607
YSLib::GDependencyEvent::ConstReferenceType
typename GDependency< _tEvent >::ConstReferenceType ConstReferenceType
Definition: yevt.hpp:568
YSLib::GDependencyEvent::EventType
DependentType EventType
Definition: yevt.hpp:571
YSLib::u8
std::uint8_t u8
通用数据类型。
Definition: yadaptor.h:67
DefDeMoveAssignment
#define DefDeMoveAssignment(_t)
Definition: YBaseMacro.h:159
yconstexpr
#define yconstexpr
指定编译时常量表达式。
Definition: ydef.h:462
DefCvt
#define DefCvt(_q, _t,...)
Definition: YBaseMacro.h:164
YSLib::GHEvent< _tRet(_tParams...)>::FuncType
_tRet(_tParams...) FuncType
Definition: yevt.hpp:70
YSLib::GHEvent< _tRet(_tParams...)>::Comparer
bool(*)(const GHEvent &, const GHEvent &) Comparer
比较函数类型。
Definition: yevt.hpp:75
DefGetterMem
#define DefGetterMem(_q, _t, _n, _m)
Definition: YBaseMacro.h:185
DeclIEntry
#define DeclIEntry(_sig)
Definition: YBaseMacro.h:314
YSLib::GHandlerAdaptor::operator()
void operator()(_tParams &&...args) const
Definition: yevt.hpp:750
ystdex::any_ops::clone
Definition: any.h:310
ynoexcept
#define ynoexcept(...)
YSLib 无异常抛出保证：指定特定的异常规范。
Definition: ydef.h:526
YSLib::GDependencyEvent::ReferenceType
typename GDependency< _tEvent >::ReferenceType ReferenceType
Definition: yevt.hpp:570
YSLib::Drawing::Size
屏幕区域大小。
Definition: ygdibase.h:249
YSLib::yimpl
YF_API yimpl(GUIApplication &) FetchGlobalInstance() ynothrow
取全局应用程序实例。
YSLib::GHEvent< _tRet(_tParams...)>::GHEvent
yconstfn GHEvent(_fCallable &&f, ystdex::enable_if_t< !std::is_constructible< BaseType, _fCallable >::value, int >=0)
使用扩展函数对象。
Definition: yevt.hpp:131
DefDeCopyAssignment
#define DefDeCopyAssignment(_t)
Definition: YBaseMacro.h:154
ystdex::enable_if_t
typename enable_if< _bCond, _type >::type enable_if_t
Definition: type_op.hpp:274
YSLib::GHandlerAdaptor
事件处理器适配器模板。
Definition: yevt.hpp:731
YSLib::GEvent< _tRet(_tParams...)>::FuncType
typename HandlerType::FuncType FuncType
Definition: yevt.hpp:230