20#include <unordered_map>
22#include <carma_ros2_utils/timers/Timer.hpp>
23#include <carma_ros2_utils/timers/TimerFactory.hpp>
24#include <carma_ros2_utils/timers/ROSTimerFactory.hpp>
25#include <gtest/gtest_prod.h>
36 using Timer = carma_ros2_utils::timers::Timer;
43 std::unordered_map<uint32_t, std::pair<TimerPtr, bool>>
timers_;
72 void onGeofenceActive(std::function<
void(std::shared_ptr<Geofence>)> active_callback);
78 void onGeofenceInactive(std::function<
void(std::shared_ptr<Geofence>)> inactive_callback);
112 void startGeofenceCallback(std::shared_ptr<Geofence> gf_ptr,
const unsigned int schedule_id,
const int32_t timer_id);
122 void endGeofenceCallback(std::shared_ptr<Geofence> gf_ptr,
const unsigned int schedule_id,
const int32_t timer_id);
A GeofenceScheduler is responsable for notifying the user when a geofence is active or inactive accor...
void onGeofenceActive(std::function< void(std::shared_ptr< Geofence >)> active_callback)
Method which allows the user to set a callback which will be triggered when a geofence becomes active...
void endGeofenceCallback(std::shared_ptr< Geofence > gf_ptr, const unsigned int schedule_id, const int32_t timer_id)
The callback which is triggered when a geofence becomes in-active This will call the user set inactiv...
std::unique_ptr< Timer > TimerPtr
rcl_clock_type_t clock_type_
rcl_clock_type_t getClockType()
Get the clock type of the clock being created by the timer factory.
GeofenceScheduler(std::shared_ptr< TimerFactory > timerFactory)
Constructor which takes in a TimerFactory. Timers from this factory will be used to generate the trig...
std::function< void(std::shared_ptr< Geofence >)> active_callback_
carma_ros2_utils::timers::ROSTimerFactory ROSTimerFactory
rclcpp::Time now()
Get current time used by scheduler.
carma_ros2_utils::timers::Timer Timer
void startGeofenceCallback(std::shared_ptr< Geofence > gf_ptr, const unsigned int schedule_id, const int32_t timer_id)
The callback which is triggered when a geofence becomes active This will call the user set active_cal...
uint32_t nextId()
Generates the next id to be used for a timer.
std::unique_ptr< Timer > deletion_timer_
std::function< void(std::shared_ptr< Geofence >)> inactive_callback_
void addGeofence(std::shared_ptr< Geofence > gf_ptr)
Add a geofence to the scheduler. This will cause it to trigger an event when it becomes active or goe...
void onGeofenceInactive(std::function< void(std::shared_ptr< Geofence >)> inactive_callback)
Method which allows the user to set a callback which will be triggered when a geofence becomes in-act...
std::unordered_map< uint32_t, std::pair< TimerPtr, bool > > timers_
carma_ros2_utils::timers::TimerFactory TimerFactory
std::shared_ptr< TimerFactory > timerFactory_
void clearTimers()
Clears the expired timers from the memory of this scheduler.