YSTest: YEvent.hpp 源文件

YSTest PreAlpha_b800_20170810 The YSLib Test Project

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

- 文件列表
- 文件成员

YEvent.hpp
浏览该文件的文档.
1 /*
2 © 2010-2017 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 // for ystdex::examiners::equal_examiner;
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/base.h> // for ystdex::cloneable;
37 #include <ystdex/operators.hpp> // for ystdex::equality_comparable;
38 #include <ystdex/functional.hpp> // for ystdex::make_expanded,
39 // ystdex::default_last_value;
40 #include <ystdex/optional.h> // for ystdex::optional_last_value;
41
42 namespace YSLib
43 {
44
49 template<typename... _tParams>
50 DeclDerivedI(, GIHEvent, ystdex::cloneable)
51 DeclIEntry(size_t operator()(_tParams...) const)
53 DeclIEntry(GIHEvent* clone() const ImplI(ystdex::cloneable))
54 EndDecl
55
56 template<typename... _tParams>
57 GIHEvent<_tParams...>::DefDeDtor(GIHEvent)
58
59
67 template<typename>
68 class GHEvent;
69
71 template<typename _tRet, typename... _tParams>
72 class GHEvent<_tRet(_tParams...)>
73 : protected std::function<_tRet(_tParams...)>,
74 private ystdex::equality_comparable<GHEvent<_tRet(_tParams...)>>,
75 private ystdex::equality_comparable<GHEvent<_tRet(_tParams...)>, nullptr_t>
76 {
77 public:
78 using TupleType = tuple<_tParams...>;
79 using FuncType = _tRet(_tParams...);
80 using BaseType = std::function<FuncType>;
81
82 private:
84 using Comparer = bool(*)(const GHEvent&, const GHEvent&);
85 template<class _tFunctor>
86 struct GEquality
87 {
89 using Decayed = ystdex::decay_t<_tFunctor>;
90
95 static bool
96 AreEqual(const GHEvent& x, const GHEvent& y)
97 // TODO: Verify if it is a GCC bug. Since the resolution of CWG
98 // 1330 is in the working draft M4659, it likes to be. See also
99 // https://stackoverflow.com/questions/35790350/noexcept-inheriting-constructors-and-the-invalid-use-of-an-incomplete-type-that.
100 #if !(YB_IMPL_GNUC >= 70000)
101 ynoexcept_spec(
102 ystdex::examiners::equal_examiner::are_equal(Deref(
103 x.template target<Decayed>()), Deref(y.template target<Decayed>())))
104 #endif
105 {
106 return ystdex::examiners::equal_examiner::are_equal(
107 Deref(x.template target<Decayed>()),
108 Deref(y.template target<Decayed>()));
109 }
110 };
111
116 Comparer comp_eq;
117
118 public:
123 yconstfn
124 GHEvent(FuncType* f = {})
125 : BaseType(f), comp_eq(GEquality<FuncType>::AreEqual)
126 {}
131 template<class _fCallable>
132 yconstfn
133 GHEvent(_fCallable f, ystdex::enable_if_t<
134 std::is_constructible<BaseType, _fCallable>::value, int> = 0)
135 : BaseType(f),
136 comp_eq(GEquality<ystdex::decay_t<_fCallable>>::AreEqual)
137 {}
143 template<class _fCallable>
144 yconstfn
145 GHEvent(_fCallable&& f, ystdex::enable_if_t<
146 !std::is_constructible<BaseType, _fCallable>::value, int> = 0)
147 : BaseType(ystdex::make_expanded<_tRet(_tParams...)>(yforward(f))),
148 comp_eq([](const GHEvent&, const GHEvent&) ynothrow{
149 return true;
150 })
151 {}
157 template<class _type>
158 yconstfn
159 GHEvent(_type& obj, _tRet(_type::*pm)(_tParams...))
160 : GHEvent([&, pm](_tParams... args) ynoexcept(
161 noexcept((obj.*pm)(yforward(args)...))
162 && std::is_nothrow_copy_constructible<_tRet>::value){
163 return (obj.*pm)(yforward(args)...);
164 })
165 {}
166 DefDeCopyMoveCtorAssignment(GHEvent)
167
168
169 friend yconstfn bool
170 operator==(const GHEvent& x, const GHEvent& y)
171 {
172 return
173 #if defined(YF_DLL) || defined(YF_BUILD_DLL)
174 x.target_type() == y.target_type()
175 #else
176 x.comp_eq == y.comp_eq
177 #endif
178 && (!bool(x) || x.comp_eq(x, y));
179 }
180
182 using BaseType::operator();
183
185 using BaseType::operator bool;
186
188 using BaseType::target;
189
191 using BaseType::target_type;
192 };
194
199 template<typename _tRet, typename... _tParams>
200 yconstfn bool
201 operator==(const GHEvent<_tRet(_tParams...)>& x, nullptr_t)
202 {
203 return !x;
204 }
205
206
211 using EventPriority = std::uint8_t;
212
213
218 yconstexpr const EventPriority DefaultEventPriority(0x80);
219
220
222
223 struct CountedHandlerInvoker
225 {
230 template<typename _tIn, typename... _tParams>
231 size_t
232 operator()(_tIn first, _tIn last, _tParams&&... args) const
233 {
234 size_t n(0);
235
236 while(first != last)
237 {
238 TryExpr((*first)(yforward(args)...))
239 CatchIgnore(std::bad_function_call&)
240 yunseq(++n, ++first);
241 }
242 return n;
243 }
244 };
245
246
248 template<typename _type, typename _tCombiner>
249 struct GCombinerInvoker
250 {
251 static_assert(ystdex::is_decayed<_tCombiner>(), "Invalid type found.");
252
253 public:
254 using result_type = _type;
255
256 private:
257 _tCombiner combiner;
258
259 public:
260 template<typename _tIn, typename... _tParams>
261 result_type
262 operator()(_tIn first, _tIn last, _tParams&&... args) const
263 {
264 // XXX: Blocked. 'yforward' cause G++ 5.2 crash: internal
265 // compiler error: Aborted (program cc1plus).
266 #if false
267 const auto tr([&](_tIn iter){
268 return ystdex::make_transform(iter, [&](_tIn i){
269 // XXX: Blocked. 'std::forward' still cause G++ 5.2 crash:
270 // internal compiler error: in execute, at cfgexpand.c:6044.
271 // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65992.
272 return (*i)(std::forward<_tParams>(args)...);
273 });
274 });
275 #else
276 const auto f([&](_tIn i){
277 return (*i)(std::forward<_tParams>(args)...);
278 });
279 const auto tr([f](_tIn iter){
280 return ystdex::make_transform(iter, f);
281 });
282 #endif
283 return combiner(tr(first), tr(last));
284 }
285 };
286
287
289 template<typename _type>
290 using GDefaultLastValueInvoker
291 = GCombinerInvoker<_type, ystdex::default_last_value<_type>>;
292
294 template<typename _type>
295 using GOptionalLastValueInvoker = GCombinerInvoker<ystdex::cond_t<std::is_void<
296 _type>, void, ystdex::optional<_type>>, ystdex::optional_last_value<_type>>;
297
298
299
305 template<typename, typename = CountedHandlerInvoker>
306 class GEvent;
307
312 template<typename _tRet, typename... _tParams, typename _tInvoker>
313 class GEvent<_tRet(_tParams...), _tInvoker>
314 {
315 public:
317
318 using HandlerType = GHEvent<_tRet(_tParams...)>;
319 using TupleType = typename HandlerType::TupleType;
320 using FuncType = typename HandlerType::FuncType;
322
326 using ContainerType
327 = multimap<EventPriority, HandlerType, std::greater<EventPriority>>;
329 using InvokerType = _tInvoker;
331
332 using const_iterator = typename ContainerType::const_iterator;
333 using const_reference = typename ContainerType::const_reference;
334 using const_reverse_iterator
335 = typename ContainerType::const_reverse_iterator;
336 using iterator = typename ContainerType::iterator;
337 using reference = typename ContainerType::reference;
338 using reverse_iterator = typename ContainerType::reverse_iterator;
339 using size_type = typename ContainerType::size_type;
340 using value_type = typename ContainerType::value_type;
342 using result_type = decltype(std::declval<_tInvoker&>()(
344 std::declval<const_iterator>(), std::declval<const_iterator>(),
345 std::declval<_tParams>()...));
346
351 InvokerType Invoker{};
352
353 private:
358 ContainerType handlers{};
359
360 public:
366 yconstfn DefDeCtor(GEvent)
371 GEvent(InvokerType ivk)
372 : Invoker(std::move(ivk))
373 {}
378 template<typename _tHandler,
379 yimpl(typename = ystdex::exclude_self_t<GEvent, _tHandler>)>
380 GEvent(_tHandler&& h, InvokerType ivk = {})
381 : Invoker(std::move(ivk))
382 {
383 Add(yforward(h));
384 }
386 DefDeCopyMoveCtorAssignment(GEvent)
387
388
392 template<typename _tHandler,
393 yimpl(typename = ystdex::exclude_self_t<GEvent, _tHandler>)>
394 inline GEvent&
395 operator=(_tHandler&& _arg)
396 {
397 return *this = GEvent(yforward(_arg));
398 }
399
401
402
406 inline PDefHOp(GEvent&, +=, const HandlerType& h)
407 ImplRet(Add(h))
412 inline PDefHOp(GEvent&, +=, HandlerType&& h)
413 ImplRet(Add(std::move(h)))
418 template<typename _type>
419 inline GEvent&
420 operator+=(_type&& _arg)
421 {
422 return Add(HandlerType(yforward(_arg)));
423 }
424
426 GEvent&
427 operator-=(const HandlerType& h)
428 {
429 ystdex::erase_all_if<ContainerType>(handlers, handlers.cbegin(),
430 handlers.cend(), [&](decltype(*handlers.cbegin()) pr){
431 return pr.second == h;
432 });
433 return *this;
434 }
439 inline PDefHOp(GEvent&, -=, HandlerType&& h)
440 ImplRet(*this -= static_cast<const HandlerType&>(h))
445 template<typename _type>
446 inline GEvent&
447 operator-=(_type&& _arg)
448 {
449 return *this -= HandlerType(yforward(_arg));
450 }
452
460 inline PDefH(GEvent&, Add, const HandlerType& h,
462 EventPriority prior = DefaultEventPriority)
463 ImplRet(Insert(h, prior), *this)
465 inline PDefH(GEvent&, Add, HandlerType&& h,
466 EventPriority prior = DefaultEventPriority)
467 ImplRet(Insert(std::move(h), prior), *this)
469 template<typename _type>
470 inline GEvent&
471 Add(_type&& _arg, EventPriority prior = DefaultEventPriority)
472 {
473 return Add(HandlerType(yforward(_arg)), prior);
474 }
479 template<class _tObj, class _type>
480 inline GEvent&
481 Add(_tObj& obj, _tRet(_type::*pm)(_tParams...),
482 EventPriority prior = DefaultEventPriority)
483 {
484 return Add(HandlerType(static_cast<_type&>(obj), std::move(pm)), prior);
485 }
487
494 inline PDefH(typename ContainerType::iterator, Insert, const HandlerType& h,
496 EventPriority prior = DefaultEventPriority)
497 ImplRet(handlers.emplace(prior, h))
499 inline PDefH(typename ContainerType::iterator, Insert, HandlerType&& h,
500 EventPriority prior = DefaultEventPriority)
501 ImplRet(handlers.emplace(prior, std::move(h)))
503 template<typename _type>
504 inline typename ContainerType::iterator
505 Insert(_type&& _arg, EventPriority prior = DefaultEventPriority)
506 {
507 return Insert(HandlerType(yforward(_arg)), prior);
508 }
510 template<class _tObj, class _type>
511 inline typename ContainerType::iterator
512 Insert(_tObj& obj, _tRet(_type::*pm)(_tParams...),
513 EventPriority prior = DefaultEventPriority)
514 {
515 return
516 Insert(HandlerType(static_cast<_type&>(obj), std::move(pm)), prior);
517 }
519
524 template<class _tObj, class _type>
525 inline GEvent&
526 Remove(_tObj& obj, _tRet(_type::*pm)(_tParams...))
527 {
528 return *this -= HandlerType(static_cast<_type&>(obj), std::move(pm));
529 }
530
535 bool
536 Contains(const HandlerType& h) const
537 {
538 using ystdex::get_value;
539
540 return std::count(handlers.cbegin() | get_value,
541 handlers.cend() | get_value, h) != 0;
542 }
547 template<typename _type>
548 inline bool
549 Contains(_type&& _arg) const
550 {
551 return Contains(HandlerType(yforward(_arg)));
552 }
553
558 PDefHOp(result_type, (), _tParams... args) const
559 ImplRet(Invoker(handlers.cbegin() | ystdex::get_value,
560 handlers.cend() | ystdex::get_value, yforward(args)...))
561
563 PDefH(const_iterator, cbegin, ) const ynothrow
564 ImplRet(handlers.cbegin())
565
567
568 PDefH(iterator, begin, ) ynothrow
569 ImplRet(handlers.begin())
570 PDefH(iterator, begin, ) const ynothrow
571 ImplRet(handlers.begin())
572
574 PDefH(const_iterator, cend, ) const ynothrow
575 ImplRet(handlers.cend())
576
578 PDefH(void, clear, ) ynothrow
579 ImplRet(handlers.clear())
580
582
583 PDefH(size_type, count, EventPriority prior) const ynothrow
584 ImplRet(handlers.count(prior))
585
586 PDefH(const_reverse_iterator, crbegin, ) const ynothrow
587 ImplRet(handlers.crbegin())
588
589 PDefH(const_reverse_iterator, crend, ) const ynothrow
590 ImplRet(handlers.crend())
592
593 PDefH(bool, empty, ) const ynothrow
594 ImplRet(handlers.empty())
595
596 PDefH(iterator, end, ) ynothrow
597 ImplRet(handlers.end())
598 PDefH(iterator, end, ) const ynothrow
599 ImplRet(handlers.end())
601
603
604 PDefH(reverse_iterator, rbegin, ) ynothrow
605 ImplRet(handlers.rbegin())
606
607 PDefH(reverse_iterator, rend, ) ynothrow
608 ImplRet(handlers.rend())
609
611 PDefH(size_type, size, ) const ynothrow
612 ImplRet(handlers.size())
614
619 friend PDefH(void, swap, GEvent& x, GEvent& y) ynothrow
620 ImplRet(x.handlers.swap(y.handlers))
621 };
623
624
630 template<typename _tRet, typename... _tParams>
631 inline GEvent<_tRet(_tParams...)>&
632 AddUnique(GEvent<_tRet(_tParams...)>& evt,
633 const typename GEvent<_tRet(_tParams...)>::HandlerType& h,
634 EventPriority prior = DefaultEventPriority)
635 {
636 return (evt -= h).Add(h, prior);
637 }
638 template<typename _tRet, typename... _tParams>
639 inline GEvent<_tRet(_tParams...)>&
640 AddUnique(GEvent<_tRet(_tParams...)>& evt, typename GEvent<_tRet(_tParams...)>
641 ::HandlerType&& h, EventPriority prior = DefaultEventPriority)
642 {
643 return (evt -= h).Add(std::move(h), prior);
644 }
645 template<typename _type, typename _tRet, typename... _tParams>
646 inline GEvent<_tRet(_tParams...)>&
647 AddUnique(GEvent<_tRet(_tParams...)>& evt, _type&& arg,
648 EventPriority prior = DefaultEventPriority)
649 {
650 return AddUnique(evt, HandlerType(yforward(arg)), prior);
651 }
653 template<class _type, typename _tRet, typename... _tParams>
654 inline GEvent<_tRet(_tParams...)>&
655 AddUnique(GEvent<_tRet(_tParams...)>& evt, _type& obj,
656 _tRet(_type::*pm)(_tParams...), EventPriority prior = DefaultEventPriority)
657 {
658 return AddUnique(evt, HandlerType(static_cast<_type&>(obj), std::move(pm)),
659 prior);
660 }
662
663
669 template<typename... _tEventArgs>
670 class GEventGuard
671 {
672 public:
673 using EventType = GEvent<_tEventArgs...>;
674 using HandlerType = GHEvent<_tEventArgs...>;
676 lref<EventType> Event;
677 HandlerType Handler;
678
679 template<typename _type>
680 GEventGuard(EventType& evt, _type&& handler,
681 EventPriority prior = DefaultEventPriority)
682 : Event(evt), Handler(yforward(handler))
683 {
684 Event.get().Add(Handler, prior);
685 }
686 ~GEventGuard()
687 {
688 Event.get() -= Handler;
689 }
690 };
691
692
698 template<class _tEvent, class _tOwnerPointer = shared_ptr<_tEvent>>
699 class GDependencyEvent : public GDependency<_tEvent, _tOwnerPointer>
700 {
701 public:
702 using DependentType = typename GDependency<_tEvent>::DependentType;
703 using PointerType = typename GDependency<_tEvent>::PointerType;
704 using ConstReferenceType
705 = typename GDependency<_tEvent>::ConstReferenceType;
706 using ReferentType = typename GDependency<_tEvent>::ReferentType;
707 using ReferenceType = typename GDependency<_tEvent>::ReferenceType;
708 using EventType = DependentType;
709 using SEventType = typename EventType::SEventType;
710 using FuncType = typename EventType::FuncType;
711 using HandlerType = typename EventType::HandlerType;
712 using SizeType = typename EventType::SizeType;
713
714 GDependencyEvent(PointerType p = PointerType())
715 : GDependency<_tEvent>(p)
716 {}
717
721 template<typename _type>
722 inline ReferenceType
723 operator+=(_type _arg)
724 {
725 return this->GetNewRef().operator+=(_arg);
726 }
727
731 template<typename _type>
732 inline ReferenceType
733 operator-=(_type _arg)
734 {
735 return this->GetNewRef().operator-=(_arg);
736 }
737
742 template<class _type, typename _tRet, typename... _tParams>
743 inline ReferenceType
744 Add(_type& obj, _tRet(_type::*pm)(_tParams...))
745 {
746 return this->GetNewRef().Add(obj, pm);
747 }
748
753 template<class _type, typename _tRet, typename... _tParams>
754 inline ReferenceType
755 Remove(_type& obj, _tRet(_type::*pm)(_tParams...))
756 {
757 return this->GetNewRef().Remove(obj, pm);
758 }
759
764 template<typename... _tParams>
765 inline SizeType
766 operator()(_tParams&&... args) const
767 {
768 return this->GetRef().operator()(yforward(args)...);
769 }
770
774 DefGetterMem(const ynothrow, SizeType, Size, this->GetRef())
775
776
780 PDefH(void, clear, )
781 ImplExpr(this->GetNewRef().clear())
782 };
783
784
786 template<typename... _tParams>
787 struct EventArgsHead
788 {
789 using type = ystdex::conditional_t<sizeof...(_tParams) == 0, void,
790 ystdex::tuple_element_t<0, tuple<_tParams...>>>;
791 };
792
793 template<typename... _tParams>
794 struct EventArgsHead<tuple<_tParams...>> : EventArgsHead<_tParams...>
795 {};
796
797
804 template<typename _type, typename _func = std::function<void(_type&)>>
805 class GHandlerAdaptor : private GHandlerAdaptor<void, _func>
806 {
807 private:
809 using Base = GHandlerAdaptor<void, _func>;
810
811 public:
813 using typename Base::CallerType;
814
816 using Base::Caller;
818 lref<_type> ObjectRef;
819
820 GHandlerAdaptor(_type& obj, CallerType f)
821 : Base(f), ObjectRef(obj)
822 {}
823 template<typename _fCaller>
824 GHandlerAdaptor(_type& obj, _fCaller&& f)
825 : Base(ystdex::make_expanded<CallerType>(yforward(f))), ObjectRef(obj)
826 {}
828
829 DefDeCopyMoveCtorAssignment(GHandlerAdaptor)
830
831 using Base::operator();
833
838 friend PDefHOp(bool, ==, const GHandlerAdaptor& x, const GHandlerAdaptor& y)
839 ynothrow
840 ImplRet(std::addressof(x.ObjectRef.get())
841 == std::addressof(y.ObjectRef.get()))
842 };
843
845 template<typename _func>
846 class GHandlerAdaptor<void, _func>
847 {
848 public:
849 using CallerType = ystdex::decay_t<_func>;
850
851 CallerType Caller;
852
853 GHandlerAdaptor(CallerType f)
854 : Caller(f)
855 {}
856 template<typename _fCaller, yimpl(
857 typename = ystdex::exclude_self_t<GHandlerAdaptor, _fCaller>)>
858 GHandlerAdaptor(_fCaller&& f)
859 : Caller(ystdex::make_expanded<CallerType>(yforward(f)))
860 {}
861 DefDeCopyCtor(GHandlerAdaptor)
862 DefDeMoveCtor(GHandlerAdaptor)
863
864 DefDeCopyAssignment(GHandlerAdaptor)
865 DefDeMoveAssignment(GHandlerAdaptor)
866
868 template<typename... _tParams>
869 void
870 operator()(_tParams&&... args) const
871 {
872 TryExpr(Caller(yforward(args)...))
873 CatchIgnore(std::bad_function_call&)
874 }
875
880 friend PDefHOp(bool, ==, const GHandlerAdaptor& x, const GHandlerAdaptor& y)
881 ynothrow
882 ImplRet(&x == &y)
883 };
885
886
891 template<class _tEvent, typename _tBaseArgs>
892 class GEventWrapper : public _tEvent, implements GIHEvent<_tBaseArgs>
893 {
894 public:
895 using EventType = _tEvent;
896 using BaseArgsType = _tBaseArgs;
897 using EventArgsType = _t<EventArgsHead<typename _tEvent::TupleType>>;
898
904 size_t
905 operator()(BaseArgsType e) const ImplI(GIHEvent<_tBaseArgs>)
906 {
907 return EventType::operator()(EventArgsType(yforward(e)));
908 }
909
911 DefClone(const ImplI(GIHEvent<_tBaseArgs>), GEventWrapper)
912 };
913
914
920 template<typename _tBaseArgs>
921 class GEventPointerWrapper
922 {
923 public:
924 using ItemType = GIHEvent<_tBaseArgs>;
925 using PointerType = unique_ptr<ItemType>;
926
927 private:
928 PointerType ptr;
929
930 public:
932 template<typename _type, yimpl(
933 typename = ystdex::exclude_self_t<GEventPointerWrapper, _type>)>
934 inline
935 GEventPointerWrapper(_type&& p)
936 ynoexcept(std::is_nothrow_constructible<PointerType, _type>())
937 : ptr(Nonnull(p))
938 {}
942 GEventPointerWrapper(const GEventPointerWrapper& item)
943 : ptr(ystdex::clone_polymorphic(Deref(item.ptr)))
944 {}
945 DefDeMoveCtor(GEventPointerWrapper)
946
947 yconstfn DefCvt(const ynothrow, const ItemType&, *ptr)
948 yconstfn DefCvt(const ynothrow, ItemType&, *ptr)
949 };
950
951
956 #define DefExtendEventMap(_n, _b) \
957 DefExtendClass(YF_API, _n, public _b)
958
959 } // namespace YSLib;
960
961 #endif
962
YSLib::GDependencyEvent::operator-=
ReferenceType operator-=(_type _arg)
移除事件响应。
Definition: YEvent.hpp:733
YSLib::GEventGuard
使用 RAII 管理的事件辅助类。
Definition: YEvent.hpp:670
YSLib::DeclDerivedI
DeclDerivedI(YF_API, IValueHolder, ystdex::any_ops::holder) enum Creation
带等于接口的动态泛型持有者接口。
Definition: YObject.h:107
DefDeCopyAssignment
#define DefDeCopyAssignment(_t)
Definition: YBaseMacro.h:186
YSLib::GDependencyEvent::ReferentType
typename GDependency< _tEvent >::ReferentType ReferentType
Definition: YEvent.hpp:706
YSLib::GHandlerAdaptor::ObjectRef
lref< _type > ObjectRef
Definition: YEvent.hpp:818
ystdex::cloneable
可动态复制的抽象基类。
Definition: base.h:117
YSLib::GDependencyEvent::Remove
ReferenceType Remove(_type &obj, _tRet(_type::*pm)(_tParams...))
移除事件响应：目标为指定对象引用和成员函数指针。
Definition: YEvent.hpp:755
DeclIEntry
#define DeclIEntry(_sig)
Definition: YBaseMacro.h:396
YSLib::GEvent< _tRet(_tParams...), _tInvoker >::const_reverse_iterator
typename ContainerType::const_reverse_iterator const_reverse_iterator
Definition: YEvent.hpp:335
YSLib::AddUnique
GEvent< _tRet(_tParams...)> & AddUnique(GEvent< _tRet(_tParams...)> &evt, const typename GEvent< _tRet(_tParams...)>::HandlerType &h, EventPriority prior=DefaultEventPriority)
添加单一事件响应：删除后添加。
Definition: YEvent.hpp:632
YSLib::GHandlerAdaptor< void, _func >
Definition: YEvent.hpp:846
ystdex::cond_t
conditional_t< _tCond::value, _tThen, _tElse > cond_t
条件判断。
Definition: type_traits.hpp:738
YSLib::GCombinerInvoker::result_type
_type result_type
Definition: YEvent.hpp:254
YSLib::GEventWrapper::operator()
size_t operator()(BaseArgsType e) const ImplI(GIHEvent< _tBaseArgs >)
委托调用。
Definition: YEvent.hpp:905
YSLib::GEventGuard::GEventGuard
GEventGuard(EventType &evt, _type &&handler, EventPriority prior=DefaultEventPriority)
Definition: YEvent.hpp:680
yconstfn
#define yconstfn
指定编译时常量函数。
Definition: ydef.h:680
YSLib::GEvent
事件模板。
Definition: YEvent.hpp:306
YSLib::EventPriority
std::uint8_t EventPriority
事件优先级。
Definition: YEvent.hpp:211
YSLib::GHEvent< _tRet(_tParams...)>::GHEvent
yconstfn GHEvent(_fCallable &&f, ystdex::enable_if_t< !std::is_constructible< BaseType, _fCallable >::value, int >=0)
使用扩展函数对象。
Definition: YEvent.hpp:145
YSLib
YSLib 命名空间。
Definition: AndroidHost.h:45
YSLib::GDependencyEvent::PointerType
typename GDependency< _tEvent >::PointerType PointerType
Definition: YEvent.hpp:703
YSLib::GEventWrapper< YSLib::GEvent< void(YSLib::UI::PaintEventArgs &&)>, YSLib::UI::UIEventArgs && >::EventArgsType
_t< EventArgsHead< typename YSLib::GEvent< void(YSLib::UI::PaintEventArgs &&)>::TupleType >> EventArgsType
Definition: YEvent.hpp:897
YSLib::GHandlerAdaptor< void, _func >::CallerType
ystdex::decay_t< _func > CallerType
Definition: YEvent.hpp:849
YSLib::GCombinerInvoker
结果组合调用器。
Definition: YEvent.hpp:249
iterator.hpp
通用迭代器。
platform::KeyCodes::DS::Insert
Definition: Keys.h:260
YSLib::DefaultEventPriority
yconstexpr const EventPriority DefaultEventPriority(0x80)
默认事件优先级。
platform::Deref
yconstfn auto Deref(_type &&p) -> decltype(*p)
断言并解引用非空指针。
Definition: Debug.h:451
YSLib::UI::y
SPos SPos y
Definition: YWidget.cpp:44
NPL::x
const TermNode &term ynothrow const TermNode &term ynothrow const TermNode &term ynothrow TermNode &term const TermNode &term ValueNode &node const ValueNode &node const _type & x
Definition: SContext.h:94
YSLib::GDefaultLastValueInvoker
GCombinerInvoker< _type, ystdex::default_last_value< _type >> GDefaultLastValueInvoker
默认结果组合调用器。
Definition: YEvent.hpp:291
ystdex::cpp2014::rbegin
auto rbegin(_tRange &c) -> decltype(c.rbegin())
Definition: range.hpp:94
YSLib::GCombinerInvoker::combiner
_tCombiner combiner
Definition: YEvent.hpp:257
ystdex::clone_polymorphic
auto clone_polymorphic(const _type &v) -> decltype(v.clone())
使用 clone 成员函数复制多态类类型对象。
Definition: memory.hpp:1115
CHRLib::f
f(d, s)
ynoexcept_spec
#define ynoexcept_spec(...)
表达式 noexcept 异常规范。
Definition: ydef.h:794
YSLib::GHEvent< _tRet(_tParams...)>::GEquality::Decayed
ystdex::decay_t< _tFunctor > Decayed
Definition: YEvent.hpp:89
YSLib::GHEvent< _tRet(_tParams...)>::GHEvent
yconstfn GHEvent(_type &obj, _tRet(_type::*pm)(_tParams...))
构造：使用对象引用和成员函数指针。
Definition: YEvent.hpp:159
platform::bool
std::FILE *fp bool
Definition: FileIO.h:1280
ystdex::cpp2014::crend
auto crend(const _tRange &c) -> decltype(ystdex::rend(c))
Definition: range.hpp:150
DefDeMoveCtor
#define DefDeMoveCtor(_t)
Definition: YBaseMacro.h:167
YSLib::CountedHandlerInvoker::operator()
size_t operator()(_tIn first, _tIn last, _tParams &&...args) const
Definition: YEvent.hpp:232
ImplI
#define ImplI(...)
Definition: YBaseMacro.h:388
YSLib::GDependencyEvent::operator()
SizeType operator()(_tParams &&...args) const
调用函数。
Definition: YEvent.hpp:766
YSLib::GEvent< _tRet(_tParams...), _tInvoker >::iterator
typename ContainerType::iterator iterator
Definition: YEvent.hpp:336
ystdex::cpp2014::enable_if_t
typename enable_if< _bCond, _type >::type enable_if_t
Definition: type_traits.hpp:343
YSLib::GHEvent< _tRet(_tParams...)>::GEquality::AreEqual
static bool AreEqual(const GHEvent &x, const GHEvent &y) ynoexcept_spec(ystdex
Definition: YEvent.hpp:96
ystdex::cpp2014::cend
auto cend(const _tRange &c) -> decltype(std::end(c))
Definition: range.hpp:87
DefDeCopyMoveCtorAssignment
#define DefDeCopyMoveCtorAssignment(_t)
Definition: YBaseMacro.h:202
CHRLib::args
_tParams && args
Definition: CharacterProcessing.h:538
yconstexpr
#define yconstexpr
指定编译时常量表达式。
Definition: ydef.h:679
YSLib::GEvent< _tRet(_tParams...), _tInvoker >::const_iterator
typename ContainerType::const_iterator const_iterator
Definition: YEvent.hpp:332
YSLib::GEventPointerWrapper::GEventPointerWrapper
GEventPointerWrapper(_type &&p) ynoexcept(std
Definition: YEvent.hpp:935
CatchIgnore
#define CatchIgnore(_ex)
指定异常处理器忽略指定异常。
Definition: YBaseMacro.h:133
ystdex::optional_last_value
合并可选值序列。
Definition: optional.h:562
DefClone
#define DefClone(_q, _t)
动态复制。
Definition: YBaseMacro.h:294
ystdex::cpp2011::end
_type * end(_type(&&array)[_vN])
Definition: range.hpp:54
YSLib::GEvent< _tRet(_tParams...), _tInvoker >::value_type
typename ContainerType::value_type value_type
Definition: YEvent.hpp:340
yunseq
#define yunseq
无序列依赖表达式组求值。
Definition: ydef.h:1022
YSLib::GHandlerAdaptor< void, _func >::GHandlerAdaptor
GHandlerAdaptor(_fCaller &&f)
Definition: YEvent.hpp:858
ystdex::cpp2014::rend
auto rend(_tRange &c) -> decltype(c.rend())
Definition: range.hpp:119
ystdex::lref
左值引用包装。
Definition: ref.hpp:74
YSLib::UI::EventMapping::ItemType
GIHEvent< UIEventArgs && > ItemType
Definition: YWidgetEvent.h:483
TryExpr
#define TryExpr(...)
指定表达式在 try 块中求值。
Definition: YBaseMacro.h:120
YSLib::EventArgsHead::type
ystdex::conditional_t< sizeof...(_tParams)==0, void, ystdex::tuple_element_t< 0, tuple< _tParams... >>> type
Definition: YEvent.hpp:790
YSLib::GEvent< _tRet(_tParams...), _tInvoker >::result_type
decltype(std::declval< _tInvoker & >()(std::declval< const_iterator >(), std::declval< const_iterator >(), std::declval< _tParams >()...)) result_type
Definition: YEvent.hpp:345
YSLib::PDefH
PDefH(Environment &, FetchEnvironment,) ImplRet(FetchGlobalInstance().GetEnvironmentRef()) inline PDefH(GUIHost &
取单一环境对象引用。
DefDeMoveAssignment
#define DefDeMoveAssignment(_t)
Definition: YBaseMacro.h:191
YSLib::GDependencyEvent::operator+=
ReferenceType operator+=(_type _arg)
添加事件响应。
Definition: YEvent.hpp:723
YSLib::GEvent< _tRet(_tParams...), _tInvoker >::reference
typename ContainerType::reference reference
Definition: YEvent.hpp:337
YSLib::GHEvent< _tRet(_tParams...)>::BaseType
std::function< FuncType > BaseType
Definition: YEvent.hpp:80
ystdex::dep_ops::equality_comparable
_t< details::ops_seq< _type, _type2, _tOpt, cond_t< is_same< _type, _type2 >, index_sequence< 7 >, index_sequence< 6, 7, 8 >>>> equality_comparable
Definition: operators.hpp:243
YSLib::GEvent< _tRet(_tParams...), _tInvoker >::ContainerType
multimap< EventPriority, HandlerType, std::greater< EventPriority >> ContainerType
容器类型。
Definition: YEvent.hpp:327
container.hpp
通用容器操作。
ystdex::cpp2014::decay_t
typename decay< _type >::type decay_t
Definition: type_traits.hpp:340
ystdex::cpp2014::cbegin
auto cbegin(const _tRange &c) -> decltype(std::begin(c))
Definition: range.hpp:79
ystdex::cpp2014::tuple_element_t
_t< std::tuple_element< _vIdx, _type >> tuple_element_t
Definition: tuple.hpp:50
ystdex
特性测试宏。
Definition: ydef.h:822
YSLib::GDependencyEvent
依赖事件项模板。
Definition: YEvent.hpp:699
DefDeDtor
#define DefDeDtor(_t)
Definition: YBaseMacro.h:177
YSLib::GHandlerAdaptor
事件处理器适配器模板。
Definition: YEvent.hpp:805
ystdex::lref::get
_type & get() const
Definition: ref.hpp:108
YSLib::i
return i
Definition: YCoreUtilities.h:176
YSLib::EventArgsHead
Definition: YEvent.hpp:787
DefGetterMem
#define DefGetterMem(_q, _t, _n, _m)
Definition: YBaseMacro.h:247
YSLib::GEventPointerWrapper
事件项类型。
Definition: YEvent.hpp:921
YSLib::GHEvent< _tRet(_tParams...)>::comp_eq
Comparer comp_eq
比较函数：相等关系。
Definition: YEvent.hpp:116
ystdex::any_ops::clone
Definition: any.h:233
YSLib::GHandlerAdaptor< void, _func >::GHandlerAdaptor
GHandlerAdaptor(CallerType f)
Definition: YEvent.hpp:853
ystdex::examiners::equal::are_equal
static auto are_equal(_type1 &&x, _type2 &&y) -> decltype(bool(x==y))
Definition: examiner.hpp:53
EndDecl
#define EndDecl
Definition: YBaseMacro.h:398
YSLib::CountedHandlerInvoker
计数调用器：调用事件处理器并计数。
Definition: YEvent.hpp:224
YSLib::GEventGuard::Handler
HandlerType Handler
Definition: YEvent.hpp:677
YSLib::GCombinerInvoker::operator()
result_type operator()(_tIn first, _tIn last, _tParams &&...args) const
Definition: YEvent.hpp:262
YSLib::yimpl
YF_API yimpl(GUIApplication &) FetchGlobalInstance()
取全局应用程序实例。
YSLib::GEvent< _tRet(_tParams...), _tInvoker >::TupleType
typename HandlerType::TupleType TupleType
Definition: YEvent.hpp:319
YSLib::ynothrow
YB_PURE const _type size_t n ynothrow
Definition: YCoreUtilities.h:168
base.h
基类实用设施。
functional.hpp
函数和可调用对象。
YSLib::GDependencyEvent::ReferenceType
typename GDependency< _tEvent >::ReferenceType ReferenceType
Definition: YEvent.hpp:707
ystdex::cpp2014::crbegin
auto crbegin(const _tRange &c) -> decltype(ystdex::rbegin(c))
Definition: range.hpp:143
YSLib::GDependencyEvent::SizeType
typename EventType::SizeType SizeType
Definition: YEvent.hpp:712
ystdex::is_decayed
判断指定类型是否已退化。
Definition: type_traits.hpp:906
YSLib::GEvent< _tRet(_tParams...), _tInvoker >::GEvent
GEvent(_tHandler &&h, InvokerType ivk={})
构造：使用指定调用器并添加事件处理器。
Definition: YEvent.hpp:380
operators.hpp
重载操作符。
CHRLib::e
const char const char * e
Definition: CharacterProcessing.h:109
YSLib::GEvent< _tRet(_tParams...), _tInvoker >::reverse_iterator
typename ContainerType::reverse_iterator reverse_iterator
Definition: YEvent.hpp:338
YSLib::UI::Styles::Handler
std::function< void(PaintEventArgs &&)> Handler
样式处理器。
Definition: YStyle.h:380
YSLib::GDependencyEvent::FuncType
typename EventType::FuncType FuncType
Definition: YEvent.hpp:710
ystdex::nullptr_t
空指针类。
Definition: ydef.h:861
ystdex::get_value
const second_tag get_value
Definition: iterator.hpp:593
ystdex::exclude_self_t
enable_if_t<!is_same< _tClass &, decay_t< _tParam > & >::value, _type > exclude_self_t
移除选择类类型的特定重载避免构造模板和复制/转移特殊成员函数冲突。
Definition: type_traits.hpp:748
YSLib::GEvent< _tRet(_tParams...), _tInvoker >::DefDeCtor
yconstfn DefDeCtor(GEvent) GEvent(InvokerType ivk)
无参数构造：默认实现。
Definition: YEvent.hpp:366
YSLib::GHEvent< _tRet(_tParams...)>::GHEvent
yconstfn GHEvent(_fCallable f, ystdex::enable_if_t< std::is_constructible< BaseType, _fCallable >::value, int >=0)
使用函数对象。
Definition: YEvent.hpp:133
YSLib::GDependencyEvent::GDependencyEvent
GDependencyEvent(PointerType p=PointerType())
Definition: YEvent.hpp:714
std
Definition: memory.hpp:1183
YSLib::ImplRet
ImplRet(FetchGlobalInstance().GetGUIHostRef()) YF_API void Execute(GUIApplication &
执行程序主消息循环。
YSLib::GEventPointerWrapper::ItemType
GIHEvent< _tBaseArgs > ItemType
Definition: YEvent.hpp:924
YSLib::GDependencyEvent::SEventType
typename EventType::SEventType SEventType
Definition: YEvent.hpp:709
platform::Nonnull
_type && Nonnull(_type &&p) ynothrowv
断言并返回非空参数。
Definition: Debug.h:422
YSLib::GEvent< _tRet(_tParams...), _tInvoker >::const_reference
typename ContainerType::const_reference const_reference
Definition: YEvent.hpp:333
DefCvt
#define DefCvt(_q, _t,...)
Definition: YBaseMacro.h:206
YSLib::GDependencyEvent::EventType
DependentType EventType
Definition: YEvent.hpp:708
YModules.h
YSLib::GEvent< _tRet(_tParams...), _tInvoker >::InvokerType
_tInvoker InvokerType
Definition: YEvent.hpp:329
YSLib::Drawing::Size
屏幕区域大小。
Definition: YGDIBase.h:293
YSLib::GHEvent< _tRet(_tParams...)>::TupleType
tuple< _tParams... > TupleType
Definition: YEvent.hpp:78
YSLib::GDependencyEvent::DependentType
typename GDependency< _tEvent >::DependentType DependentType
Definition: YEvent.hpp:702
implements
#define implements
Definition: YBaseMacro.h:352
YSLib::GHandlerAdaptor::CallerType
ystdex::decay_t< _func > CallerType
Definition: YEvent.hpp:849
yforward
#define yforward(_expr)
根据参数类型使用 std::forward 传递对应参数。
Definition: ydef.h:995
YSLib::GHandlerAdaptor::GHandlerAdaptor
GHandlerAdaptor(_type &obj, _fCaller &&f)
Definition: YEvent.hpp:824
YSLib::UI::UIEventArgs
用户界面事件参数基类。
Definition: YWidgetEvent.h:59
optional.h
可选值包装类型。
YSLib::GEventPointerWrapper::ptr
PointerType ptr
Definition: YEvent.hpp:928
YSLib::GEventGuard::Event
lref< EventType > Event
Definition: YEvent.hpp:676
YSLib::GHEvent< _tRet(_tParams...)>::FuncType
_tRet(_tParams...) FuncType
Definition: YEvent.hpp:79
YSLib::GHandlerAdaptor< void, _func >::DefDeCopyCtor
DefDeCopyCtor(GHandlerAdaptor) DefDeMoveCtor(GHandlerAdaptor) DefDeCopyAssignment(GHandlerAdaptor) DefDeMoveAssignment(GHandlerAdaptor) template< typename..._tParams > void operator()(_tParams &&...args) const
Definition: YEvent.hpp:861
ystdex::cpp2014::conditional_t
typename conditional< _bCond, _type, _type2 >::type conditional_t
Definition: type_traits.hpp:346
YSLib::GHandlerAdaptor< void, _func >::Caller
CallerType Caller
Definition: YEvent.hpp:851
ystdex::cpp2011::begin
_type * begin(_type(&&array)[_vN])
Definition: range.hpp:46
YSLib::GHandlerAdaptor::GHandlerAdaptor
GHandlerAdaptor(_type &obj, CallerType f)
Definition: YEvent.hpp:820
YSLib::GHEvent< _tRet(_tParams...)>::Comparer
bool(*)(const GHEvent &, const GHEvent &) Comparer
比较函数类型。
Definition: YEvent.hpp:84
YSLib::GEventPointerWrapper::PointerType
unique_ptr< ItemType > PointerType
Definition: YEvent.hpp:925
ystdex::size
auto size(const _tRange &c) -> decltype(c.size())
类容器访问。
Definition: range.hpp:233
ystdex::optional
可选值对象包装。
Definition: optional.h:233
YSLib::GEventWrapper
事件包装类模板。
Definition: YEvent.hpp:892
YSLib::GEventGuard::HandlerType
GHEvent< _tEventArgs... > HandlerType
Definition: YEvent.hpp:674
YSLib::GEventGuard::~GEventGuard
~GEventGuard()
Definition: YEvent.hpp:686
YSLib::GEventPointerWrapper::GEventPointerWrapper
GEventPointerWrapper(const GEventPointerWrapper &item)
复制构造：深复制。
Definition: YEvent.hpp:942
YSLib::GEvent< _tRet(_tParams...), _tInvoker >::FuncType
typename HandlerType::FuncType FuncType
Definition: YEvent.hpp:320
YSLib::GDependencyEvent::Add
ReferenceType Add(_type &obj, _tRet(_type::*pm)(_tParams...))
添加事件响应：使用对象引用和成员函数指针。
Definition: YEvent.hpp:744
YSLib::GEvent< _tRet(_tParams...), _tInvoker >::size_type
typename ContainerType::size_type size_type
Definition: YEvent.hpp:339
ynoexcept
#define ynoexcept(...)
YSLib 无异常抛出保证：指定特定的异常规范。
Definition: ydef.h:746
YSLib::GDependencyEvent::HandlerType
typename EventType::HandlerType HandlerType
Definition: YEvent.hpp:711
YSLib::GHEvent< _tRet(_tParams...)>
事件处理器接口模板。
Definition: YEvent.hpp:72
CHRLib::p
const auto p(d)
YSLib::GDependencyEvent::ConstReferenceType
typename GDependency< _tEvent >::ConstReferenceType ConstReferenceType
Definition: YEvent.hpp:705
YSLib::GHEvent< _tRet(_tParams...)>::GHEvent
yconstfn GHEvent(FuncType *f={})
构造：使用函数指针。
Definition: YEvent.hpp:124
YSLib::operator==
bool operator==(const shared_ptr< _type > &sp, _type *p)
比较： shared_ptr 和内建指针类型的相等关系。
Definition: YShellDefinition.h:62
YSLib::swap
void swap(ValueNode &x, ValueNode &y) ynothrow
Definition: ValueNode.cpp:73
ystdex::details::get
get())
Definition: cast.hpp:102