summaryrefslogtreecommitdiff
path: root/starling/node.scm
diff options
context:
space:
mode:
authorDavid Thompson <dthompson@vistahigherlearning.com>2019-06-20 07:53:13 -0400
committerDavid Thompson <dthompson@vistahigherlearning.com>2019-06-20 07:53:13 -0400
commit8d3d42aeb5bfb4abc471eb26172496e3ac0e1514 (patch)
treed3dad5748828a2ab8abf7041202f3ad85186e049 /starling/node.scm
parent0db11332fe08c154c1954f5d4fe13f75a703feb8 (diff)
node: Add reboot feature.
Diffstat (limited to 'starling/node.scm')
-rw-r--r--starling/node.scm18
1 files changed, 18 insertions, 0 deletions
diff --git a/starling/node.scm b/starling/node.scm
index f8a0e79..07fef48 100644
--- a/starling/node.scm
+++ b/starling/node.scm
@@ -37,6 +37,7 @@
on-boot
on-enter
on-exit
+ reboot
activate
deactivate
show
@@ -143,6 +144,23 @@ represented as a ratio in the range [0, 1]."
(set! (booted? node) #t)
(on-boot node))
+(define-method (reboot (node <node>))
+ (define (do-reboot)
+ (for-each detach (children node))
+ (with-agenda (agenda node) (reset-agenda))
+ (on-boot node))
+ (cond
+ ;; Never booted before, so do nothing.
+ ((not (booted? node))
+ #t)
+ ;; Currently active, so reactivate after reboot.
+ ((active? node)
+ (do-reboot)
+ (activate node))
+ ;; Not active.
+ (else
+ (do-reboot))))
+
(define-method (activate (node <node>))
"Mark NODE and all of its children as active."
;; First time activating? We must boot!