in my opinion, PIStateMachine is ready to real work
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -74,8 +74,10 @@ public:
|
||||
|
||||
void print(PIString prefix = {});
|
||||
|
||||
PIVector<PIStateBase *> gatherStates();
|
||||
|
||||
protected:
|
||||
bool start();
|
||||
bool start(bool force = false);
|
||||
void setActive(bool yes);
|
||||
void setActiveRecursive(bool yes);
|
||||
void setChildrenActive(bool yes);
|
||||
|
||||
@@ -91,7 +91,7 @@ void PITransitionBase::trigger() {
|
||||
else
|
||||
source_target_path[i]->activeChild(source_target_path[i + 1]);
|
||||
}
|
||||
if (target_state->isCompound()) target_state->start();
|
||||
if (target_state->isCompound()) target_state->start(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user