Skip to content

Commit

Permalink
Dom: inc cov
Browse files Browse the repository at this point in the history
  • Loading branch information
fchn289 committed Mar 1, 2024
1 parent 514bed4 commit 7028c7a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 22 deletions.
34 changes: 13 additions & 21 deletions src/domino/Domino.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,35 +32,27 @@ void Domino::deduceState(const Event aEv)
}

// ***********************************************************************************************
bool Domino::foundNextEv(const Event aFromEv, const Event aNextEv) const
bool Domino::isLinkedFromTo(const Event aFromEv, const Event aToEv) const
{
if (aFromEv == aNextEv)
if (aFromEv == aToEv)
return true;

auto&& ev_nextEVs = next_[true].find(aFromEv);
if (ev_nextEVs != next_[true].end())
{
for (auto&& nextEV : ev_nextEVs->second)
{
if (nextEV == aNextEv)
return true;
else if (foundNextEv(nextEV, aNextEv))
return true;
} // for
} // if

ev_nextEVs = next_[false].find(aFromEv);
if (ev_nextEVs != next_[false].end())
if (isLinkedFromToVia(aFromEv, aToEv, next_[true]))
return true;
return isLinkedFromToVia(aFromEv, aToEv, next_[false]);
}
bool Domino::isLinkedFromToVia(const Event aFromEv, const Event aToEv, const EvLinks& aViaEvLinks) const
{
auto&& ev_nextEVs = aViaEvLinks.find(aFromEv);
if (ev_nextEVs != aViaEvLinks.end())
{
for (auto&& nextEV : ev_nextEVs->second)
{
if (nextEV == aNextEv)
if (nextEV == aToEv)
return true;
else if (foundNextEv(nextEV, aNextEv))
else if (isLinkedFromTo(nextEV, aToEv))
return true;
} // for
} // if

return false;
}

Expand Down Expand Up @@ -144,7 +136,7 @@ Domino::Event Domino::setPrev(const EvName& aEvName, const SimuEvents& aSimuPrev
auto&& event = newEvent(aEvName);
for (auto&& prevEn_state : aSimuPrevEvents)
{
if (foundNextEv(event, newEvent(prevEn_state.first)))
if (isLinkedFromTo(event, newEvent(prevEn_state.first)))
{
WRN("(Domino) !!!Failed to avoid loop between " << aEvName << " & " << prevEn_state.first);
return D_EVENT_FAILED_RET;
Expand Down
3 changes: 2 additions & 1 deletion src/domino/Domino.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ class Domino : public UniLog
void pureSetState(const Event, const bool aNewState);
void pureRmLink(const Event, EvLinks& aMyLinks, EvLinks& aNeighborLinks);

bool foundNextEv(const Event aFromEv, const Event aNextEv) const;
bool isLinkedFromTo (const Event aFromEv, const Event aToEv) const;
bool isLinkedFromToVia(const Event aFromEv, const Event aToEv, const EvLinks& aViaEvLinks) const;

// -------------------------------------------------------------------------------------------
vector<bool> states_; // bitmap & dyn expand, [event]=t/f
Expand Down

0 comments on commit 7028c7a

Please sign in to comment.