Skip to content

Commit

Permalink
Use new operator<<
Browse files Browse the repository at this point in the history
  • Loading branch information
dziegel committed Jan 27, 2024
1 parent 0425ab5 commit 4d26072
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 43 deletions.
8 changes: 4 additions & 4 deletions test/ScXmlFsmImpl.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
ScXmlFsmImpl::ScXmlFsmImpl()
{
fsm_.on_handle_event_ = [](ScXmlTest::Ref fsm, ScXmlTest::StateRef state, ScXmlTest::Event event)
{ std::cout << fsm.Name() << " State " << state.Name() << " handle event " << event << '\n'; };
{ std::cout << fsm << " State " << state << " handle event " << event << '\n'; };
fsm_.on_state_entry_ = [](ScXmlTest::Ref fsm, ScXmlTest::StateRef state)
{ std::cout << fsm.Name() << " Enter " << state.Name() << '\n'; };
{ std::cout << fsm << " Enter " << state << '\n'; };
fsm_.on_state_exit_ = [](ScXmlTest::Ref fsm, ScXmlTest::StateRef state)
{ std::cout << fsm.Name() << " Exit " << state.Name() << '\n'; };
{ std::cout << fsm << " Exit " << state << '\n'; };
fsm_.on_unhandled_event_ = [](ScXmlTest::Ref fsm, ScXmlTest::StateRef state, ScXmlTest::Event event)
{
std::cout << fsm.Name() << " Unhandled event " << event << " in state " << state.Name() << '\n';
std::cout << fsm << " Unhandled event " << event << " in state " << state << '\n';
fsm.Implementation()->UnhandledEvent();
};

Expand Down
35 changes: 0 additions & 35 deletions test/XmiFsm.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -40,41 +40,6 @@ using PoolSizeCalculator =
cpp_event_framework::SignalPoolElementSizeCalculator<Transition_1, Transition_2, Transition_3, Transition_4,
Transition_6, Transition_7, Transition_8, Internal>;

inline std::ostream& operator<<(std::ostream& os, const cpp_event_framework::Signal::SPtr& event)
{
switch (event->Id())
{
case Transition_1::kId:
os << "Transition_1";
break;
case Transition_2::kId:
os << "Transition_2";
break;
case Transition_3::kId:
os << "Transition_3";
break;
case Transition_4::kId:
os << "Transition_4";
break;
case Transition_6::kId:
os << "Transition_6";
break;
case Transition_7::kId:
os << "Transition_7";
break;
case Transition_8::kId:
os << "Transition_8";
break;
case Internal::kId:
os << "Internal";
break;
default:
os << "Unknown";
break;
}
return os;
}

class IXmiFsmImpl;
using XmiTestBase = cpp_event_framework::Statemachine<IXmiFsmImpl, const cpp_event_framework::Signal::SPtr&>;

Expand Down
8 changes: 4 additions & 4 deletions test/XmiFsmImpl.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ XmiFsmImpl::XmiFsmImpl()
EventPoolAllocator::SetPool(pool);

fsm_.on_handle_event_ = [](XmiTest::Ref fsm, XmiTest::StateRef state, XmiTest::Event event)
{ std::cout << fsm.Name() << " State " << state.Name() << " handle event " << event << '\n'; };
{ std::cout << fsm << " State " << state << " handle event " << event << '\n'; };
fsm_.on_state_entry_ = [](XmiTest::Ref fsm, XmiTest::StateRef state)
{ std::cout << fsm.Name() << " Enter " << state.Name() << '\n'; };
{ std::cout << fsm << " Enter " << state << '\n'; };
fsm_.on_state_exit_ = [](XmiTest::Ref fsm, XmiTest::StateRef state)
{ std::cout << fsm.Name() << " Exit " << state.Name() << '\n'; };
{ std::cout << fsm << " Exit " << state << '\n'; };
fsm_.on_unhandled_event_ = [](XmiTest::Ref fsm, XmiTest::StateRef state, XmiTest::Event event)
{
std::cout << fsm.Name() << " Unhandled event " << event << " in state " << state.Name() << '\n';
std::cout << fsm << " Unhandled event " << event << " in state " << state << '\n';
fsm.Implementation()->UnhandledEvent();
};

Expand Down

0 comments on commit 4d26072

Please sign in to comment.