Hi Frank,

Thanks for your example. My apologies for requiring you to repeat your answer 
from last month. I found your post not long after I posted.

>From your example, and other examples that use the FAMILY class, the KIDS are 
>instantiated at the same time as the FAMILY instance. In my case, the KIDS are 
>instantiated at different times and then "connected" in the future. I have an 
>attempt at the end of the email which is based off your example. It does not 
>work, and I am not sure why.

I noticed in your examples that you use macros. Is there something significant 
about that?

Thanks
Mark

(defpackage "MODEL"
  (:use "COMMON-LISP"
        "CELLS"))
(in-package "MODEL")

;; model

(defmodel my-model (model)
  ((item-index
    :initarg :item-index
    :accessor item-index))
  (:default-initargs
   :item-index (c-in 0)))

(defun make-model (id)
  (make-instance 'my-model :md-name id))

;; view

(defmodel my-view (model)
  ((item-index
    :initarg :item-index
    :accessor item-index))
  (:default-initargs
   :item-index (c-in 0)))

(defun make-view (id)
  (make-instance 'my-view :md-name id))

(defobserver item-index ((object my-view) new-value)
  (format t "~&VIEW item-index ~A~%" new-value))

;; controller

(defmodel my-controller (family)
  ((model
    :initarg :model
    :accessor model)
   (view
    :initarg :view
    :accessor view)))

(defun make-controller (model view)
  (setf (fm-parent model) :root
        (fm-parent view) :root)
  (let ((rv (make-instance 'my-controller
                           :model (c-in model)
                           :view (c-in view)
                           :kids (c? (the-kids model view))
                           :md-name :root)))

    (setf (item-index view) (c? (let ((m (model (fm^ :root))))
                                  (item-index m))))
    rv))

;; test

(defun test ()
  (let* ((model (make-model :model))
         (view  (make-view :view))
         (controller (make-controller model view)))    
    (setf (item-index model) 2)
    (item-index view)))


_______________________________________________
cells-devel site list
cells-devel@common-lisp.net
http://common-lisp.net/mailman/listinfo/cells-devel

Reply via email to