diff base/datasets/datasets-file/methods.lisp @ 251:6a3adca16910

Refactor dataset stuff out of amuse-database-admin, and add midifile-dataset.
author Jamie Forth <j.forth@gold.ac.uk>
date Thu, 24 Feb 2011 11:23:18 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/base/datasets/datasets-file/methods.lisp	Thu Feb 24 11:23:18 2011 +0000
@@ -0,0 +1,27 @@
+(cl:in-package #:amuse-datasets)
+
+(defmethod make-dataset ((identifier midifile-dataset-identifier)
+			 composition-identifiers &optional
+			 description)
+  (make-instance 'midifile-dataset
+		 :%data composition-identifiers
+		 :identifier identifier
+		 :description description))
+
+(defmethod get-dataset ((dataset-identifier midifile-dataset-identifier))
+  (let ((midifile-paths
+	 (append (directory (merge-pathnames (dataset-path
+					      dataset-identifier) "*.mid*"))
+		 (directory (merge-pathnames (dataset-path
+					      dataset-identifier) "*.MID*")))))
+    (unless midifile-paths
+      (warn "No midifiles in: ~A" (dataset-path dataset-identifier))
+      (return-from get-dataset nil))
+    (loop for path in midifile-paths
+	 collect (make-composition-identifier
+		  (implementation-package dataset-identifier) path)
+	 into composition-identifiers
+	 finally (return (make-dataset dataset-identifier
+				       composition-identifiers)))))
+
+