Skip to content

Conversation

@Mchan2003
Copy link
Collaborator

@Mchan2003 Mchan2003 commented Sep 15, 2025

Fixes #33

Copy link
Collaborator

@PhazonicRidley PhazonicRidley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall good! One small design question, is there a reason you are using raw pointers for your states? Do they need to stay alive after exiting? If so, is there a reason you are using raw pointers over smart pointers

@@ -0,0 +1,52 @@
#pragma once
#include <print>
#include "./state.hpp"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: include/ should be in the include path (this functionally doesn't matter but imo its cleaner without relative paths, also if we ever change our file structure then it doesn't need to be updated)

* SAFE will be stored here and shared between the states.
*
*/
class StateContext {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add doxygen style documentation (our good friend chaudexityilot is great at this)


class State;

class StateMachine {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs

void StateMachine::run_state() {
current_state->enter(context);
current_state->handle(context);
transition_state (current_state->exit(context));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prev state is dangling and is never freed


class StateMachine {
public:
StateMachine();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: No need to declare a default ctor or dtor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

State Machine boilerplate

3 participants