messages.hpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // SPDX-License-Identifier: MIT
  2. // SPDX-FileCopyrightText: 2022 Ivan Baidakou
  3. #pragma once
  4. #include "definitions.hpp"
  5. #include "message.hpp"
  6. namespace rotor_light::message {
  7. /** \struct ChangeState
  8. * \brief State Change command, from supervisor/actor to actor
  9. */
  10. struct ChangeState : Message {
  11. /** synthethic message id used as anchor for rotor-light messages */
  12. static constexpr auto undef = std::numeric_limits<MessageTypeId>::max();
  13. /** message type identifyer */
  14. static constexpr auto type_id = undef - 1;
  15. /** records destination and state change command */
  16. ChangeState(ActorId to, details::StateCommand command_)
  17. : Message(to), command{command_} {}
  18. /** state change command */
  19. details::StateCommand command;
  20. };
  21. /** \struct ChangeStateAck
  22. * \brief State Change confirmation, from actor to supervisor
  23. */
  24. struct ChangeStateAck : Message {
  25. /** message type identifyer */
  26. static constexpr auto type_id = ChangeState::type_id - 1;
  27. /** records origin of the state change and success marker */
  28. ChangeStateAck(ActorId to, ActorId from_, State state_, bool success_)
  29. : Message(to), from{from_}, state{state_}, success{success_} {}
  30. /** origin/source actor */
  31. ActorId from;
  32. /** asked/subject state */
  33. State state;
  34. /** success marker */
  35. bool success;
  36. };
  37. /** \struct RefreshTime
  38. * \brief Idle message, refreshes time and triggers expired timers
  39. */
  40. struct RefreshTime : Message {
  41. /** message type identifyer */
  42. static constexpr auto type_id = ChangeStateAck::type_id - 1;
  43. /** use parent's ctor */
  44. using Message::Message;
  45. };
  46. } // namespace rotor_light::message