comparison implementations/geerdes/methods.lisp @ 217:d8f650e3796e

Rationalise base and geerdes classes, constructors and methods. Ignore-this: d9d4d88566a6d110844d91d4c70513cd Towards a more standardised interface. Some of these changes (generalised constructors and reader functions) are necessary for amuse-database-admin functionality and some other CHARM-like things. darcs-hash:20090716154406-16a00-8a9b4fb1fc1f5ba75af66a1bbd87e1bb68e02493.gz committer: Jamie Forth <j.forth@gold.ac.uk>
author j.forth <j.forth@gold.ac.uk>
date Thu, 24 Feb 2011 11:23:18 +0000
parents 619194befdd4
children
comparison
equal deleted inserted replaced
216:e1842efb1dd4 217:d8f650e3796e
1 (cl:in-package #:amuse-geerdes) 1 (cl:in-package #:amuse-geerdes)
2 2
3 ;;; Compositions 3 ;; Identifiers
4
5 ;; identifiers
6 (defun g-id (cat-id)
7 "Make a geerdes-identifier based on a catalogue id"
8 (make-instance 'geerdes-identifier-cat-id :cat-id cat-id))
9 (defun g-id-file-id (file-id)
10 "Make a geerdes-identifier based on a catalogue id"
11 (make-instance 'geerdes-identifier-file-id :file-id file-id))
12 4
13 (defgeneric cat-id (object) 5 (defgeneric cat-id (object)
14 (:documentation "Return a database catalogue id for object (for 6 (:documentation "Return a database catalogue id for object (for
15 Geerdes data, this is the company's own ID")) 7 Geerdes data, this is the company's own ID"))
16 (defgeneric file-id (object) 8 (defgeneric file-id (object)
17 (:documentation "Return a database file id for object (for 9 (:documentation "Return a database file id for object (for
18 Geerdes data, this is a unique integer identifier)")) 10 Geerdes data, this is a unique integer identifier)"))
19 (defgeneric (setf cat-id) (value object)) 11 (defgeneric (setf cat-id) (value object)) ;; FIXME: why?
20 (defgeneric (setf file-id) (value object)) 12 (defgeneric (setf file-id) (value object))
21 13
22 (defmethod cat-id ((object geerdes-composition)) 14 (defmethod cat-id ((object geerdes-composition))
23 (%db-cat-id object)) 15 (%db-cat-id object))
24 (defmethod cat-id ((object geerdes-identifier-cat-id)) 16 (defmethod cat-id ((object geerdes-identifier-cat-id))
34 (defmethod (setf file-id) (value (object geerdes-composition)) 26 (defmethod (setf file-id) (value (object geerdes-composition))
35 (setf (%db-file-id object) value)) 27 (setf (%db-file-id object) value))
36 (defmethod (setf file-id) (value (object geerdes-identifier-file-id)) 28 (defmethod (setf file-id) (value (object geerdes-identifier-file-id))
37 (setf (slot-value object 'file-id) value)) 29 (setf (slot-value object 'file-id) value))
38 30
31 ;; Identifier accessors for CHARM constituents
32
33 (defmethod composition-id ((o geerdes-composition-identifier))
34 "Composition-id is file-id in geerdes."
35 (file-id o))
36
37 (defmethod composition-id ((o geerdes-composition))
38 (file-id o))
39
40 (defmethod event-id ((o geerdes-event))
41 (event-id (identifier o)))
42
39 ;; Specialised constructors 43 ;; Specialised constructors
40 44
41 (defmethod make-composition-identifier ((package (eql *package*)) 45 (defmethod make-composition-identifier ((package (eql *package*))
42 composition-id) 46 composition-id)
43 (g-id-file-id composition-id)) 47 (g-id-file-id composition-id))
44 48
45 ;; Composition 49 ;; Composition
46 50
47 (defmethod get-composition ((identifier geerdes-identifier)) 51 (defmethod get-composition ((identifier
52 geerdes-composition-identifier))
48 (let* ((composition (get-geerdes-composition identifier))) 53 (let* ((composition (get-geerdes-composition identifier)))
49 (%initialise-notes composition) 54 (%initialise-notes composition)
50 (%initialise-constituents composition))) 55 (%initialise-constituents composition)))
51 56
52 (defgeneric get-geerdes-composition (identifier)) 57 (defgeneric get-geerdes-composition (identifier))