jfayot / dynamic-state-machine Goto Github PK
View Code? Open in Web Editor NEWDynamic StateMachine where states and transitions are created runtime
License: MIT License
Dynamic StateMachine where states and transitions are created runtime
License: MIT License
Users should be able to provide actions and guards through other callbable types: std::function, lambdas, raw functions...
Some functions' templated parameters should be passed as rvalue reference with perfect forwarding, rather than lvalue reference.
User should be able to reset the history either from the state machine itself, or from within any inner state (inside an action for instance)
When you are using the transit function outside off a processEvent it is not processed until the next processEvent.
The following test will fail :
_sm.addState<NiceMock<s0>, Entry>();
_sm.addState<NiceMock<s1>>();
_sm.addTransition<s0, e0, s0, &s0::onEvent0>();
s0* _s0 = _sm.getState<s0>();
ON_CALL(*_s0, onEvent0(_)).WillByDefault(Invoke([&] () { _s0->transit<s1>(); }));
_sm.start();
_s0->transit<s1>();
ASSERT_TRUE((_sm.checkStates<s1>()));
Move all implementation details to a dedicated namespace
The application crash in debug with the following exception when using postEvent in an onEntry call.
cannot seek value-initilized deque iterator.
The m_postedTransitions list is modified while something else is using an iterator on it.
It can be reproduced with the following test :
_sm.addState<NiceMock<s0>, Entry>();
_sm.addState<NiceMock<s1>>();
_sm.addTransition<s0, e0, s0, &s0::onEvent0>();
_sm.addTransition<s1, e1, s1, &s1::onEvent1>();
s0* _s0 = _sm.getState<s0>();
s1* _s1 = _sm.getState<s1>();
ON_CALL(*_s0, onEvent0(_)).WillByDefault(Invoke([&] () { _s0->transit<s1>(); }));
ON_CALL(*_s1, onEntry0()).WillByDefault(Invoke([&] () { _s1->postEvent(e1{}); }));
ON_CALL(*_s1, onEvent1(_)).WillByDefault(Invoke([&] () { std::cout << "toto" << std::endl; }));
_sm.start();
_sm.processEvent(e0{});
ASSERT_TRUE((_sm.checkStates<s1>()));
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.