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() {
|
bool PIStateBase::start(bool force) {
|
||||||
if (isActive()) return true;
|
if (!force && isActive()) return true;
|
||||||
if (isAtomic()) {
|
if (isAtomic()) {
|
||||||
setActive(true);
|
setActive(true);
|
||||||
return 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) {
|
void PIStateBase::gatherActiveStates(PIVector<PIStateBase *> & output) {
|
||||||
for (auto * c: children)
|
for (auto * c: children)
|
||||||
c->gatherActiveStates(output);
|
c->gatherActiveStates(output);
|
||||||
|
|||||||
@@ -74,8 +74,10 @@ public:
|
|||||||
|
|
||||||
void print(PIString prefix = {});
|
void print(PIString prefix = {});
|
||||||
|
|
||||||
|
PIVector<PIStateBase *> gatherStates();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool start();
|
bool start(bool force = false);
|
||||||
void setActive(bool yes);
|
void setActive(bool yes);
|
||||||
void setActiveRecursive(bool yes);
|
void setActiveRecursive(bool yes);
|
||||||
void setChildrenActive(bool yes);
|
void setChildrenActive(bool yes);
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ void PITransitionBase::trigger() {
|
|||||||
else
|
else
|
||||||
source_target_path[i]->activeChild(source_target_path[i + 1]);
|
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