xtd 0.2.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
delegates

Definition

Contains delegates definitions.

Classes

class  xtd::delegate< result_t(arguments_t...)>
 Represents a delegate, which is a data structure that refers to a static method or to a class instance && an instance method of that class. More...
 

Typedefs

template<class type_t >
using xtd::comparison = xtd::delegate< int32(type_t x, type_t y)>
 Represents the method that compares two objects of the same type.
 
template<class output_t , class input_t >
using xtd::converter = xtd::delegate< output_t(input_t input)>
 Represents a method that converts an object from one type to another type.
 
using xtd::async_callback = xtd::delegate< void(async_result ar)>
 References a method to be called when a corresponding asynchronous operation completes.
 
template<class result_t , class ... arguments_t>
using xtd::func = xtd::delegate< result_t(arguments_t... arguments)>
 Represents a delegate that has variables parameters and returns a value of the type specified by the result_t type.
 
using xtd::threading::parameterized_thread_start = xtd::delegate< void(const xtd::any_object &obj)>
 Represents the method that executes on a xtd::threading::thread.
 
using xtd::threading::thread_start = xtd::delegate< void()>
 Represents the method that executes on a xtd::threading::thread.
 
using xtd::threading::wait_callback = xtd::delegate< void(const xtd::any_object &state)>
 Represents a callback method to be executed by a thread pool thread.
 
using xtd::threading::wait_or_timer_callback = xtd::delegate< void(const xtd::any_object &state, bool timed_out)>
 Represents a method to be called when a xtd::threading::wait_handle is signaled or times out.
 
using xtd::forms::message_loop_callback = xtd::delegate< bool()>
 Represents a method that will check whether the hosting environment is still sending messages.
 

Typedef Documentation

◆ comparison

template<class type_t >
using xtd::comparison = typedef xtd::delegate<int32(type_t x, type_t y)>

#include <xtd.core/include/xtd/comparison.hpp>

Represents the method that compares two objects of the same type.

template<class type_t>
using comparison = xtd::delegate<int32(type_t x, type_t y)>;
xtd::delegate< int32(type_t x, type_t y)> comparison
Represents the method that compares two objects of the same type.
Definition comparison.hpp:33
int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:23
@ y
The Y key.
@ x
The X key.
Parameters
type_tThe type of the objects to compare.
xThe first object to compare.
yThe second object to compare.
Returns
A signed integer that indicates the relative values of x and y, as shown in the following table.
Value Meaning
less than 0 x is less than y.
0 x equals y.
Greater than 0 x is greater than y.
Header
#include <xtd/comparison>
Library
xtd.core

◆ converter

template<class output_t , class input_t >
using xtd::converter = typedef xtd::delegate<output_t(input_t input)>

#include <xtd.core/include/xtd/converter.hpp>

Represents a method that converts an object from one type to another type.

