comparison classes.lisp @ 1:cbb5b478307e

Initial import of classes.lisp and default-methods.lisp from David. darcs-hash:20061016144427-aa3d6-93919f5153445ade41eb753434da6f3c838c155a.gz
author m.pearce <m.pearce@gold.ac.uk>
date Mon, 16 Oct 2006 15:44:27 +0100
parents
children 8fbbb0f14f3c
comparison
equal deleted inserted replaced
0:92b28dfc3938 1:cbb5b478307e
1 ;; basic musical object classes
2
3 (defclass composition ()
4 ())
5
6 (defclass event ()
7 ())
8
9 (defclass pitched-event (event)
10 ())
11
12 ;; pitch-related classes
13
14 (defclass pitch ()
15 ())
16
17 (defclass chromatic-pitch (pitch)
18 ())
19
20 (defclass diatonic-pitch (pitch)
21 ())
22
23 (defclass frequency (pitch)
24 ())
25
26 (defclass interval ()
27 ())
28
29 ;; time-related classes
30
31 (defclass moment ()
32 ())
33
34 (defclass duration ()
35 ())
36
37 ;; Some conditions we might want to be able to signal
38
39 (define-condition undefined-action (condition)
40 ;; This condition would apply to an attempt to perform a meaningless
41 ;; operation on an object. This may, initially, include things that
42 ;; are a pain to implement but should really be used when it's
43 ;; genuinely unclear what an operation means in the given
44 ;; context. In such cases, a condition handler might be the best
45 ;; approach anyway.
46 ((operation :initarg :operation
47 :reader undefined-action-operation)
48 (datatype :initarg :datatype
49 :reader undefined-action-datatype))
50 (:report (lambda (condition stream)
51 (format stream "The consequence of performing ~A on and object of type ~A is undefined"
52 (undefined-action-operation condition)
53 (undefined-action-datatype condition)))
54
55 (define-condition insufficient-information (condition)
56 ;; It should be possible to construct genuinely minimal musical
57 ;; structures. When the information in these is insufficient to
58 ;; answer a query, this condition should be raised.
59 ((operation :initarg :operation
60 :reader insufficient-information-operation)
61 (datatype :initarg :datatype
62 :reader insufficient-information-datatype))
63 (:report (lambda (condition stream)
64 (format stream "The ~A object does not contain enough information to perform ~A"
65 (insufficient-information-datatype condition)
66 (insufficient-information-operation condition)))
67
68