-
Notifications
You must be signed in to change notification settings - Fork 38
Open
Description
// The Repeater decorator repeats infinitely or to a limit until the child returns success.
class Repeater : public Decorator
{
public:
Repeater(int limit = 0) : limit(limit) {}
void initialize() override
{
counter = 0;
}
#if 0 // this is old function, seems you forgot the status of child->tick()
Status update() override
{
child->tick();
if (limit > 0 && ++counter == limit) {
return Status::Success;
}
return Status::Running;
}
#else // this is a new one
Status update() override
{
auto status = child->tick();
if (status == Status::Success)
{
if (limit > 0 && ++counter == limit) {
return Status::Success;
}
}
return Status::Running;
}
#endif
protected:
int limit;
int counter = 0;
};
Metadata
Metadata
Assignees
Labels
No labels