annotate base/database/charm/methods.lisp @ 318:c4e792b9b898

Add some ideas for charm constituents. Not particularly useful in its own right, but contains some possibly useful ideas related to the generalisation of db-compositions.
author Jamie Forth <j.forth@gold.ac.uk>
date Thu, 30 Sep 2010 15:35:15 +0100
parents
children
rev   line source
j@318 1 (cl:in-package #:amuse-charm)
j@318 2
j@318 3 ;;;=====================================================================
j@318 4 ;;; identifiers
j@318 5 ;;;=====================================================================
j@318 6
j@318 7 (defmethod id ((o constituent-identifier))
j@318 8 (constituent-id o))
j@318 9
j@318 10 (defmethod id ((o constituent))
j@318 11 (constituent-id (identifier o)))
j@318 12
j@318 13 (defmethod id ((o event-identifier))
j@318 14 (event-id o))
j@318 15
j@318 16 (defmethod id ((o event))
j@318 17 (event-id o))
j@318 18
j@318 19 (defmethod id ((o composition-identifier))
j@318 20 (composition-id o))
j@318 21
j@318 22 (defmethod id ((o composition))
j@318 23 (composition-id o))
j@318 24
j@318 25
j@318 26 ;;;=====================================================================
j@318 27 ;;; Specialised constructors
j@318 28 ;;;=====================================================================
j@318 29
j@318 30 (defmethod make-charm-parent-identifier ((implementation
j@318 31 (eql *package*)) id)
j@318 32 "A Charm constituent parent in this context is just another Charm
j@318 33 constituent, i.e. a constituent has been defined which as a subset of
j@318 34 another (parent) constituent."
j@318 35 (make-charm-constituent-identifier id))
j@318 36
j@318 37 (defmethod make-charm-parent-identifier ((implementation
j@318 38 (eql (find-package
j@318 39 "AMUSE-GEERDES"))) id)
j@318 40 "FIXME: This should be in amuse-geerdes"
j@318 41 (amuse-geerdes::g-id-file-id id))
j@318 42
j@318 43 (defmethod make-charm-particle-identifier ((impl-package
j@318 44 (eql *package*)) id)
j@318 45 "A CHARM particle in this context is just another CHARM constituent,
j@318 46 i.e. a constituent has been defined which is the union of other
j@318 47 previously defined constituents."
j@318 48 (make-charm-constituent-identifier id))
j@318 49
j@318 50 (defmethod make-charm-particle-identifier ((impl-package
j@318 51 (eql (find-package
j@318 52 "AMUSE-GEERDES")))
j@318 53 id)
j@318 54 "FIXME: This should be in amuse-geerdes"
j@318 55 (amuse-geerdes::make-geerdes-event-identifier id))
j@318 56
j@318 57 (defmethod get-charm-particles (constituent-identifier ids
j@318 58 (parent amuse-geerdes::composition))
j@318 59 "FIXME: This should be in amuse-geerdes"
j@318 60 (amuse-geerdes::select-events-by-ids parent ids))
j@318 61
j@318 62 (defmethod get-charm-parent ((constituent-identifier
j@318 63 amuse-geerdes::constituent-identifier))
j@318 64 (amuse-geerdes::get-composition constituent-identifier))
j@318 65
j@318 66 ;; (defmethod %cache-charm-particles ((impl-package (eql *package*))
j@318 67 ;; constituent)
j@318 68 ;; "hierarchy of constituents not yet implemented!")
j@318 69
j@318 70 ;; (defmethod %cache-charm-particles ((impl-package (eql (find-package
j@318 71 ;; "AMUSE-GEERDES")))
j@318 72 ;; constituent)
j@318 73 ;; "FIXME: This should be in amuse-geerdes. This relies on identifier
j@318 74 ;; and particles being in the same order! Better to have generic
j@318 75 ;; functions within each implementation that can take a list of event
j@318 76 ;; identifiers and return a list of events from the database? Or maybe
j@318 77 ;; better still to make compositions proper CHARM constituents so that we
j@318 78 ;; can use 'make-sequence-like'?"
j@318 79 ;; (let ((composition (amuse-geerdes::get-composition
j@318 80 ;; (parent-identifier constituent))))
j@318 81 ;; (loop with events = (%list-slot-sequence-data composition)
j@318 82 ;; for identifier in (%list-slot-sequence-data constituent)
j@318 83 ;; for event = (loop for events-head on events
j@318 84 ;; until (eq (event-id (car events-head))
j@318 85 ;; (event-id identifier))
j@318 86 ;; finally (progn (setf events events-head)
j@318 87 ;; (return (car events-head))))
j@318 88 ;; collect event into cached-events
j@318 89 ;; finally (progn (setf (particle-cache constituent)
j@318 90 ;; cached-events)
j@318 91 ;; (return constituent)))))