Skip to content

Context

Andrew Gresyk edited this page Apr 12, 2024 · 1 revision
  1. Context is a user-defined type, for sharing data between user scope, and state methods.

    struct Context {};
    using Config = hfsm2::Config::ContextT<Context&>;
    using M = hfsm2::MachineT<Config>;

Tests

  1. Set context type (can be a value, a reference or a pointer):

    using Config = hfsm2::Config
                        ::ContextT<TContext>;
    
    using M = hfsm2::MachineT<Config>;
Method Description
Instance(const Context&); Construct FSM instance with context
Context& Instance::context();
const Context& Instance::context() const;
Access context
void Instance::setContext(const Context&); Assign context