Closed jbwillis closed 3 years ago
Thanks for the feedback. std::chrono
sounds like a great choice.
My understanding was CRTP is necessary when I need to pass a template argument into a class that is acting as the base class for an interface. This comes up here because I need to be able to pass a pointer to the class containing the callback function into the TimerInterface
class. Since this requires a template, it is no longer eligible to be virtual. Is there a different/cleaner way to do this?
I was trying to avoid using CRTP, which is why TimeInterface
does not use it.
The two most relevant files to look at to get an idea of what I am doing are
timer_interface.h
andros_timer.h
. Essentially I have a base classAbstractTimer
which simply provides an interface to start and stop functions. Then, there is another base classTimerInterface
with acreateTimer
function which returns anAbstractTimer
. It uses CRTP to pass down thecreateTimer
to its inheritedROSTimerInterface
class. Since theROSTimerInterface
class is created inrosflight_io
, it has to be able to handle the creation of multiple timers, so it calls new and keeps track of the timers in a vector.I am really not convinced this is a correct or best way to approach this, but it's my best shot at it. I may be missing something fundamental that would make this all come together easily. If you can provide some feedback, I'd really appreciate it.