Skip to content

Commit

Permalink
Adapt to event framework API change
Browse files Browse the repository at this point in the history
  • Loading branch information
dziegel committed Feb 1, 2024
1 parent 4d26072 commit a4dc9a6
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions test/ScXmlFsmImpl.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ScXmlFsmImpl::ScXmlFsmImpl()
fsm.Implementation()->UnhandledEvent();
};

fsm_.Init(this, "ScXml", ScXmlTest::kInitialState);
fsm_.Init(this, "ScXml");
}

void ScXmlFsmImpl::Test()
Expand All @@ -27,7 +27,7 @@ void ScXmlFsmImpl::Test()
assert(fsm_.CurrentState() == nullptr);

// Start FSM. Entry actions of initial states must be called.
fsm_.Start();
fsm_.Start(ScXmlTest::kInitialState);
assert(fsm_.CurrentState() == &ScXmlTest::kState_1State_2);
assert(state1_on_entry_called_);
state1_on_entry_called_ = false;
Expand Down
2 changes: 1 addition & 1 deletion test/XmiFsm.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <cpp_event_framework/Signal.hxx>
#include <cpp_event_framework/Statemachine.hxx>

class EventPoolAllocator : public cpp_event_framework::PoolAllocator<EventPoolAllocator>
class EventPoolAllocator : public cpp_event_framework::CustomAllocator<EventPoolAllocator>
{
};

Expand Down
12 changes: 6 additions & 6 deletions test/XmiFsmImpl.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
constexpr size_t kPoolSize = 10;

XmiFsmImpl::XmiFsmImpl()
: pool_(cpp_event_framework::Pool<>::MakeShared(PoolSizeCalculator::kSptrSize, kPoolSize, "EventPool"))
{
auto pool = cpp_event_framework::Pool<>::MakeShared(PoolSizeCalculator::kSptrSize, kPoolSize, "MyPool");
EventPoolAllocator::SetPool(pool);
EventPoolAllocator::SetAllocator(pool_);

fsm_.on_handle_event_ = [](XmiTest::Ref fsm, XmiTest::StateRef state, XmiTest::Event event)
{ std::cout << fsm << " State " << state << " handle event " << event << '\n'; };
Expand All @@ -24,19 +24,19 @@ XmiFsmImpl::XmiFsmImpl()
fsm.Implementation()->UnhandledEvent();
};

fsm_.Init(this, "Xmi", XmiTest::kInitialState);
fsm_.Init(this, "Xmi");
}

void XmiFsmImpl::Test()
{
assert(EventPoolAllocator::pool->FillLevel() == kPoolSize);
assert(pool_->FillLevel() == kPoolSize);

// FSM not started
CheckAllFalse();
assert(fsm_.CurrentState() == nullptr);

// Start FSM. Entry actions of initial states must be called.
fsm_.Start();
fsm_.Start(XmiTest::kInitialState);
assert(fsm_.CurrentState() == &XmiTest::kState_1State_2);
assert(state1_on_entry_called_);
state1_on_entry_called_ = false;
Expand Down Expand Up @@ -145,7 +145,7 @@ void XmiFsmImpl::Test()
choice_action2_called_ = false;
CheckAllFalse();

assert(EventPoolAllocator::pool->FillLevel() == kPoolSize);
assert(pool_->FillLevel() == kPoolSize);
}

void XmiFsmImpl::CheckAllFalse() const
Expand Down
1 change: 1 addition & 0 deletions test/XmiFsmImpl.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public:

private:
XmiTest fsm_;
cpp_event_framework::Pool<>::SPtr pool_;

bool on_unhandled_event_called_ = false;
void UnhandledEvent() override;
Expand Down

0 comments on commit a4dc9a6

Please sign in to comment.