in my opinion, PIStateMachine is ready to real work

This commit is contained in:
2024-08-04 20:26:39 +03:00
parent 7d02f710ea
commit 6efc962923
3 changed files with 20 additions and 4 deletions

View File

@@ -97,8 +97,8 @@ void PIStateBase::print(PIString prefix) {
}
bool PIStateBase::start() {
if (isActive()) return true;
bool PIStateBase::start(bool force) {
if (!force && isActive()) return true;
if (isAtomic()) {
setActive(true);
return true;
@@ -197,6 +197,20 @@ void PIStateBase::propagateRoot(PIStateMachine * r) {
}
PIVector<PIStateBase *> PIStateBase::gatherStates() {
PIVector<PIStateBase *> ret, slice, prev_slice({this});
while (prev_slice.isNotEmpty()) {
slice.clear();
for (auto s: prev_slice) {
ret << s;
slice << s->children;
}
prev_slice.swap(slice);
}
return ret;
}
void PIStateBase::gatherActiveStates(PIVector<PIStateBase *> & output) {
for (auto * c: children)
c->gatherActiveStates(output);