-
Notifications
You must be signed in to change notification settings - Fork 6
convert
Alexandre Marcireau edited this page May 31, 2018
·
7 revisions
In header "../third_party/tarsier/source/convert.hpp"
tarsier::convert
maps a type to another.
namespace tarsier {
template <typename Event, typename EventToConvertedEvent, typename HandleConvertedEvent>
class convert {
public:
convert(EventToConvertedEvent event_to_converted_event, HandleConvertedEvent handle_converted_event);
/// operator() handles an event.
virtual void operator()(Event event);
};
}
-
Event
is the input type. - The expression
event_to_converted_event(event)
, whereevent
is anEvent
object andx
andy
are floats, must be valid and return a type compatible withhandle_converted_event
. - The expression
handle_converted_event(converted_event)
, whereconverted_event
is returned byevent_to_converted_event
, must be valid.
Event
and Activity
must be specified when using make_compute_activity
:
struct event {
uint16_t x;
uint16_t y;
};
struct activity {
uint16_t x;
uint16_t y;
float value;
};
auto compute_activity = tarsier::make_compute_activity<event, activity>(
320,
240,
1e6
[](event event, float value) -> activity {
return {event.x, event.y, value};
},
[](activity activity) {
// do something with activity
});