template<class output_t, class input_t>
using converter = xtd::delegate<output_t(input_t input)>;
xtd::delegate< output_t(input_t input)> converter
Represents a method that converts an object from one type to another type.
Definition converter.hpp:33
Template Parameters
input_tThe type of object that is to be converted. This type parameter is contravariant. That is, you can use either the type you specified or any type that is less derived.
output_the type the input object is to be converted to. This type parameter is covariant. That is, you can use either the type you specified or any type that is more derived.
Parameters
inputThe object to convert.
Returns
The output_t that represents the converted input_t.
Header
#include <xtd/converter>
Namespace
xtd
Library
xtd.core
Remarks
This delegate is used by the xtd::array::convert_all method of the xtd::array class and the xtd::collections::generic::list::convert_all method of the xtd::collections::generic::list <type_t> class to convert each element of the collection from one type to another.
Examples
The following example defines a method named point_f_to_point that converts a xtd::drawing::point_f structure to a xtd::drawing::point structure. The example then creates a xtd::collections::generic::list <type_t> of xtd::drawing::point_f structures, creates a xtd::converter <point_f, point> delegate to represent the point_f_to_point method, and passes the delegate to the xtd::collections::generic::list::convert_all method. The xtd::collections::generic::list::convert_all method passes each element of the input list to the point_f_to_point method and puts the converted elements into a new list of Point structures. Both lists are displayed.
#include <xtd/xtd>
using namespace xtd;
using namespace xtd::collections::generic;
using namespace xtd::drawing;
class example {
public:
static auto main() -> void {
auto lpf = list<point_f> {};
lpf.add(point_f {27.8f, 32.62f});
lpf.add(point_f {99.3f, 147.273f});
lpf.add(point_f {7.5f, 1412.2f});
console::write_line();
for (const auto& p : lpf)
console::write_line(p);
console::write_line();
for (const auto& p : lp)
console::write_line(p);
}
static point point_f_to_point(const point_f& pf) {
return point {as<int>(pf.x), as<int>(pf.y)};
}
};
startup_(example::main);
// This code produces the following output :
//
//
// {x=27.8, y=32.62}
// {x=99.3, y=147.273}
// {x=7.5, y=1412.2}
//
// {x=28, y=33}
// {x=99, y=147}
// {x=8, y=1412}
Represents a strongly typed list of objects that can be accessed by index. Provides methods to search...
Definition list.hpp:80
void add(const type_t &item) override
Adds an object to the end of the xtd::collections::generic::list <type_t>.
Definition list.hpp:480
list< output_t > convert_all(xtd::converter< output_t, const type_t & > converter) const
Converts the elements in the current xtd::colllections::generic::list <type_t> to another type,...
Definition list.hpp:637
Represents the standard input, output, and error streams for console applications.
Definition console.hpp:36
#define startup_(main_method)
Defines the entry point to be called when the application loads. Generally this is set either to the ...
Definition startup.hpp:167
@ p
The P key.
The xtd::collections::generic namespace contains interfaces and classes that define generic collectio...
Definition comparer.hpp:16
The xtd::drawing namespace provides access to GDI+ basic graphics functionality. More advanced functi...
Definition actions_system_images.hpp:10
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10
Represents an ordered pair of floating-point x- and y-coordinates that defines a point in a two-dimen...
Definition point_f.hpp:35
float x
Gets or sets the x-coordinate of this xtd::drawing::point_f.
Definition point_f.hpp:72
float y
Gets or sets the y-coordinate of this xtd::drawing::point_f.
Definition point_f.hpp:76
Represents an ordered pair of integer x- and y-coordinates that defines a point in a two-dimensional ...
Definition point.hpp:54

◆ async_callback

using xtd::async_callback = typedef xtd::delegate<void(async_result ar)>

#include <xtd.core/include/xtd/delegate.hpp>

References a method to be called when a corresponding asynchronous operation completes.

using async_callback = xtd::delegate<void(async_result ar)>;
xtd::delegate< void(async_result ar)> async_callback
References a method to be called when a corresponding asynchronous operation completes.
Definition delegate.hpp:39
xtd::sptr< xtd::iasync_result > async_result
Represents the status of an asynchronous operation.
Definition async_result.hpp:19
Parameters
arThe result of the asynchronous operation.
Header
#include <xtd/async_callback>
Namespace
xtd
Library
xtd.core

◆ func

template<class result_t , class ... arguments_t>
using xtd::func = typedef xtd::delegate<result_t(arguments_t... arguments)>

#include <xtd.core/include/xtd/func.hpp>

Represents a delegate that has variables parameters and returns a value of the type specified by the result_t type.

using event_handler = xtd::delegate<void(xtd::object& sender, const xtd::event_args& e)>;
Represents the base class for classes that contain event data, and provides a value to use for events...
Definition event_args.hpp:18
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:43
generic_event_handler< const xtd::event_args & > event_handler
Represents the method that will handle an event that has no event data.
Definition event_handler.hpp:24
@ e
The E key.
Template Parameters
result_tThe type of the return value of the method that this delegate encapsulates.
...arguments_tThe type of parameter list of the method that this delegate encapsulates.
Parameters
argumentsThe parameter list of the method that this delegate encapsulates.
Returns
The return value of the method that this delegate encapsulates.
Header
#include <xtd/func>
Namespace
xtd
Library
xtd.core

◆ parameterized_thread_start

using xtd::threading::parameterized_thread_start = typedef xtd::delegate<void(const xtd::any_object& obj)>

#include <xtd.core/include/xtd/threading/parameterized_thread_start.hpp>

Represents the method that executes on a xtd::threading::thread.

using parameterized_thread_start = xtd::delegate<void(const xtd::any_object& obj)>;
Represent a polymorphic wrapper capable of holding any type.
Definition any_object.hpp:29
xtd::delegate< void(const xtd::any_object &obj)> parameterized_thread_start
Represents the method that executes on a xtd::threading::thread.
Definition parameterized_thread_start.hpp:29
Parameters
objAn object that contains data for the thread procedure.
delegate< void(arguments_t...)> action
Represents a xtd::delegate that has variable parameters and does not return a value.
Definition action.hpp:20
Header
#include <xtd/threading/parameterized_thread_start>
Namespace
xtd::threading
Library
xtd.core

