Skip to content

Basic Context

Andrew Gresyk edited this page Apr 1, 2022 · 4 revisions

Context

  1. Context is a user-defined type, for sharing data between user scope, and state methods.

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

Tests

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

    using Config = ffsm2::Config
                        ::ContextT<TContext>;
    
    using M = ffsm2::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