Skip to content

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), where event is an Event object and x and y are floats, must be valid and return a type compatible with handle_converted_event.
  • The expression handle_converted_event(converted_event), where converted_event is returned by event_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
    });
Clone this wiki locally