◆ thread_start

using xtd::threading::thread_start = typedef xtd::delegate<void()>

#include <xtd.core/include/xtd/threading/thread_start.hpp>

Represents the method that executes on a xtd::threading::thread.

using thread_start = xtd::delegate<void()>;
xtd::delegate< void()> thread_start
Represents the method that executes on a xtd::threading::thread.
Definition thread_start.hpp:24
Header
#include <xtd/threading/thread_start>
Namespace
xtd::threading
Library
xtd.core

◆ wait_callback

using xtd::threading::wait_callback = typedef xtd::delegate<void(const xtd::any_object& state)>

#include <xtd.core/include/xtd/threading/wait_callback.hpp>

Represents a callback method to be executed by a thread pool thread.

using wait_callback = xtd::delegate<void(const xtd::any_object& state)>;
xtd::delegate< void(const xtd::any_object &state)> wait_callback
Represents a callback method to be executed by a thread pool thread.
Definition wait_callback.hpp:30
Parameters
stateAn object containing information to be used by the callback method.
Header
#include <xtd/threading/wait_callback>
Namespace
xtd::threading
Library
xtd.core
Remarks
xtd::threading::wait_callback represents a callback method that you want to execute on a xtd::threading::thread_pool thread. Create the delegate by passing your callback method to the xtd::threading::wait_callback constructor. Your method must have the signature shown here.
Queue the method for execution by passing the xtd::threading::wait_callback delegate to xtd::threading::thread_pool::queue_user_work_item. The callback method executes when a thread pool thread becomes available.
If you want to pass information to the callback method, create an object that contains the necessary information and pass it to the xtd::threading::thread_pool::queue_user_work_item(xtd::threading::wait_callback, xtd::object&) method as the second argument. Each time the callback method executes, the state parameter contains this object.
For examples that use the xtd::threading::wait_callback delegate, see the xtd::threading::thread_pool::queue_user_work_item method.

◆ wait_or_timer_callback

using xtd::threading::wait_or_timer_callback = typedef xtd::delegate<void(const xtd::any_object& state, bool timed_out)>

#include <xtd.core/include/xtd/threading/wait_or_timer_callback.hpp>

Represents a method to be called when a xtd::threading::wait_handle is signaled or times out.

using wait_or_timer_callback = xtd::delegate<void(const xtd::any_object& state, bool timed_out)>;
xtd::delegate< void(const xtd::any_object &state, bool timed_out)> wait_or_timer_callback
Represents a method to be called when a xtd::threading::wait_handle is signaled or times out.
Definition wait_or_timer_callback.hpp:30
Parameters
stateAn object containing information to be used by the callback method each time it executes.
timed_outtrue if the xtd::threading::wait_handle timed out; false if it was signaled.
Header
#include <xtd/threading/wait_or_timer_callback>
Namespace
xtd::threading
Library
xtd.core
Remarks
xtd::threading::wait_or_timer_callback represents a callback method that you want to execute when a registered wait handle times out or is signaled. Create the delegate by passing your callback method to the xtd::threading::wait_or_timer_callback constructor. Your method must have the signature shown here.
Create the registered wait handle by passing the xtd::threading::wait_or_timer_callback delegate and a xtd::threading::wait_handle to xtd::threading::thread_pool::register_wait_for_single_object. Your callback method executes each time the xtd::threading::wait_handle times out or is signaled.
If you want to pass information to your callback method, create an object that contains the necessary information and pass it to xtd::threading::thread_pool::register_wait_for_single_object when you create the registered wait handle. Each time your callback method executes, the state parameter contains this object.

◆ message_loop_callback

using xtd::forms::message_loop_callback = typedef xtd::delegate<bool()>

#include <xtd.forms/include/xtd/forms/message_loop_callback.hpp>

Represents a method that will check whether the hosting environment is still sending messages.

using message_loop_callback = xtd::delegate<bool()>;
xtd::delegate< bool()> message_loop_callback
Represents a method that will check whether the hosting environment is still sending messages.
Definition message_loop_callback.hpp:26
Returns
true if the hosting environment is still sending messages; otherwise, false.
Header
#include <xtd/forms/message_loop_callback>
Namespace
xtd::forms
Library
xtd.forms
Remarks
This delegate is used with the application::register_message_loop method.