;;;; units/unit.lisp (in-package #:wheelwork) (defclass/std unit () ((cached-application :a) (container :with :a) (visiblep :with :std t))) (defmethod (setf closer-mop:slot-value-using-class) :after (newval class (unit unit) slot) (case (closer-mop:slot-definition-name slot) (container (setf (cached-application unit) nil)))) (defun app-of-unit (unit) "Returns the APPLICATION instance, if any, of which this UNIT is a part. NIL indicates that the unit has not been added to any container in this application." (or (cached-application unit) (setf (cached-application unit) (labels ((rec (u) (etypecase u (application u) (unit (rec (unit-container u))) (nil nil)))) (rec unit))))) (defmethod render :around ((unit unit)) (when (unit-visiblep unit) (call-next-method)))