Update updates the children of the given [Node] in accordance with the [Plan].
(n Node)
| 228 | |
| 229 | // Update updates the children of the given [Node] in accordance with the [Plan]. |
| 230 | func (p *Plan) Update(n Node) { |
| 231 | if len(p.Children) == 0 && !p.EnforceEmpty { |
| 232 | return |
| 233 | } |
| 234 | pr := profile.Start("plan.Update") |
| 235 | plan.Update(&n.AsTree().Children, len(p.Children), |
| 236 | func(i int) string { |
| 237 | return p.Children[i].Name |
| 238 | }, func(name string, i int) Node { |
| 239 | item := p.Children[i] |
| 240 | child := item.New() |
| 241 | child.AsTree().SetName(item.Name) |
| 242 | return child |
| 243 | }, func(child Node, i int) { |
| 244 | SetParent(child, n) |
| 245 | for _, f := range p.Children[i].Init { |
| 246 | f(child) |
| 247 | } |
| 248 | }, func(child Node) { |
| 249 | child.Destroy() |
| 250 | }, |
| 251 | ) |
| 252 | pr.End() |
| 253 | } |