diff base/database/charm/classes.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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/base/database/charm/classes.lisp	Thu Sep 30 15:35:15 2010 +0100
@@ -0,0 +1,109 @@
+(cl:in-package #:amuse-charm)
+
+;;;=====================================================================
+;;; Charm-constituents - experimental implementation
+;;;=====================================================================
+
+;; This aims to bolt on Charm compliance to AMuSE constituents, as
+;; they are currently implmented (i.e. compositions
+;; primarily). However, in order to avoid breaking existing code, this
+;; is not the most tidy of solutions.
+
+;;;=====================================================================
+;;; Charm property lists
+;;;=====================================================================
+
+(defclass charm-property-list (amuse-object list-slot-sequence) ())
+
+;; (defclass charm-property (amuse-object) ()
+;;   (:documentation "Base class for charm property objects."))
+
+;; (defclass extrinsic-property (charm-property)  
+;;   ((property :reader property
+;; 	     :initarg :property
+;; 	     :documentation "String specifiying extrinsic property."))
+;;   (:documentation "Base class for charm extrinsic properties."))
+
+;; (defclass intrinsic-property (charm-property)
+;;   ((property :reader property
+;; 	     :initarg :property
+;; 	     :documentation "String describing intrinsic property."))
+;;   (:documentation "Base class for charm intrinsic properties."))
+
+
+;;;=====================================================================
+;;; Charm constituent identifier
+;;;=====================================================================
+
+(defclass charm-constituent-identifier (constituent-identifier)
+  ((constituent-id :reader constituent-id
+		   :initarg :constituent-id))
+  (:documentation "Class to represent Charm constituent identifiers."))
+
+;;;=====================================================================
+;;; Charm constituents
+;;;=====================================================================
+
+(defclass charm-constituent (list-slot-sequence anchored-period)
+  ((identifier :accessor identifier
+	       :initarg :identifier
+	       :initform nil
+	       :documentation "Slot to store database ID, allocated
+	       automatically when inserted into the database.")
+;;    (parent-identifier :reader parent-identifier
+;; 		      :initarg :parent-identifier
+;; 		      :documentation "Slot to store the identifer for
+;; 		      the constituent from which the particles of this
+;; 		      constituent are also members. May either be
+;; 		      another Charm constituent or an AMuSE
+;; 		      composition.")
+   (parent :reader parent
+	   :initarg :parent
+	   :documentation "Slot to store the constituent from which
+	   the particles of this constituent are also members. May
+	   either be another Charm constituent or an AMuSE
+	   composition.")
+   (extrinsic-properties :reader extrinsic-properties
+			 :initarg :extrinsic-properties
+			 :documentation "Slot for the specification of
+			 extrinsic properties.")
+   (intrinsic-properties :reader intrinsic-properties
+			 :initarg :intrinsic-properties
+			 :documentation "Slot for the description of
+			 intrinsic properties.")
+;;    (particles-cache :accessor particles-cache ;; FIXME: why bother?
+;; 		    :initarg :particles-cache
+;; 		    :initform nil
+;; 		    :documentation "Slot to store the objects
+;; 		   identifier by the particles-identifiers.")
+   (owner :accessor owner ;FIXME: these slots should be inherited.
+	  :initarg :owner
+	  :initform nil)
+   (version :accessor version
+	    :initarg :version
+	    :initform nil)
+   (creation-timestamp :accessor creation-timestamp
+		       :initarg :creation-timestamp
+		       :initform nil)
+   (deletion-timestamp :accessor deletion-timestamp
+		       :initarg :deletion-timestamp
+		       :initform nil))
+   (:documentation "Base class for constituents"))
+
+(defclass standard-charm-constituent (charm-constituent
+				      standard-anchored-period) ()
+  (:documentation "Base class for constituents using standard time
+   representation."))
+
+(defclass standard-charm-event-constituent (standard-charm-constituent) ()
+  (:documentation "Base class for constituents using standard time
+   representation."))
+
+(defmethod initialize-instance :after ((constituent
+					standard-charm-constituent) &key)
+  (amuse::%recompute-standard-composition-period constituent))
+
+(defmethod (setf %list-slot-sequence-data) :after (new-value object)
+  "FIXME: :after is right, right? What is :around for again?"
+  (declare (ignore new-value))
+  (amuse::%recompute-standard-composition-period object))