YSTest: YEvent.hpp 源文件

YSTest PreAlpha_b700_20160611 The YSLib Test Project

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

- 文件列表
- 文件成员

YEvent.hpp
浏览该文件的文档.
1 /*
2 © 2010-2016 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/base.h> // for ystdex::cloneable;
37 #include <ystdex/operators.hpp> // for ystdex::equality_comparable;
38 #include <ystdex/functional.hpp> // for ystdex::make_expanded, ystdex::default_last_value;
39 #include <ystdex/optional.h> // for ystdex::optional_last_value;
40
41 namespace YSLib
42 {
43
48 template<typename... _tParams>
49 DeclDerivedI(, GIHEvent, ystdex::cloneable)
50 DeclIEntry(size_t operator()(_tParams...) const)
52 DeclIEntry(GIHEvent* clone() const ImplI(ystdex::cloneable))
53 EndDecl
54
55 template<typename... _tParams>
56 GIHEvent<_tParams...>::DefDeDtor(GIHEvent)
57
58
66 template<typename>
67 class GHEvent;
68
70 template<typename _tRet, typename... _tParams>
71 class GHEvent<_tRet(_tParams...)>
72 : protected std::function<_tRet(_tParams...)>,
73 private ystdex::equality_comparable<GHEvent<_tRet(_tParams...)>>,
74 private ystdex::equality_comparable<GHEvent<_tRet(_tParams...)>, nullptr_t>
75 {
76 public:
77 using TupleType = tuple<_tParams...>;
78 using FuncType = _tRet(_tParams...);
79 using BaseType = std::function<FuncType>;
80
81 private:
83 using Comparer = bool(*)(const GHEvent&, const GHEvent&);
84 template<class _tFunctor>
85 struct GEquality
86 {
88
89 using decayed_type = ystdex::decay_t<_tFunctor>;
90
92 static bool
93 AreEqual(const GHEvent& x, const GHEvent& y)
94 ynoexcept_spec(std::declval<const decayed_type>()
95 == std::declval<const decayed_type>())
96 {
97 const auto p(x.template target<decayed_type>());
98
99 if(const auto q = y.template target<decayed_type>())
100 return p == q || (p && *p == *q);
101 else
102 return !p;
103 return {};
104 }
106 };
107
108 Comparer comp_eq;
109
110 public:
115 yconstfn
116 GHEvent(FuncType* f = {})
117 : BaseType(f), comp_eq(GEquality<FuncType>::AreEqual)
118 {}
123 template<class _fCallable>
124 yconstfn
125 GHEvent(_fCallable f, ystdex::enable_if_t<
126 std::is_constructible<BaseType, _fCallable>::value, int> = 0)
127 : BaseType(f), comp_eq(GetComparer(f, f))
128 {}
134 template<class _fCallable>
135 yconstfn
136 GHEvent(_fCallable&& f, ystdex::enable_if_t<
137 !std::is_constructible<BaseType, _fCallable>::value, int> = 0)
138 : BaseType(ystdex::make_expanded<_tRet(_tParams...)>(yforward(f))),
139 comp_eq(GHEvent::AreAlwaysEqual)
140 {}
146 template<class _type>
147 yconstfn
148 GHEvent(_type& obj, _tRet(_type::*pm)(_tParams...))
149 : GHEvent([&, pm](_tParams... args) ynoexcept(
150 noexcept((obj.*pm)(yforward(args)...))
151 && std::is_nothrow_copy_constructible<_tRet>::value){
152 return (obj.*pm)(yforward(args)...);
153 })
154 {}
155 DefDeCopyMoveCtorAssignment(GHEvent)
156
157
158 friend yconstfn bool
159 operator==(const GHEvent& x, const GHEvent& y)
160 {
161 return
162 #if defined(YF_DLL) || defined(YF_BUILD_DLL)
163 x.BaseType::target_type() == y.BaseType::target_type()
164 #else
165 x.comp_eq == y.comp_eq
166 #endif
167 && (x.comp_eq(x, y));
168 }
169
171 using BaseType::operator();
172
174 using BaseType::operator bool;
175
176 private:
178
179 template<typename _type>
180 static yconstfn Comparer
181 GetComparer(_type& x, _type& y, decltype(x == y) = {}) ynothrow
182 {
183 return GEquality<_type>::AreEqual;
184 }
185 template<typename _type, typename _tUnused>
186 static yconstfn Comparer
187 GetComparer(_type&, _tUnused&) ynothrow
188 {
189 return GHEvent::AreAlwaysEqual;
190 }
191
192 static yconstfn bool
193 AreAlwaysEqual(const GHEvent&, const GHEvent&) ynothrow
194 {
195 return true;
196 }
198 };
200
205 template<typename _tRet, typename... _tParams>
206 yconstfn bool
207 operator==(const GHEvent<_tRet(_tParams...)>& x, nullptr_t)
208 {
209 return !x;
210 }
211
212
217 using EventPriority = std::uint8_t;
218
219
224 yconstexpr const EventPriority DefaultEventPriority(0x80);
225
226
228
229 struct CountedHandlerInvoker
231 {
236 template<typename _tIn, typename... _tParams>
237 size_t
238 operator()(_tIn first, _tIn last, _tParams&&... args) const
239 {
240 size_t n(0);
241
242 while(first != last)
243 {
244 TryExpr((*first)(yforward(args)...))
245 CatchIgnore(std::bad_function_call&)
246 yunseq(++n, ++first);
247 }
248 return n;
249 }
250 };
251
252
254 template<typename _type, typename _tCombiner>
255 struct GCombinerInvoker
256 {
257 static_assert(ystdex::is_decayed<_tCombiner>(), "Invalid type found.");
258
259 public:
260 using result_type = _type;
261
262 private:
263 _tCombiner combiner;
264
265 public:
266 template<typename _tIn, typename... _tParams>
267 result_type
268 operator()(_tIn first, _tIn last, _tParams&&... args) const
269 {
270 // XXX: Blocked. 'yforward' cause G++ 5.2 crash: internal
271 // compiler error: Aborted (program cc1plus).
272 #if 0
273 const auto tr([&](_tIn iter){
274 return ystdex::make_transform(iter, [&](_tIn i){
275 // XXX: Blocked. 'std::forward' still cause G++ 5.2 crash:
276 // internal compiler error: in execute, at cfgexpand.c:6044.
277 // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65992.
278 return (*i)(std::forward<_tParams>(args)...);
279 });
280 });
281 #else
282 const auto f([&](_tIn i){
283 return (*i)(std::forward<_tParams>(args)...);
284 });
285 const auto tr([f](_tIn iter){
286 return ystdex::make_transform(iter, f);
287 });
288 #endif
289 return combiner(tr(first), tr(last));
290 }
291 };
292
293
295 template<typename _type>
296 using GDefaultLastValueInvoker
297 = GCombinerInvoker<_type, ystdex::default_last_value<_type>>;
298
300 template<typename _type>
301 using GOptionalLastValueInvoker = GCombinerInvoker<ystdex::cond_t<std::is_void<
302 _type>, void, ystdex::optional<_type>>, ystdex::optional_last_value<_type>>;
303
304
305
311 template<typename, typename = CountedHandlerInvoker>
312 class GEvent;
313
318 template<typename _tRet, typename... _tParams, typename _tInvoker>
319 class GEvent<_tRet(_tParams...), _tInvoker>
320 {
321 public:
323
324 using HandlerType = GHEvent<_tRet(_tParams...)>;
325 using TupleType = typename HandlerType::TupleType;
326 using FuncType = typename HandlerType::FuncType;
328
332 using ContainerType
333 = multimap<EventPriority, HandlerType, std::greater<EventPriority>>;
335 using InvokerType = _tInvoker;
337
338 using const_iterator = typename ContainerType::const_iterator;
339 using const_reference = typename ContainerType::const_reference;
340 using const_reverse_iterator
341 = typename ContainerType::const_reverse_iterator;
342 using iterator = typename ContainerType::iterator;
343 using reference = typename ContainerType::reference;
344 using reverse_iterator = typename ContainerType::reverse_iterator;
345 using size_type = typename ContainerType::size_type;
346 using value_type = typename ContainerType::value_type;
348 using result_type = decltype(std::declval<_tInvoker&>()(
350 std::declval<const_iterator>(), std::declval<const_iterator>(),
351 std::declval<_tParams>()...));
352
357 InvokerType Invoker{};
358
359 private:
364 ContainerType handlers{};
365
366 public:
372 yconstfn DefDeCtor(GEvent)
377 GEvent(InvokerType ivk)
378 : Invoker(std::move(ivk))
379 {}
384 template<typename _tHandler,
385 yimpl(typename = ystdex::exclude_self_t<GEvent, _tHandler>)>
386 GEvent(_tHandler&& h, InvokerType ivk = {})
387 : Invoker(std::move(ivk))
388 {
389 Add(yforward(h));
390 }
392 DefDeCopyMoveCtorAssignment(GEvent)
393
394
398 template<typename _tHandler,
399 yimpl(typename = ystdex::exclude_self_t<GEvent, _tHandler>)>
400 inline GEvent&
401 operator=(_tHandler&& _arg)
402 {
403 return *this = GEvent(yforward(_arg));
404 }
405
407
408
412 inline PDefHOp(GEvent&, +=, const HandlerType& h)
413 ImplRet(Add(h))
418 inline PDefHOp(GEvent&, +=, HandlerType&& h)
419 ImplRet(Add(std::move(h)))
424 template<typename _type>
425 inline GEvent&
426 operator+=(_type&& _arg)
427 {
428 return Add(HandlerType(yforward(_arg)));
429 }
430
432 GEvent&
433 operator-=(const HandlerType& h)
434 {
435 ystdex::erase_all_if<ContainerType>(handlers, handlers.cbegin(),
436 handlers.cend(), [&](decltype(*handlers.cbegin()) pr){
437 return pr.second == h;
438 });
439 return *this;
440 }
445 inline PDefHOp(GEvent&, -=, HandlerType&& h)
446 ImplRet(*this -= static_cast<const HandlerType&>(h))
451 template<typename _type>
452 inline GEvent&
453 operator-=(_type&& _arg)
454 {
455 return *this -= HandlerType(yforward(_arg));
456 }
458
466 inline PDefH(GEvent&, Add, const HandlerType& h,
468 EventPriority prior = DefaultEventPriority)
469 ImplRet(Insert(h, prior), *this)
471 inline PDefH(GEvent&, Add, HandlerType&& h,
472 EventPriority prior = DefaultEventPriority)
473 ImplRet(Insert(std::move(h), prior), *this)
475 template<typename _type>
476 inline GEvent&
477 Add(_type&& _arg, EventPriority prior = DefaultEventPriority)
478 {
479 return Add(HandlerType(yforward(_arg)), prior);
480 }
485 template<class _tObj, class _type>
486 inline GEvent&
487 Add(_tObj& obj, _tRet(_type::*pm)(_tParams...),
488 EventPriority prior = DefaultEventPriority)
489 {
490 return Add(HandlerType(static_cast<_type&>(obj), std::move(pm)), prior);
491 }
493
500 inline PDefH(typename ContainerType::iterator, Insert, const HandlerType& h,
502 EventPriority prior = DefaultEventPriority)
503 ImplRet(handlers.emplace(prior, h))
505 inline PDefH(typename ContainerType::iterator, Insert, HandlerType&& h,
506 EventPriority prior = DefaultEventPriority)
507 ImplRet(handlers.emplace(prior, std::move(h)))
509 template<typename _type>
510 inline typename ContainerType::iterator
511 Insert(_type&& _arg, EventPriority prior = DefaultEventPriority)
512 {
513 return Insert(HandlerType(yforward(_arg)), prior);
514 }
516 template<class _tObj, class _type>
517 inline typename ContainerType::iterator
518 Insert(_tObj& obj, _tRet(_type::*pm)(_tParams...),
519 EventPriority prior = DefaultEventPriority)
520 {
521 return
522 Insert(HandlerType(static_cast<_type&>(obj), std::move(pm)), prior);
523 }
525
530 template<class _tObj, class _type>
531 inline GEvent&
532 Remove(_tObj& obj, _tRet(_type::*pm)(_tParams...))
533 {
534 return *this -= HandlerType(static_cast<_type&>(obj), std::move(pm));
535 }
536
541 bool
542 Contains(const HandlerType& h) const
543 {
544 using ystdex::get_value;
545
546 return std::count(handlers.cbegin() | get_value,
547 handlers.cend() | get_value, h) != 0;
548 }
553 template<typename _type>
554 inline bool
555 Contains(_type&& _arg) const
556 {
557 return Contains(HandlerType(yforward(_arg)));
558 }
559
564 PDefHOp(result_type, (), _tParams... args) const
565 ImplRet(Invoker(handlers.cbegin() | ystdex::get_value,
566 handlers.cend() | ystdex::get_value, yforward(args)...))
567
569 PDefH(const_iterator, cbegin, ) const ynothrow
570 ImplRet(handlers.cbegin())
571
573
574 PDefH(iterator, begin, ) ynothrow
575 ImplRet(handlers.begin())
576 PDefH(iterator, begin, ) const ynothrow
577 ImplRet(handlers.begin())
578
580 PDefH(const_iterator, cend, ) const ynothrow
581 ImplRet(handlers.cend())
582
584 PDefH(void, clear, ) ynothrow
585 ImplRet(handlers.clear())
586
588
589 PDefH(size_type, count, EventPriority prior) const ynothrow
590 ImplRet(handlers.count(prior))
591
592 PDefH(const_reverse_iterator, crbegin, ) const ynothrow
593 ImplRet(handlers.crbegin())
594
595 PDefH(const_reverse_iterator, crend, ) const ynothrow
596 ImplRet(handlers.crend())
598
599 PDefH(bool, empty, ) const ynothrow
600 ImplRet(handlers.empty())
601
602 PDefH(iterator, end, ) ynothrow
603 ImplRet(handlers.end())
604 PDefH(iterator, end, ) const ynothrow
605 ImplRet(handlers.end())
607
609
610 PDefH(reverse_iterator, rbegin, ) ynothrow
611 ImplRet(handlers.rbegin())
612
613 PDefH(reverse_iterator, rend, ) ynothrow
614 ImplRet(handlers.rend())
615
617 PDefH(size_type, size, ) const ynothrow
618 ImplRet(handlers.size())
620
625 PDefH(void, swap, GEvent& e) ynothrow
626 ImplRet(handlers.swap(e))
627 };
629
630
636 template<typename _tRet, typename... _tParams>
637 inline GEvent<_tRet(_tParams...)>&
638 AddUnique(GEvent<_tRet(_tParams...)>& evt,
639 const typename GEvent<_tRet(_tParams...)>::HandlerType& h,
640 EventPriority prior = DefaultEventPriority)
641 {
642 return (evt -= h).Add(h, prior);
643 }
644 template<typename _tRet, typename... _tParams>
645 inline GEvent<_tRet(_tParams...)>&
646 AddUnique(GEvent<_tRet(_tParams...)>& evt, typename GEvent<_tRet(_tParams...)>
647 ::HandlerType&& h, EventPriority prior = DefaultEventPriority)
648 {
649 return (evt -= h).Add(std::move(h), prior);
650 }
651 template<typename _type, typename _tRet, typename... _tParams>
652 inline GEvent<_tRet(_tParams...)>&
653 AddUnique(GEvent<_tRet(_tParams...)>& evt, _type&& arg,
654 EventPriority prior = DefaultEventPriority)
655 {
656 return AddUnique(evt, HandlerType(yforward(arg)), prior);
657 }
659 template<class _type, typename _tRet, typename... _tParams>
660 inline GEvent<_tRet(_tParams...)>&
661 AddUnique(GEvent<_tRet(_tParams...)>& evt, _type& obj,
662 _tRet(_type::*pm)(_tParams...), EventPriority prior = DefaultEventPriority)
663 {
664 return AddUnique(evt, HandlerType(static_cast<_type&>(obj), std::move(pm)),
665 prior);
666 }
668
673 template<typename _tRet, typename... _tParams>
674 inline DefSwap(ynothrow, GEvent<_tRet(_tParams...)>)
675
676
677
682 template<typename... _tEventArgs>
683 class GEventGuard
684 {
685 public:
686 using EventType = GEvent<_tEventArgs...>;
687 using HandlerType = GHEvent<_tEventArgs...>;
689 lref<EventType> Event;
690 HandlerType Handler;
691
692 template<typename _type>
693 GEventGuard(EventType& evt, _type&& handler,
694 EventPriority prior = DefaultEventPriority)
695 : Event(evt), Handler(yforward(handler))
696 {
697 Event.get().Add(Handler, prior);
698 }
699 ~GEventGuard()
700 {
701 Event.get() -= Handler;
702 }
703 };
704
705
711 template<class _tEvent, class _tOwnerPointer = shared_ptr<_tEvent>>
712 class GDependencyEvent : public GDependency<_tEvent, _tOwnerPointer>
713 {
714 public:
715 using DependentType = typename GDependency<_tEvent>::DependentType;
716 using PointerType = typename GDependency<_tEvent>::PointerType;
717 using ConstReferenceType
718 = typename GDependency<_tEvent>::ConstReferenceType;
719 using ReferentType = typename GDependency<_tEvent>::ReferentType;
720 using ReferenceType = typename GDependency<_tEvent>::ReferenceType;
721 using EventType = DependentType;
722 using SEventType = typename EventType::SEventType;
723 using FuncType = typename EventType::FuncType;
724 using HandlerType = typename EventType::HandlerType;
725 using SizeType = typename EventType::SizeType;
726
727 GDependencyEvent(PointerType p = PointerType())
728 : GDependency<_tEvent>(p)
729 {}
730
734 template<typename _type>
735 inline ReferenceType
736 operator+=(_type _arg)
737 {
738 return this->GetNewRef().operator+=(_arg);
739 }
740
744 template<typename _type>
745 inline ReferenceType
746 operator-=(_type _arg)
747 {
748 return this->GetNewRef().operator-=(_arg);
749 }
750
755 template<class _type, typename _tRet, typename... _tParams>
756 inline ReferenceType
757 Add(_type& obj, _tRet(_type::*pm)(_tParams...))
758 {
759 return this->GetNewRef().Add(obj, pm);
760 }
761
766 template<class _type, typename _tRet, typename... _tParams>
767 inline ReferenceType
768 Remove(_type& obj, _tRet(_type::*pm)(_tParams...))
769 {
770 return this->GetNewRef().Remove(obj, pm);
771 }
772
777 template<typename... _tParams>
778 inline SizeType
779 operator()(_tParams&&... args) const
780 {
781 return this->GetRef().operator()(yforward(args)...);
782 }
783
787 DefGetterMem(const ynothrow, SizeType, Size, this->GetRef())
788
789
793 PDefH(void, clear, )
794 ImplExpr(this->GetNewRef().clear())
795 };
796
797
799 template<typename... _tParams>
800 struct EventArgsHead
801 {
802 using type = ystdex::conditional_t<sizeof...(_tParams) == 0, void,
803 ystdex::tuple_element_t<0, tuple<_tParams...>>>;
804 };
805
806 template<typename... _tParams>
807 struct EventArgsHead<tuple<_tParams...>> : EventArgsHead<_tParams...>
808 {};
809
810
817 template<typename _type, typename _func = std::function<void(_type&)>>
818 class GHandlerAdaptor : private GHandlerAdaptor<void, _func>
819 {
820 private:
822 using Base = GHandlerAdaptor<void, _func>;
823
824 public:
826 using typename Base::CallerType;
827
829 using Base::Caller;
831 lref<_type> ObjectRef;
832
833 GHandlerAdaptor(_type& obj, CallerType f)
834 : Base(f), ObjectRef(obj)
835 {}
836 template<typename _fCaller>
837 GHandlerAdaptor(_type& obj, _fCaller&& f)
838 : Base(ystdex::make_expanded<CallerType>(yforward(f))), ObjectRef(obj)
839 {}
841
842 DefDeCopyMoveCtorAssignment(GHandlerAdaptor)
843
844 using Base::operator();
846
851 friend PDefHOp(bool, ==, const GHandlerAdaptor& x, const GHandlerAdaptor& y)
852 ynothrow
853 ImplRet(std::addressof(x.ObjectRef.get())
854 == std::addressof(y.ObjectRef.get()))
855 };
856
858 template<typename _func>
859 class GHandlerAdaptor<void, _func>
860 {
861 public:
862 using CallerType = ystdex::decay_t<_func>;
863
864 CallerType Caller;
865
866 GHandlerAdaptor(CallerType f)
867 : Caller(f)
868 {}
869 template<typename _fCaller, yimpl(
870 typename = ystdex::exclude_self_t<GHandlerAdaptor, _fCaller>)>
871 GHandlerAdaptor(_fCaller&& f)
872 : Caller(ystdex::make_expanded<CallerType>(yforward(f)))
873 {}
874 DefDeCopyCtor(GHandlerAdaptor)
875 DefDeMoveCtor(GHandlerAdaptor)
876
877 DefDeCopyAssignment(GHandlerAdaptor)
878 DefDeMoveAssignment(GHandlerAdaptor)
879
881 template<typename... _tParams>
882 void
883 operator()(_tParams&&... args) const
884 {
885 TryExpr(Caller(yforward(args)...))
886 CatchIgnore(std::bad_function_call&)
887 }
888
893 friend PDefHOp(bool, ==, const GHandlerAdaptor& x, const GHandlerAdaptor& y)
894 ynothrow
895 ImplRet(&x == &y)
896 };
898
899
904 template<class _tEvent, typename _tBaseArgs>
905 class GEventWrapper : public _tEvent, implements GIHEvent<_tBaseArgs>
906 {
907 public:
908 using EventType = _tEvent;
909 using BaseArgsType = _tBaseArgs;
910 using EventArgsType = _t<EventArgsHead<typename _tEvent::TupleType>>;
911
917 size_t
918 operator()(BaseArgsType e) const ImplI(GIHEvent<_tBaseArgs>)
919 {
920 return EventType::operator()(EventArgsType(yforward(e)));
921 }
922
924 DefClone(const ImplI(GIHEvent<_tBaseArgs>), GEventWrapper)
925 };
926
927
933 template<typename _tBaseArgs>
934 class GEventPointerWrapper
935 {
936 public:
937 using ItemType = GIHEvent<_tBaseArgs>;
938 using PointerType = unique_ptr<ItemType>;
939
940 private:
941 PointerType ptr;
942
943 public:
945 template<typename _type, yimpl(
946 typename = ystdex::exclude_self_t<GEventPointerWrapper, _type>)>
947 inline
948 GEventPointerWrapper(_type&& p)
949 ynoexcept(std::is_nothrow_constructible<PointerType, _type>())
950 : ptr(Nonnull(p))
951 {}
955 GEventPointerWrapper(const GEventPointerWrapper& item)
956 : ptr(ystdex::clone_polymorphic(item.ptr))
957 {}
958 DefDeMoveCtor(GEventPointerWrapper)
959
960 yconstfn DefCvt(const ynothrow, const ItemType&, *ptr)
961 yconstfn DefCvt(const ynothrow, ItemType&, *ptr)
962 };
963
964
969 #define DefExtendEventMap(_n, _b) \
970 DefExtendClass(YF_API, _n, public _b)
971
972 } // namespace YSLib;
973
974 #endif
975
YSLib::GEvent< _tRet(_tParams...), _tInvoker >::FuncType
typename HandlerType::FuncType FuncType
Definition: YEvent.hpp:326
ystdex::cpp2014::conditional_t
typename conditional< _bCond, _type, _type2 >::type conditional_t
Definition: type_traits.hpp:353
YSLib::GEvent< _tRet(_tParams...), _tInvoker >::reverse_iterator
typename ContainerType::reverse_iterator reverse_iterator
Definition: YEvent.hpp:344
platform::p
while p p
Definition: YCLib/FileSystem.h:225
YSLib::GEvent< _tRet(_tParams...), _tInvoker >::InvokerType
_tInvoker InvokerType
Definition: YEvent.hpp:335
YSLib::Drawing::x
The boundary is out of the const Rect SDst SPos x
Definition: YDraw.h:127
ystdex::lref::get
_type & get() const
Definition: ref.hpp:107
YSLib::GEventPointerWrapper::PointerType
unique_ptr< ItemType > PointerType
Definition: YEvent.hpp:938
yconstexpr
#define yconstexpr
指定编译时常量表达式。
Definition: ydef.h:653
YSLib::GDependencyEvent
依赖事件项模板。
Definition: YEvent.hpp:712
YSLib::CountedHandlerInvoker
计数调用器：调用事件处理器并计数。
Definition: YEvent.hpp:230
YSLib::GHEvent< _tRet(_tParams...)>::GEquality::decayed_type
ystdex::decay_t< _tFunctor > decayed_type
Definition: YEvent.hpp:89
YSLib::GHandlerAdaptor< void, _func >::CallerType
ystdex::decay_t< _func > CallerType
Definition: YEvent.hpp:862
platform::Nonnull
_type && Nonnull(_type &&p) ynothrow
断言并返回非空指针。
Definition: Debug.h:411
YSLib::EventArgsHead
Definition: YEvent.hpp:800
YSLib::GEvent
事件模板。
Definition: YEvent.hpp:312
YSLib::GEventPointerWrapper::ItemType
GIHEvent< _tBaseArgs > ItemType
Definition: YEvent.hpp:937
YSLib::GHEvent< _tRet(_tParams...)>::GHEvent
yconstfn GHEvent(FuncType *f={})
构造：使用函数指针。
Definition: YEvent.hpp:116
YSLib::GHEvent< _tRet(_tParams...)>::GetComparer
static yconstfn Comparer GetComparer(_type &, _tUnused &) ynothrow
Definition: YEvent.hpp:187
YModules.h
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:351
ystdex::swap
void swap(container_adaptor< _tSeqCon > &x, container_adaptor< _tSeqCon > &y)
Definition: container.hpp:179
YSLib::GDependencyEvent::Remove
ReferenceType Remove(_type &obj, _tRet(_type::*pm)(_tParams...))
移除事件响应：目标为指定对象引用和成员函数指针。
Definition: YEvent.hpp:768
YSLib::GHEvent< _tRet(_tParams...)>::GHEvent
yconstfn GHEvent(_fCallable &&f, ystdex::enable_if_t< !std::is_constructible< BaseType, _fCallable >::value, int >=0)
使用扩展函数对象。
Definition: YEvent.hpp:136
ystdex::cpp2014::cend
auto cend(const _tRange &c) -> decltype(std::end(c))
Definition: range.hpp:87
iterator.hpp
通用迭代器。
ystdex::get_value
const second_tag get_value
Definition: iterator.hpp:589
YSLib::GHandlerAdaptor
事件处理器适配器模板。
Definition: YEvent.hpp:818
ystdex::cpp2014::enable_if_t
typename enable_if< _bCond, _type >::type enable_if_t
Definition: type_traits.hpp:350
YSLib::GEvent< _tRet(_tParams...), _tInvoker >::const_iterator
typename ContainerType::const_iterator const_iterator
Definition: YEvent.hpp:338
YSLib::yimpl
YF_API yimpl(GUIApplication &) FetchGlobalInstance()
取全局应用程序实例。
YSLib::GEventPointerWrapper::ptr
PointerType ptr
Definition: YEvent.hpp:941
YSLib::GHEvent< _tRet(_tParams...)>::AreAlwaysEqual
static yconstfn bool AreAlwaysEqual(const GHEvent &, const GHEvent &) ynothrow
Definition: YEvent.hpp:193
optional.h
可选值包装类型。
YSLib::GHEvent< _tRet(_tParams...)>
事件处理器接口模板。
Definition: YEvent.hpp:71
YSLib::GEventWrapper::operator()
size_t operator()(BaseArgsType e) const ImplI(GIHEvent< _tBaseArgs >)
委托调用。
Definition: YEvent.hpp:918
YSLib::GHEvent< _tRet(_tParams...)>::GHEvent
yconstfn GHEvent(_fCallable f, ystdex::enable_if_t< std::is_constructible< BaseType, _fCallable >::value, int >=0)
使用函数对象。
Definition: YEvent.hpp:125
DefDeCopyMoveCtorAssignment
#define DefDeCopyMoveCtorAssignment(_t)
Definition: YBaseMacro.h:201
YSLib
YSLib 命名空间。
Definition: AndroidHost.h:45
ImplI
#define ImplI(...)
Definition: YBaseMacro.h:386
YSLib::EventArgsHead::type
ystdex::conditional_t< sizeof...(_tParams)==0, void, ystdex::tuple_element_t< 0, tuple< _tParams... >>> type
Definition: YEvent.hpp:803
CHRLib::e
const char const char * e
Definition: CharacterProcessing.h:109
YSLib::UI::EventMapping::ItemType
GIHEvent< UIEventArgs && > ItemType
Definition: YWidgetEvent.h:483
ystdex::optional_last_value
合并可选值序列。
Definition: optional.h:566
ystdex::any_ops::clone
Definition: any.h:253
YSLib::PDefH
PDefH(Environment &, FetchEnvironment,) ImplRet(FetchGlobalInstance().GetEnvironmentRef()) inline PDefH(GUIHost &
取单一环境对象引用。
DefDeCopyAssignment
#define DefDeCopyAssignment(_t)
Definition: YBaseMacro.h:185
YSLib::EventPriority
std::uint8_t EventPriority
事件优先级。
Definition: YEvent.hpp:217
YSLib::GHEvent< _tRet(_tParams...)>::GEquality::AreEqual
static bool AreEqual(const GHEvent &x, const GHEvent &y) ynoexcept_spec(std
Definition: YEvent.hpp:93
YSLib::GDependencyEvent::PointerType
typename GDependency< _tEvent >::PointerType PointerType
Definition: YEvent.hpp:716
YSLib::GEvent< _tRet(_tParams...), _tInvoker >::ContainerType
multimap< EventPriority, HandlerType, std::greater< EventPriority >> ContainerType
容器类型。
Definition: YEvent.hpp:333
YSLib::GHandlerAdaptor< void, _func >::Caller
CallerType Caller
Definition: YEvent.hpp:864
YSLib::GHandlerAdaptor::CallerType
ystdex::decay_t< _func > CallerType
Definition: YEvent.hpp:862
YSLib::GCombinerInvoker::combiner
_tCombiner combiner
Definition: YEvent.hpp:263
YSLib::CountedHandlerInvoker::operator()
size_t operator()(_tIn first, _tIn last, _tParams &&...args) const
Definition: YEvent.hpp:238
DefGetterMem
#define DefGetterMem(_q, _t, _n, _m)
Definition: YBaseMacro.h:246
ystdex::exclude_self_t
enable_if_t<!is_same< _tClass &, decay_t< _tParam > & >::value, _type > exclude_self_t
移除选择类类型的特定重载避免构造模板和复制/转移特殊成员函数冲突。
Definition: type_traits.hpp:708
ystdex::is_decayed
判断指定类型是否已退化。
Definition: type_traits.hpp:866
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:910
ystdex::cpp2014::tuple_element_t
_t< std::tuple_element< _vIdx, _type >> tuple_element_t
Definition: tuple.hpp:50
YSLib::UI::UIEventArgs
用户界面事件参数基类。
Definition: YWidgetEvent.h:59
YSLib::GHandlerAdaptor< void, _func >::GHandlerAdaptor
GHandlerAdaptor(CallerType f)
Definition: YEvent.hpp:866
ystdex::lref
左值引用包装。
Definition: ref.hpp:74
DefCvt
#define DefCvt(_q, _t,...)
Definition: YBaseMacro.h:205
YSLib::GDependencyEvent::SEventType
typename EventType::SEventType SEventType
Definition: YEvent.hpp:722
YSLib::DeclDerivedI
DeclDerivedI(YF_API, IValueHolder, ystdex::any_ops::holder) DeclIEntry(bool operator
带等于接口的动态泛型持有者接口。
YSLib::GEventPointerWrapper::GEventPointerWrapper
GEventPointerWrapper(_type &&p) ynoexcept(std
Definition: YEvent.hpp:948
CatchIgnore
#define CatchIgnore(_ex)
指定异常处理器忽略指定异常。
Definition: YBaseMacro.h:133
YSLib::GDependencyEvent::SizeType
typename EventType::SizeType SizeType
Definition: YEvent.hpp:725
YSLib::ynothrow
YB_PURE const _type size_t n ynothrow
Definition: YCoreUtilities.h:168
YSLib::GDependencyEvent::ReferenceType
typename GDependency< _tEvent >::ReferenceType ReferenceType
Definition: YEvent.hpp:720
ynoexcept_spec
#define ynoexcept_spec(...)
表达式 noexcept 异常规范。
Definition: ydef.h:768
YSLib::GHandlerAdaptor< void, _func >::GHandlerAdaptor
GHandlerAdaptor(_fCaller &&f)
Definition: YEvent.hpp:871
DefClone
#define DefClone(_q, _t)
动态复制。
Definition: YBaseMacro.h:293
YSLib::GEvent< _tRet(_tParams...), _tInvoker >::GEvent
GEvent(_tHandler &&h, InvokerType ivk={})
构造：使用指定调用器并添加事件处理器。
Definition: YEvent.hpp:386
platform::KeyCodes::DS::Insert
Definition: Keys.h:260
container.hpp
通用容器操作。
functional.hpp
函数和可调用对象。
YSLib::GEvent< _tRet(_tParams...), _tInvoker >::DefDeCtor
yconstfn DefDeCtor(GEvent) GEvent(InvokerType ivk)
无参数构造：默认实现。
Definition: YEvent.hpp:372
base.h
基类实用设施。
YSLib::GDependencyEvent::operator()
SizeType operator()(_tParams &&...args) const
调用函数。
Definition: YEvent.hpp:779
std
Definition: memory.hpp:1100
EndDecl
#define EndDecl
Definition: YBaseMacro.h:396
YSLib::GHandlerAdaptor< void, _func >
Definition: YEvent.hpp:859
YSLib::GCombinerInvoker
结果组合调用器。
Definition: YEvent.hpp:255
YSLib::GHEvent< _tRet(_tParams...)>::TupleType
tuple< _tParams... > TupleType
Definition: YEvent.hpp:77
TryExpr
#define TryExpr(...)
指定表达式在 try 块中求值。
Definition: YBaseMacro.h:120
YSLib::GHEvent< _tRet(_tParams...)>::GHEvent
yconstfn GHEvent(_type &obj, _tRet(_type::*pm)(_tParams...))
构造：使用对象引用和成员函数指针。
Definition: YEvent.hpp:148
YSLib::GEvent< _tRet(_tParams...), _tInvoker >::iterator
typename ContainerType::iterator iterator
Definition: YEvent.hpp:342
YSLib::GEventWrapper
事件包装类模板。
Definition: YEvent.hpp:905
YSLib::GDefaultLastValueInvoker
GCombinerInvoker< _type, ystdex::default_last_value< _type >> GDefaultLastValueInvoker
默认结果组合调用器。
Definition: YEvent.hpp:297
DefDeMoveAssignment
#define DefDeMoveAssignment(_t)
Definition: YBaseMacro.h:190
ystdex::size
auto size(const _tRange &c) -> decltype(c.size())
类容器访问。
Definition: range.hpp:233
DeclIEntry
#define DeclIEntry(_sig)
Definition: YBaseMacro.h:394
YSLib::DefaultEventPriority
yconstexpr const EventPriority DefaultEventPriority(0x80)
默认事件优先级。
YSLib::GEvent< _tRet(_tParams...), _tInvoker >::value_type
typename ContainerType::value_type value_type
Definition: YEvent.hpp:346
yunseq
#define yunseq
无序列依赖表达式组求值。
Definition: ydef.h:996
ystdex::cpp2014::crend
auto crend(const _tRange &c) -> decltype(ystdex::rend(c))
Definition: range.hpp:150
ystdex
特性测试宏。
Definition: ydef.h:796
DefDeMoveCtor
#define DefDeMoveCtor(_t)
Definition: YBaseMacro.h:166
YSLib::UI::Styles::Handler
std::function< void(PaintEventArgs &&)> Handler
样式处理器。
Definition: YStyle.h:380
YSLib::Drawing::Size
屏幕区域大小。
Definition: YGDIBase.h:293
YSLib::GEvent::DefSwap
#define DefSwap(_q, _t)
使用 RAII 管理的事件辅助类。
Definition: YEvent.hpp:674
ystdex::cond_t
conditional_t< _tCond::value, _tThen, _tElse > cond_t
条件判断。
Definition: type_traits.hpp:698
YSLib::GHEvent< _tRet(_tParams...)>::Comparer
bool(*)(const GHEvent &, const GHEvent &) Comparer
比较函数类型。
Definition: YEvent.hpp:83
ystdex::nullptr_t
空指针类。
Definition: ydef.h:835
YSLib::GDependencyEvent::EventType
DependentType EventType
Definition: YEvent.hpp:721
YSLib::GHandlerAdaptor< void, _func >::DefDeCopyCtor
DefDeCopyCtor(GHandlerAdaptor) DefDeMoveCtor(GHandlerAdaptor) DefDeCopyAssignment(GHandlerAdaptor) DefDeMoveAssignment(GHandlerAdaptor) template< typename..._tParams > void operator()(_tParams &&...args) const
Definition: YEvent.hpp:874
YSLib::UI::y
SPos SPos y
Definition: YWidget.cpp:44
YSLib::i
return i
Definition: YCoreUtilities.h:176
YSLib::GCombinerInvoker::operator()
result_type operator()(_tIn first, _tIn last, _tParams &&...args) const
Definition: YEvent.hpp:268
operators.hpp
重载操作符。
YSLib::GHEvent< _tRet(_tParams...)>::BaseType
std::function< FuncType > BaseType
Definition: YEvent.hpp:79
YSLib::GHandlerAdaptor::GHandlerAdaptor
GHandlerAdaptor(_type &obj, _fCaller &&f)
Definition: YEvent.hpp:837
ynoexcept
#define ynoexcept(...)
YSLib 无异常抛出保证：指定特定的异常规范。
Definition: ydef.h:720
YSLib::GHEvent< _tRet(_tParams...)>::comp_eq
Comparer comp_eq
比较函数：相等关系。
Definition: YEvent.hpp:108
YSLib::GHEvent< _tRet(_tParams...)>::GetComparer
static yconstfn Comparer GetComparer(_type &x, _type &y, decltype(x==y)={}) ynothrow
Definition: YEvent.hpp:181
implements
#define implements
Definition: YBaseMacro.h:351
YSLib::GHEvent< _tRet(_tParams...)>::FuncType
_tRet(_tParams...) FuncType
Definition: YEvent.hpp:78
DefDeDtor
#define DefDeDtor(_t)
Definition: YBaseMacro.h:176
yconstfn
#define yconstfn
指定编译时常量函数。
Definition: ydef.h:654
YSLib::GDependencyEvent::FuncType
typename EventType::FuncType FuncType
Definition: YEvent.hpp:723
YSLib::GCombinerInvoker::result_type
_type result_type
Definition: YEvent.hpp:260
YSLib::GDependencyEvent::operator+=
ReferenceType operator+=(_type _arg)
添加事件响应。
Definition: YEvent.hpp:736
YSLib::GDependencyEvent::Add
ReferenceType Add(_type &obj, _tRet(_type::*pm)(_tParams...))
添加事件响应：使用对象引用和成员函数指针。
Definition: YEvent.hpp:757
YSLib::GDependencyEvent::HandlerType
typename EventType::HandlerType HandlerType
Definition: YEvent.hpp:724
YSLib::GHandlerAdaptor::ObjectRef
lref< _type > ObjectRef
Definition: YEvent.hpp:831
YSLib::GDependencyEvent::GDependencyEvent
GDependencyEvent(PointerType p=PointerType())
Definition: YEvent.hpp:727
ystdex::optional
可选值对象包装。
Definition: optional.h:258
YSLib::GHandlerAdaptor::GHandlerAdaptor
GHandlerAdaptor(_type &obj, CallerType f)
Definition: YEvent.hpp:833
ystdex::cpp2014::rend
auto rend(_tRange &c) -> decltype(c.rend())
Definition: range.hpp:119
YSLib::GDependencyEvent::ConstReferenceType
typename GDependency< _tEvent >::ConstReferenceType ConstReferenceType
Definition: YEvent.hpp:718
yforward
#define yforward(_expr)
根据参数类型使用 std::forward 传递对应参数。
Definition: ydef.h:969
ystdex::cpp2014::crbegin
auto crbegin(const _tRange &c) -> decltype(ystdex::rbegin(c))
Definition: range.hpp:143
ystdex::cpp2011::begin
_type * begin(_type(&&array)[_vN])
Definition: range.hpp:46
YSLib::GEventPointerWrapper::GEventPointerWrapper
GEventPointerWrapper(const GEventPointerWrapper &item)
复制构造：深复制。
Definition: YEvent.hpp:955
YSLib::IO::f
const string &path const String &path _func f
Definition: YSLib/Service/FileSystem.h:430
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::GDependencyEvent::DependentType
typename GDependency< _tEvent >::DependentType DependentType
Definition: YEvent.hpp:715
ystdex::cpp2014::rbegin
auto rbegin(_tRange &c) -> decltype(c.rbegin())
Definition: range.hpp:94
CHRLib::args
_tParams && args
Definition: CharacterProcessing.h:538
ystdex::cpp2014::cbegin
auto cbegin(const _tRange &c) -> decltype(std::begin(c))
Definition: range.hpp:79
YSLib::GEvent< _tRet(_tParams...), _tInvoker >::size_type
typename ContainerType::size_type size_type
Definition: YEvent.hpp:345
YSLib::AddUnique
GEvent< _tRet(_tParams...)> & AddUnique(GEvent< _tRet(_tParams...)> &evt, const typename GEvent< _tRet(_tParams...)>::HandlerType &h, EventPriority prior=DefaultEventPriority)
添加单一事件响应：删除后添加。
Definition: YEvent.hpp:638
ystdex::clone_polymorphic
auto clone_polymorphic(const _type &p) -> decltype(std::addressof(*p))
使用 clone 成员函数复制指定指针指向的多态类类型对象。
Definition: memory.hpp:507
YSLib::ImplRet
ImplRet(FetchGlobalInstance().GetGUIHostRef()) YF_API void Execute(GUIApplication &
执行程序主消息循环。
YSLib::GDependencyEvent::operator-=
ReferenceType operator-=(_type _arg)
移除事件响应。
Definition: YEvent.hpp:746
YSLib::GEvent< _tRet(_tParams...), _tInvoker >::const_reference
typename ContainerType::const_reference const_reference
Definition: YEvent.hpp:339
ystdex::cpp2011::end
_type * end(_type(&&array)[_vN])
Definition: range.hpp:54
platform::bool
std::FILE *fp bool
Definition: FileIO.h:1187
ystdex::cloneable
可动态复制的抽象基类。
Definition: base.h:117
YSLib::GDependencyEvent::ReferentType
typename GDependency< _tEvent >::ReferentType ReferentType
Definition: YEvent.hpp:719
YSLib::GEvent< _tRet(_tParams...), _tInvoker >::reference
typename ContainerType::reference reference
Definition: YEvent.hpp:343
platform::n
size_t n
Definition: YCLib/FileSystem.cpp:321
YSLib::GEvent< _tRet(_tParams...), _tInvoker >::TupleType
typename HandlerType::TupleType TupleType
Definition: YEvent.hpp:325
YSLib::GEventPointerWrapper
事件项类型。
Definition: YEvent.hpp:934
YSLib::operator==
bool operator==(const shared_ptr< _type > &sp, _type *p)
比较： shared_ptr 和内建指针类型的相等关系。
Definition: YShellDefinition.h:62
YSLib::GEvent< _tRet(_tParams...), _tInvoker >::const_reverse_iterator
typename ContainerType::const_reverse_iterator const_reverse_iterator
Definition: YEvent.hpp:341