summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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!