view 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 source
(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)))))