TestDataFactory.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-09-16
  6. * Changed: 2022-05-20
  7. *
  8. * */
  9. #include "TestDataFactory.hpp"
  10. ls::std::logic::StateMachine ls_std_logic_test::TestDataFactory::createStateMachine()
  11. {
  12. ls::std::logic::StateMachine stateMachine{"test_machine"};
  13. ::std::shared_ptr<ls::std::logic::State> stateA = ::std::make_shared<ls::std::logic::State>("A");
  14. ::std::shared_ptr<ls::std::logic::State> stateB = ::std::make_shared<ls::std::logic::State>("B");
  15. ::std::shared_ptr<ls::std::logic::State> stateC = ::std::make_shared<ls::std::logic::State>("C");
  16. ::std::shared_ptr<ls::std::logic::State> stateD = ::std::make_shared<ls::std::logic::State>("D");
  17. ::std::shared_ptr<ls::std::logic::State> stateE = ::std::make_shared<ls::std::logic::State>("E");
  18. // add states
  19. stateMachine.addState(stateA);
  20. stateMachine.addState(stateB);
  21. stateMachine.addState(stateC);
  22. stateMachine.addState(stateD);
  23. stateMachine.addState(stateE);
  24. // add connections / see state_machine_test.png
  25. stateA->addStateConnection("AB", stateB);
  26. stateB->addStateConnection("BC", stateC);
  27. stateB->addStateConnection("BD", stateD);
  28. stateC->addStateConnection("CB", stateB);
  29. stateC->addStateConnection("CE", stateE);
  30. stateD->addStateConnection("DE", stateE);
  31. return stateMachine;
  32. }