Skip to content

Commit

Permalink
Add _get_type_id to Impl (#8)
Browse files Browse the repository at this point in the history
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Introduced a new method for type identification in the event handling
framework, enhancing the functionality of the `EventProxy` class.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
maksimdrachov authored Nov 30, 2024
1 parent 306a574 commit d71dcfa
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions include/olg_scheduler/olg_scheduler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ class Event : private cavl::Node<Event<TimePoint>>
/// It is guaranteed that while an event resides in the tree, it has a valid deadline set.
[[nodiscard]] std::optional<TimePoint> getDeadline() const noexcept { return deadline_; }

// This method is necessary to store an Event in cetl::unbounded_variant
static constexpr std::array<std::uint8_t, 16> _get_type_id_() noexcept
{
return {0xB6, 0x87, 0x48, 0xA6, 0x7A, 0xDB, 0x4D, 0xF1, 0xB3, 0x1D, 0xA9, 0x8D, 0x50, 0xA7, 0x82, 0x47};
}

protected:
using Tree = cavl::Tree<Event>;
using cavl::Node<Event>::remove;
Expand Down Expand Up @@ -189,6 +195,7 @@ class EventLoop final
{
public:
using Event<time_point>::execute;
using Event<time_point>::_get_type_id_;
};

public:
Expand Down Expand Up @@ -219,6 +226,8 @@ class EventLoop final
this->schedule(Clock::now() + period_, owner.tree_);
}

using EventProxy::_get_type_id_;

private:
void execute(const Arg<time_point>& args, Tree& tree) override
{
Expand Down Expand Up @@ -250,6 +259,8 @@ class EventLoop final
this->schedule(Clock::now() + min_period_, owner.tree_);
}

using EventProxy::_get_type_id_;

private:
void execute(const Arg<time_point>& args, Tree& tree) override
{
Expand Down Expand Up @@ -277,6 +288,8 @@ class EventLoop final
this->schedule(deadline, owner.tree_);
}

using EventProxy::_get_type_id_;

private:
void execute(const Arg<time_point>& args, Tree&) override
{
Expand Down

0 comments on commit d71dcfa

Please sign in to comment.