| 29 | } |
| 30 | |
| 31 | NodeStatus FallbackNode::tick() |
| 32 | { |
| 33 | const size_t children_count = children_nodes_.size(); |
| 34 | |
| 35 | if(!isStatusActive(status())) |
| 36 | { |
| 37 | skipped_count_ = 0; |
| 38 | } |
| 39 | |
| 40 | setStatus(NodeStatus::RUNNING); |
| 41 | |
| 42 | while(current_child_idx_ < children_count) |
| 43 | { |
| 44 | TreeNode* current_child_node = children_nodes_[current_child_idx_]; |
| 45 | |
| 46 | auto prev_status = current_child_node->status(); |
| 47 | const NodeStatus child_status = current_child_node->executeTick(); |
| 48 | |
| 49 | switch(child_status) |
| 50 | { |
| 51 | case NodeStatus::RUNNING: { |
| 52 | return child_status; |
| 53 | } |
| 54 | case NodeStatus::SUCCESS: { |
| 55 | resetChildren(); |
| 56 | current_child_idx_ = 0; |
| 57 | return child_status; |
| 58 | } |
| 59 | case NodeStatus::FAILURE: { |
| 60 | current_child_idx_++; |
| 61 | // Return the execution flow if the child is async, |
| 62 | // to make this interruptible. |
| 63 | if(asynch_ && requiresWakeUp() && prev_status == NodeStatus::IDLE && |
| 64 | current_child_idx_ < children_count) |
| 65 | { |
| 66 | emitWakeUpSignal(); |
| 67 | return NodeStatus::RUNNING; |
| 68 | } |
| 69 | } |
| 70 | break; |
| 71 | case NodeStatus::SKIPPED: { |
| 72 | // It was requested to skip this node |
| 73 | current_child_idx_++; |
| 74 | skipped_count_++; |
| 75 | } |
| 76 | break; |
| 77 | case NodeStatus::IDLE: { |
| 78 | throw LogicError("[", name(), "]: A children should not return IDLE"); |
| 79 | } |
| 80 | } // end switch |
| 81 | } // end while loop |
| 82 | |
| 83 | // The entire while loop completed. This means that all the children returned FAILURE. |
| 84 | const bool all_children_skipped = (skipped_count_ == children_count); |
| 85 | if(current_child_idx_ == children_count) |
| 86 | { |
| 87 | resetChildren(); |
| 88 | current_child_idx_ = 0; |
nothing calls this directly
no test coverage detected