18 template<
class result_t>
21 template<
class result_t,
class ...arguments_t>
22 class delegate<result_t(arguments_t...)>;
55 template<
class result_t>
58 std::vector<std::function <result_t()>> functions;
67 bool completed_synchronously()
const noexcept override;
68 bool is_completed()
const noexcept override;
89 delegate(delegate&&) =
default;
90 delegate(
const delegate&) =
default;
91 delegate& operator =(
const delegate& delegate) =
default;
101 template<
class object1_t,
class object2_t>
102 delegate(
const object1_t&
object, result_t(object2_t::*method)() const) noexcept {
103 data_->functions.push_back(
function_t(std::bind(method, const_cast<object1_t*>(&
object))));
108 template<
class object1_t,
class object2_t>
109 delegate(
const object1_t&
object, result_t(object2_t::*method)()) noexcept {
110 data_->functions.push_back(
function_t(std::bind(method, const_cast<object1_t*>(&
object))));
123 bool is_empty() const noexcept {
return data_->functions.size() == 0;}
127 size_t size() const noexcept {
return data_->functions.size();}
134 void clear() {data_->functions.clear();}
171 result_t
invoke()
const {
return operator()();}
176 bool equals(
const object& obj)
const noexcept override {
return is<delegate>(obj) &&
equals(
static_cast<const delegate&
>(obj));}
180 bool equals(
const delegate& other)
const noexcept override {
181 if (data_->functions.size() !=
other.data_->functions.size())
184 for (
size_t i = 0;
i < data_->functions.size();
i++)
185 if (!are_equals(data_->functions[
i],
other.data_->functions[
i]))
202 for (
const delegate& delegate : delegates) {
203 for (
const function_t& function : delegate.data_->functions)
204 result.data_->functions.push_back(function);
214 static delegate
combine(
const delegate& a,
const delegate& b)
noexcept {
216 for (
const function_t& function :
b.data_->functions)
217 result.data_->functions.push_back(function);
226 static delegate
remove(
const delegate& source,
const delegate& value)
noexcept {
227 delegate result = source;
228 std::for_each(value.data_->functions.begin(), value.data_->functions.end(), [&](
auto function) {
229 auto iterator = std::find_if(result.data_->functions.rbegin(), result.data_->functions.rend(), [&](auto item) {return are_equals(item, function);});
230 if (iterator != result.data_->functions.rend()) result.data_->functions.erase((iterator + 1).base());
240 static delegate
remove_all(
const delegate& source,
const delegate& value)
noexcept {
241 delegate result = source;
242 for (
const function_t& function : value.data_->functions) {
243 if (find(result.data_->functions.begin(), result.data_->functions.end(), function) != result.data_->functions.end()) {
244 for (
typename function_collection::reverse_iterator iterator = result.data_->functions.rbegin(); iterator != result.data_->functions.rend(); ++iterator) {
245 if (are_equals(*iterator, function))
246 result.data_->functions.erase((iterator + 1).base());
261 if (data_->functions.size() == 0)
return result_t();
263 for (
size_t i = 0;
i < data_->functions.size() - 1;
i++) {
265 data_->functions[
i]();
268 return data_->functions.back()();
271 delegate& operator =(
const function_t& function)
noexcept {
272 data_->functions.clear();
273 data_->functions.push_back(function);
279 delegate operator +(
const delegate& other)
noexcept {
280 delegate result = *
this;
285 delegate operator +(
const function_t& function)
noexcept {
286 delegate result = *
this;
292 delegate operator +(fn_t function)
noexcept {
293 delegate result = *
this;
298 delegate& operator +=(
const delegate& delegate)
noexcept {
299 *
this = delegate::combine(*
this, delegate);
303 delegate& operator +=(
const function_t& function)
noexcept {
304 *
this = delegate::combine(*
this, delegate(function));
309 delegate& operator +=(fn_t function)
noexcept {
310 *
this = delegate::combine(*
this, delegate(function));
314 delegate operator -(
const delegate& other)
noexcept {
315 delegate result = *
this;
320 delegate operator -(
const function_t& function)
noexcept {
321 delegate result = *
this;
327 delegate operator -(fn_t function)
noexcept {
328 delegate result = *
this;
333 delegate& operator -=(
const delegate& delegate)
noexcept {
334 *
this = delegate::remove(*
this, delegate);
338 delegate& operator -=(
const function_t& function)
noexcept {
339 *
this = delegate::remove(*
this, delegate(function));
344 delegate& operator -=(fn_t function)
noexcept {
345 *
this = delegate::remove(*
this, delegate(function));
351 static bool are_equals(
const std::function<result_t()>& fct1,
const std::function<result_t()>& fct2)
noexcept {
352 return fct1.target_type() == fct2.target_type() && (fct1.template target<result_t(*)()>() == fct2.template target<result_t(*)()>() || *fct1.template target<result_t(*)()>() == *fct2.template target<result_t(*)()>());
355 static typename function_collection::const_iterator find(
typename function_collection::const_iterator begin,
typename function_collection::const_iterator end,
const function_t& function)
noexcept {
356 auto iterator = std::find_if(begin, end, [&](
auto item) {
return are_equals(item, function);});
357 if (iterator != end)
return iterator;
377 template<
class result_t,
class ...arguments_t>
378 class delegate<result_t(arguments_t...)> :
public object,
public xtd::iequatable<delegate<result_t(arguments_t...)>> {
380 std::vector<std::function <result_t()>> no_arguments_functions;
381 std::vector<std::function <result_t(arguments_t...)>> functions;
390 bool completed_synchronously()
const noexcept override;
391 bool is_completed()
const noexcept override;
416 delegate(delegate&&) =
default;
417 delegate(
const delegate&) =
default;
418 delegate& operator =(
const delegate& delegate) =
default;
419 delegate(
const delegate<result_t()>& delegate)
noexcept {data_->no_arguments_functions = delegate.functions();}
427 delegate(
const no_arguments_function_t& function)
noexcept {data_->no_arguments_functions.push_back(function);}
433 template<
class object1_t,
class object2_t>
434 delegate(
const object1_t&
object, result_t(object2_t::*method)() const) noexcept {
435 data_->functions.push_back(
function_t(std::bind(method, const_cast<object1_t*>(&
object))));
441 template<
class object1_t,
class object2_t>
442 delegate(
const object1_t&
object, result_t(object2_t::*method)()) noexcept {
443 data_->functions.push_back(
function_t(std::bind(method, const_cast<object1_t*>(&
object))));
448 template<
class object1_t,
class object2_t,
class a1_t>
449 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t) const) noexcept {
450 data_->functions.push_back(function_t(std::bind(method, const_cast<object1_t*>(&
object), std::placeholders::_1)));
453 template<
class object1_t,
class object2_t,
class a1_t>
454 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t)) noexcept {
455 data_->functions.push_back(function_t(std::bind(method, const_cast<object1_t*>(&object), std::placeholders::_1)));
458 template<
class object1_t,
class object2_t,
class a1_t,
class a2_t>
459 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t) const) noexcept {
460 data_->functions.push_back(function_t(std::bind(method, const_cast<object1_t*>(&object), std::placeholders::_1, std::placeholders::_2)));
463 template<
class object1_t,
class object2_t,
class a1_t,
class a2_t>
464 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t)) noexcept {
465 data_->functions.push_back(function_t(std::bind(method, const_cast<object1_t*>(&object), std::placeholders::_1, std::placeholders::_2)));
468 template<
class object1_t,
class object2_t,
class a1_t,
class a2_t,
class a3_t>
469 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t) const) noexcept {
470 data_->functions.push_back(function_t(std::bind(method, const_cast<object1_t*>(&object), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)));
473 template<
class object1_t,
class object2_t,
class a1_t,
class a2_t,
class a3_t>
474 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t)) noexcept {
475 data_->functions.push_back(function_t(std::bind(method, const_cast<object1_t*>(&object), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)));
478 template<
class object1_t,
class object2_t,
class a1_t,
class a2_t,
class a3_t,
class a4_t>
479 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t) const) {
480 data_->functions.push_back(function_t(std::bind(method,
const_cast<object1_t*
>(&
object), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4)));
483 template<
class object1_t,
class object2_t,
class a1_t,
class a2_t,
class a3_t,
class a4_t>
484 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t)) noexcept {
485 data_->functions.push_back(function_t(std::bind(method, const_cast<object1_t*>(&object), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4)));
488 template<
class object1_t,
class object2_t,
class a1_t,
class a2_t,
class a3_t,
class a4_t,
class A5>
489 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t, A5) const) noexcept {
490 data_->functions.push_back(function_t(std::bind(method, const_cast<object1_t*>(&object), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5)));
493 template<
class object1_t,
class object2_t,
class a1_t,
class a2_t,
class a3_t,
class a4_t,
class A5>
494 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t, A5)) {
495 data_->functions.push_back(function_t(std::bind(method,
const_cast<object1_t*
>(&
object), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5)));
498 template<
class object1_t,
class object2_t,
class a1_t,
class a2_t,
class a3_t,
class a4_t,
class A5,
class a6_t>
499 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t, A5, a6_t) const) noexcept {
500 data_->functions.push_back(function_t(std::bind(method, const_cast<object1_t*>(&object), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, std::placeholders::_6)));
503 template<
class object1_t,
class object2_t,
class a1_t,
class a2_t,
class a3_t,
class a4_t,
class A5,
class a6_t>
504 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t, A5, a6_t)) noexcept {
505 data_->functions.push_back(function_t(std::bind(method, const_cast<object1_t*>(&object), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, std::placeholders::_6)));
508 template<
class object1_t,
class object2_t,
class a1_t,
class a2_t,
class a3_t,
class a4_t,
class A5,
class a6_t,
class a7_t>
509 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t, A5, a6_t, a7_t) const) noexcept {
510 data_->functions.push_back(function_t(std::bind(method, const_cast<object1_t*>(&object), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, std::placeholders::_6, std::placeholders::_7)));
513 template<
class object1_t,
class object2_t,
class a1_t,
class a2_t,
class a3_t,
class a4_t,
class A5,
class a6_t,
class a7_t>
514 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t, A5, a6_t, a7_t)) noexcept {
515 data_->functions.push_back(function_t(std::bind(method, const_cast<object1_t*>(&object), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, std::placeholders::_6, std::placeholders::_7)));
518 template<
class object1_t,
class object2_t,
class a1_t,
class a2_t,
class a3_t,
class a4_t,
class A5,
class a6_t,
class a7_t,
class a8_t>
519 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t, A5, a6_t, a7_t, a8_t) const) noexcept {
520 data_->functions.push_back(function_t(std::bind(method, const_cast<object1_t*>(&object), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, std::placeholders::_6, std::placeholders::_7, std::placeholders::_8)));
523 template<
class object1_t,
class object2_t,
class a1_t,
class a2_t,
class a3_t,
class a4_t,
class A5,
class a6_t,
class a7_t,
class a8_t>
524 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t, A5, a6_t, a7_t, a8_t)) noexcept {
525 data_->functions.push_back(function_t(std::bind(method, const_cast<object1_t*>(&object), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, std::placeholders::_6, std::placeholders::_7, std::placeholders::_8)));
528 template<
class object1_t,
class object2_t,
class a1_t,
class a2_t,
class a3_t,
class a4_t,
class A5,
class a6_t,
class a7_t,
class a8_t,
class a9_t>
529 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t, A5, a6_t, a7_t, a8_t, a9_t) const) noexcept {
530 data_->functions.push_back(function_t(std::bind(method, const_cast<object1_t*>(&object), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, std::placeholders::_6, std::placeholders::_7, std::placeholders::_8, std::placeholders::_9)));
533 template<
class object1_t,
class object2_t,
class a1_t,
class a2_t,
class a3_t,
class a4_t,
class A5,
class a6_t,
class a7_t,
class a8_t,
class a9_t>
534 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t, A5, a6_t, a7_t, a8_t, a9_t)) noexcept {
535 data_->functions.push_back(function_t(std::bind(method, const_cast<object1_t*>(&object), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, std::placeholders::_6, std::placeholders::_7, std::placeholders::_8, std::placeholders::_9)));
538 template<
class object1_t,
class object2_t,
class a1_t,
class a2_t,
class a3_t,
class a4_t,
class A5,
class a6_t,
class a7_t,
class a8_t,
class a9_t,
class a10_t>
539 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t, A5, a6_t, a7_t, a8_t, a9_t, a10_t) const) noexcept {
540 data_->functions.push_back(function_t(std::bind(method, const_cast<object1_t*>(&object), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, std::placeholders::_6, std::placeholders::_7, std::placeholders::_8, std::placeholders::_9, std::placeholders::_10)));
543 template<
class object1_t,
class object2_t,
class a1_t,
class a2_t,
class a3_t,
class a4_t,
class A5,
class a6_t,
class a7_t,
class a8_t,
class a9_t,
class a10_t>
544 delegate(
const object1_t&
object, result_t(object2_t::*method)(a1_t, a2_t, a3_t, a4_t, A5, a6_t, a7_t, a8_t, a9_t, a10_t)) noexcept {
545 data_->functions.push_back(function_t(std::bind(method, const_cast<object1_t*>(&object), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, std::placeholders::_6, std::placeholders::_7, std::placeholders::_8, std::placeholders::_9, std::placeholders::_10)));
562 bool is_empty() const noexcept {
return data_->functions.size() == 0 && data_->no_arguments_functions.size() == 0;}
566 size_t size() const noexcept {
return data_->functions.size() + data_->no_arguments_functions.size();}
610 result_t
invoke(arguments_t&&... arguments)
const {
return operator()(arguments...);}
615 bool equals(
const object& obj)
const noexcept override {
return is<delegate>(obj) &&
equals(
static_cast<const delegate&
>(obj));}
619 bool equals(
const delegate& other)
const noexcept override {
620 if (data_->functions.size() !=
other.data_->functions.size() || data_->no_arguments_functions.size() !=
other.data_->no_arguments_functions.size())
623 for (
size_t i = 0;
i < data_->no_arguments_functions.size();
i++)
624 if (!are_equals(data_->no_arguments_functions[
i],
other.data_->no_arguments_functions[
i]))
627 for (
size_t i = 0;
i < data_->functions.size();
i++)
628 if (!are_equals(data_->functions[
i],
other.data_->functions[
i]))
645 for (
const delegate& delegate : delegates) {
647 result.data_->no_arguments_functions.push_back(function);
648 for (
const function_t& function : delegate.data_->functions)
649 result.data_->functions.push_back(function);
659 static delegate
combine(
const delegate& a,
const delegate& b)
noexcept {
662 result.data_->no_arguments_functions.push_back(function);
663 for (
const function_t& function :
b.data_->functions)
664 result.data_->functions.push_back(function);
673 static delegate
remove(
const delegate& source,
const delegate& value)
noexcept {
674 delegate result = source;
675 std::for_each(value.data_->no_arguments_functions.begin(), value.data_->no_arguments_functions.end(), [&](
auto no_arguments_function) {
676 auto iterator = std::find_if(result.data_->no_arguments_functions.rbegin(), result.data_->no_arguments_functions.rend(), [&](auto item) {return are_equals(item, no_arguments_function);});
677 if (iterator != result.data_->no_arguments_functions.rend()) result.data_->no_arguments_functions.erase((iterator + 1).base());
680 std::for_each(value.data_->functions.begin(), value.data_->functions.end(), [&](
auto function) {
681 auto iterator = std::find_if(result.data_->functions.rbegin(), result.data_->functions.rend(), [&](auto item) {return are_equals(item, function);});
682 if (iterator != result.data_->functions.rend()) result.data_->functions.erase((iterator + 1).base());
692 static delegate
remove_all(
const delegate& source,
const delegate& value)
noexcept {
693 delegate result = source;
695 if (find(result.data_->no_arguments_functions.begin(), result.data_->no_arguments_functions.end(), function) != result.data_->no_arguments_functions.end()) {
696 for (
typename function_collection::reverse_iterator iterator = result.data_->no_arguments_functions.rbegin(); iterator != result.data_->no_arguments_functions.rend(); ++iterator) {
697 if (are_equals(*iterator, function))
698 result.data_->no_arguments_functions.erase((iterator + 1).base());
703 for (
const function_t& function : value.data_->functions) {
704 if (find(result.data_->functions.begin(), result.data_->functions.end(), function) != result.data_->functions.end()) {
705 for (
typename function_collection::reverse_iterator iterator = result.data_->functions.rbegin(); iterator != result.data_->functions.rend(); ++iterator) {
706 if (are_equals(*iterator, function))
707 result.data_->functions.erase((iterator + 1).base());
722 if (data_->no_arguments_functions.size() == 0 && data_->functions.size() == 0)
return result_t();
724 if (data_->no_arguments_functions.size()) {
725 for (
size_t i = 0;
i < data_->no_arguments_functions.size() - (data_->functions.size() == 0 ? 1 : 0);
i++) {
727 data_->no_arguments_functions[
i]();
730 if (data_->functions.size() == 0) {
732 return data_->no_arguments_functions.back()();
736 for (
size_t i = 0;
i < data_->functions.size() - 1;
i++) {
738 data_->functions[
i](arguments...);
741 return data_->functions.back()(arguments...);
746 template<
class type_t>
747 delegate& operator =(
const type_t& function)
noexcept {
748 data_->no_arguments_functions.clear();
749 data_->functions.clear();
750 data_->functions.push_back(function_t(function));
754 delegate& operator =(
const function_t& function)
noexcept {
755 data_->no_arguments_functions.clear();
756 data_->functions.clear();
757 data_->functions.push_back(function);
761 delegate& operator =(
const no_arguments_function_t& function)
noexcept {
762 data_->no_arguments_functions.clear();
763 data_->functions.clear();
764 data_->no_arguments_functions.push_back(function);
768 delegate operator +(
const delegate& other)
noexcept {
769 delegate result = *
this;
774 delegate operator +(
const no_arguments_function_t& function)
noexcept {
775 delegate result = *
this;
780 delegate operator +(
const function_t& function)
noexcept {
781 delegate result = *
this;
787 delegate operator +(fn_t function)
noexcept {
788 delegate result = *
this;
793 delegate& operator +=(
const delegate& delegate)
noexcept {
794 *
this = delegate::combine(*
this, delegate);
798 delegate& operator +=(
const no_arguments_function_t& function)
noexcept {
799 *
this = delegate::combine(*
this, delegate(function));
803 delegate& operator +=(
const function_t& function)
noexcept {
804 *
this = delegate::combine(*
this, delegate(function));
809 delegate& operator +=(fn_t function)
noexcept {
810 *
this = delegate::combine(*
this, delegate(function));
814 delegate operator -(
const delegate& other)
noexcept {
815 delegate result = *
this;
820 delegate operator -(
const no_arguments_function_t& function)
noexcept {
821 delegate result = *
this;
826 delegate operator -(
const function_t& function)
noexcept {
827 delegate result = *
this;
833 delegate operator -(fn_t function)
noexcept {
834 delegate result = *
this;
839 delegate& operator -=(
const delegate& delegate)
noexcept {
840 *
this = delegate::remove(*
this, delegate);
844 delegate& operator -=(
const no_arguments_function_t& function)
noexcept {
845 *
this = delegate::remove(*
this, delegate(function));
849 delegate& operator -=(
const function_t& function)
noexcept {
850 *
this = delegate::remove(*
this, delegate(function));
855 delegate& operator -=(fn_t function)
noexcept {
856 *
this = delegate::remove(*
this, delegate(function));
862 static bool are_equals(
const std::function<result_t(arguments_t...)>& fct1,
const std::function<result_t(arguments_t...)>& fct2)
noexcept {
863 return fct1.target_type() == fct2.target_type() && (fct1.template target<result_t(*)(arguments_t...)>() == fct2.template target<result_t(*)(arguments_t...)>() || *fct1.template target<result_t(*)(arguments_t...)>() == *fct2.template target<result_t(*)(arguments_t...)>());
866 static bool are_equals(
const std::function<result_t()>& fct1,
const std::function<result_t()>& fct2)
noexcept {
867 return fct1.target_type() == fct2.target_type() && (fct1.template target<result_t(*)()>() == fct2.template target<result_t(*)()>() || *fct1.template target<result_t(*)()>() == *fct2.template target<result_t(*)()>());
870 static typename no_arguments_function_collection::const_iterator find(
typename no_arguments_function_collection::const_iterator begin,
typename no_arguments_function_collection::const_iterator end,
const no_arguments_function_t& function)
noexcept {
871 auto iterator = std::find_if(begin, end, [&](
auto item) {
return are_equals(item, function);});
872 if (iterator != end)
return iterator;
876 static typename function_collection::const_iterator find(
typename function_collection::const_iterator begin,
typename function_collection::const_iterator end,
const function_t& function)
noexcept {
877 auto iterator = std::find_if(begin, end, [&](
auto item) {
return are_equals(item, function);});
878 if (iterator != end)
return iterator;
Contains std::any type and std::bad_any_cast exception.
Contains xtd::argument_null_exception exception.
Contains xtd::async_result alias.
Represent a polymorphic wrapper capable of holding any type.
Definition any_object.hpp:29
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:61
const function_collection & functions() const
Gets the delegates array.
Definition delegate.hpp:119
delegate(const object1_t &object, result_t(object2_t::*method)()) noexcept
Initializes a delegate that invokes the specified instance method on the specified class instance.
Definition delegate.hpp:109
static delegate remove_all(const delegate &source, const delegate &value) noexcept
removes all occurrences of the invocation list of a delegate from the invocation list of another dele...
Definition delegate.hpp:240
std::vector< function_t > function_collection
Represents the function collection type.
Definition delegate.hpp:80
delegate(const object1_t &object, result_t(object2_t::*method)() const) noexcept
Initializes a delegate that invokes the specified instance method on the specified class instance.
Definition delegate.hpp:102
void clear()
Clear delegates array.
Definition delegate.hpp:134
delegate()=default
Initializes an empty delegate.
bool equals(const delegate &other) const noexcept override
Determines whether this instance and another specified delegateType object have the same value.
Definition delegate.hpp:180
bool is_empty() const noexcept
Return if the delegate is empty.
Definition delegate.hpp:123
size_t size() const noexcept
Return the size of invocation list.
Definition delegate.hpp:127
async_result begin_invoke(xtd::async_callback async_callback)
Executes the method represented by the current delegate asynchronously on the thread that the control...
delegate(const function_t &function) noexcept
Initializes a delegate that invokes the specified instance method.
Definition delegate.hpp:96
std::function< result_t()> function_t
Represents function type.
Definition delegate.hpp:78
async_result begin_invoke(xtd::async_callback async_callback, const xtd::any_object &async_state)
Executes the method represented by the current delegate asynchronously on the thread that the control...
static delegate combine(const array< delegate > &delegates) noexcept
Concatenates the invocation lists of an array of delegates.
Definition delegate.hpp:200
result_t end_invoke(async_result async)
Retrieves the return value of the asynchronous operation represented by the async_result_invoke passe...
bool equals(const object &obj) const noexcept override
Determines whether this instance and another specified delegateType object have the same value.
Definition delegate.hpp:176
static delegate combine(const delegate &a, const delegate &b) noexcept
Concatenates the invocation lists of two delegates.
Definition delegate.hpp:214
result_t invoke() const
invokes the method represented by the current delegate.
Definition delegate.hpp:171
static delegate remove(const delegate &source, const delegate &value) noexcept
removes the last occurrence of the invocation list of a delegate from the invocation list of another ...
Definition delegate.hpp:226
result_t operator()() const
invokes the method represented by the current delegate.
Definition delegate.hpp:260
async_result begin_invoke()
Executes the method represented by the current delegate asynchronously on the thread that the control...
std::function< result_t()> no_arguments_function_t
Represents no arguments function type.
Definition delegate.hpp:401
std::vector< function_t > function_collection
function_t Represents the function collection type.
Definition delegate.hpp:407
async_result begin_invoke(xtd::async_callback async_callback, const xtd::any_object &async_state, arguments_t &&... arguments)
Executes the method represented by the current delegate asynchronously on the thread that the control...
result_t end_invoke(async_result async)
Retrieves the return value of the asynchronous operation represented by the async_result_invoke passe...
delegate()=default
Initializes an empty delegate.
async_result begin_invoke(arguments_t &&... arguments)
Executes the method represented by the current delegate asynchronously on the thread that the control...
bool equals(const delegate &other) const noexcept override
Determines whether this instance and another specified delegateType object have the same value.
Definition delegate.hpp:619
std::function< result_t(arguments_t...)> function_t
Represents function type.
Definition delegate.hpp:403
delegate(const object1_t &object, result_t(object2_t::*method)()) noexcept
Initializes a delegate that invokes the specified instance method on the specified class instance.
Definition delegate.hpp:442
size_t size() const noexcept
Return the size of invocation list.
Definition delegate.hpp:566
std::vector< no_arguments_function_t > no_arguments_function_collection
function_t Represents the no arguments function collection type.
Definition delegate.hpp:405
result_t operator()(arguments_t... arguments) const
invokes the method represented by the current delegate.
Definition delegate.hpp:721
bool is_empty() const noexcept
Return if the delegate is empty.
Definition delegate.hpp:562
async_result begin_invoke(xtd::async_callback async_callback, arguments_t &&... arguments)
Executes the method represented by the current delegate asynchronously on the thread that the control...
static delegate remove(const delegate &source, const delegate &value) noexcept
removes the last occurrence of the invocation list of a delegate from the invocation list of another ...
Definition delegate.hpp:673
const function_collection & functions() const
Gets the delegates array.
Definition delegate.hpp:558
result_t invoke(arguments_t &&... arguments) const
invokes the method represented by the current delegate.
Definition delegate.hpp:610
static delegate combine(const array< delegate > &delegates) noexcept
Concatenates the invocation lists of an array of delegates.
Definition delegate.hpp:643
static delegate combine(const delegate &a, const delegate &b) noexcept
Concatenates the invocation lists of two delegates.
Definition delegate.hpp:659
static delegate remove_all(const delegate &source, const delegate &value) noexcept
removes all occurrences of the invocation list of a delegate from the invocation list of another dele...
Definition delegate.hpp:692
delegate(const function_t &function) noexcept
Initializes a delegate that invokes the specified instance method.
Definition delegate.hpp:424
bool equals(const object &obj) const noexcept override
Determines whether this instance and another specified delegateType object have the same value.
Definition delegate.hpp:615
const no_arguments_function_collection & no_arguments_functions() const
Gets the no arguments delegates array.
Definition delegate.hpp:554
delegate(const object1_t &object, result_t(object2_t::*method)() const) noexcept
Initializes a delegate that invokes the specified instance method on the specified class instance.
Definition delegate.hpp:434
static void throws(xtd::helpers::exception_case exception_case, const source_location &location=source_location::current())
Throws an exption with specified exception case.
Represents the status of an asynchronous operation.
Definition iasync_result.hpp:25
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.hpp:22
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:43
The xtd::shared_ptr_object is a shared pointer as std::shared_ptr.
Definition shared_ptr_object.hpp:30
Encapsulates operating system specific objects that wait for exclusive access to shared resources.
Definition wait_handle.hpp:52
xtd::delegate< void(async_result ar)> async_callback
References a method to be called when a corresponding asynchronous operation completes.
Definition delegate.hpp:39
@ argument_null
The argument is null.
@ other
The operating system is other.
Contains xtd::iequatable interface.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10
Contains xtd::object class.
Contains xtd::object_ref alias.
Contains xtd::threading::thread_pool class.