Différences

Cette page vous donne les différences entre la révision choisie et la version actuelle de la page.

Lien vers cette vue

openmusic:dev-resources:architecture [2011/02/13 18:12]
Jean Bresson [DRAG AND DROP]
openmusic:dev-resources:architecture [2011/02/13 18:23] (Version actuelle)
Ligne 38: Ligne 38:
  
  
-<code lisp+<code> 
-(defclass OMGenericFunction (<b>standard-generic-function OMBasicObject</b>)+(defclass OMGenericFunction (standard-generic-function OMBasicObject)
     ((numouts :initform nil :accessor numouts)     ((numouts :initform nil :accessor numouts)
      (inputs-default :initform nil :accessor inputs-default)      (inputs-default :initform nil :accessor inputs-default)
Ligne 45: Ligne 45:
      (inputs-doc :initform nil :accessor inputs-doc)      (inputs-doc :initform nil :accessor inputs-doc)
      (inputs-menus :initform nil :accessor inputs-menus))      (inputs-menus :initform nil :accessor inputs-menus))
-    (:metaclass <b>OMStandardClass</b>))+    (:metaclass OMStandardClass))
 </code> </code>
  
Ligne 51: Ligne 51:
 All meta-object classes have OMstandardClass as metaclass and not Standard-Class, this feature allows us to see all meta-objects as simple OM instances. All meta-object classes have OMstandardClass as metaclass and not Standard-Class, this feature allows us to see all meta-objects as simple OM instances.
  
-The OMStandardClass inherits from (and have as meta-class) the class OMClass :</P>+The OMStandardClass inherits from (and have as meta-class) the class OMClass :
  
-<code lisp+<code> 
-(defclass OMstandardClass (<b>OMClass</b>) ( ) +(defclass OMstandardClass (OMClass) ( ) 
-    (:metaclass <b>OMClass</b>))+    (:metaclass OMClass))
 </code>  </code>
  
 OMClass class is defined as the other meta-objects, but its meta-class is standard-class so the default CLOS meta-class: OMClass class is defined as the other meta-objects, but its meta-class is standard-class so the default CLOS meta-class:
  
-<code lisp+<code> 
-  (defclass OMClass (<b>standard-class OMPersistantObject</b>)+  (defclass OMClass (standard-class OMPersistantObject)
     ((lib-class-p :initform nil :accessor lib-class-p)     ((lib-class-p :initform nil :accessor lib-class-p)
      (internal-met :initform nil :accessor internal-met)))      (internal-met :initform nil :accessor internal-met)))
Ligne 82: Ligne 82:
 Patches are instances of the OMPatch class, the meta-class of this class is OMStandardClass: Patches are instances of the OMPatch class, the meta-class of this class is OMStandardClass:
  
-<code lisp+<code> 
-(defclass OMPatch (<b>OMBasicObject</b>)+(defclass OMPatch (OMBasicObject)
     ((boxes :initform nil :initarg :boxes :accessor boxes)     ((boxes :initform nil :initarg :boxes :accessor boxes)
        ...)        ...)
-    (:metaclass <b>OMStandardClass</b>))+    (:metaclass OMStandardClass))
 </code> </code>
  
Ligne 95: Ligne 95:
 OMinstance instances allow us to visualisize instances of OMStandardClass classes. We use delegation to point to the real CLOS instance: OMinstance instances allow us to visualisize instances of OMStandardClass classes. We use delegation to point to the real CLOS instance:
  
-<code lisp+<code> 
-(defclass OMInstance (<b>OMBasicObject</b>)+(defclass OMInstance (OMBasicObject)
     ((instance :initform nil :initarg :instancor :accessor instance)     ((instance :initform nil :initarg :instancor :accessor instance)
       ...))       ...))
Ligne 118: Ligne 118:
 The more general class for boxes is **OMBox**, which inherits from OMBasicObject and has OMStandardClass as metaclass: The more general class for boxes is **OMBox**, which inherits from OMBasicObject and has OMStandardClass as metaclass:
  
-<code lisp>  +<code>  
-(defclass OMBox (<b>OMBasicObject</b>)+(defclass OMBox (OMBasicObject)
     ((reference :initform nil :initarg :reference :accessor reference)     ((reference :initform nil :initarg :reference :accessor reference)
       ...)       ...)
-    (:metaclass <b>OMStandardClass</b>))+    (:metaclass OMStandardClass))
 </code> </code>
  
Ligne 278: Ligne 278:
 When the //class-icon-frame// is dropped on the panel the method **om-drag-receive** is invoked with the ClassPanel as principal argument. This method complete fill slots of //*OM-drag&drop-handler*// with information about the drop step and then call the method **finalize-drag&drop** with //*OM-drag&drop-handler*// as argument. This method test if it is posible to drop the slot object of the //class-icon-frame// into the slot object of the //ClassPanel// ; for this there is a genreic function called **drop-allow-p** specified for differentes metaobjects ; in our exemple it is possible if the class **A** is not protected. When the //class-icon-frame// is dropped on the panel the method **om-drag-receive** is invoked with the ClassPanel as principal argument. This method complete fill slots of //*OM-drag&drop-handler*// with information about the drop step and then call the method **finalize-drag&drop** with //*OM-drag&drop-handler*// as argument. This method test if it is posible to drop the slot object of the //class-icon-frame// into the slot object of the //ClassPanel// ; for this there is a genreic function called **drop-allow-p** specified for differentes metaobjects ; in our exemple it is possible if the class **A** is not protected.
  
-<code lisp+ 
-  (defmethod drop-allow-p ((D\&DHandler omdrag-drop) (dragged OMClass) (target OMClass))+<code> 
 +  (defmethod drop-allow-p ((D&DHandler omdrag-drop) (dragged OMClass) (target OMClass))
     (if (protected-p target)     (if (protected-p target)
    (om-beep-msg "This class is protected you can not add slot to it")    (om-beep-msg "This class is protected you can not add slot to it")
Ligne 287: Ligne 288:
 If the operation is allowed the method perform-drop is called with arguments //*OM-drag&drop-handler*// //dragged// and //target//. If the operation is allowed the method perform-drop is called with arguments //*OM-drag&drop-handler*// //dragged// and //target//.
  
-<code lisp+<code> 
-  (defmethod perform-drop ((D&amp;amp;DHandler omdrag-drop) (dragged class-icon-frame) (target ClassPanel) position)+  (defmethod perform-drop ((D&DHandler omdrag-drop) (dragged class-icon-frame) (target ClassPanel) position)
     (make-add-slot target (class-name (object dragged)) position))     (make-add-slot target (class-name (object dragged)) position))
 </code> </code>
Ligne 298: Ligne 299:
  
  
----- +==== PERSISTENCE ==== 
-\\+ 
 + 
 +The **OMPersistantObject** class is the superclass for all meta-objects which are saved on the disk. 
 + 
 +<code> 
 +  (defclass OMPersistantObject (OMBasicObject) 
 +    ((mypathname :initform nil :initarg :mypathname :accessor mypathname) 
 +     (omversion :initform *om-version* :accessor omversion) 
 +      ...)   
 +</code> 
 + 
 + 
 +Principal subclasses of OMPersistantObject are:  
 + 
 +//OMWorkSpace//, //OMFolder//, //OMPackage//, //OMlib//, //OMPatch//, //OMMaquette//, //OMinstance//, //OMMethod//, //OMClass//. 
 + 
 + 
 +The generic function **omng-save** is specialized for all meta-objects, it is responsible to write on disk graphical objects created by the user. 
 + 
 +<code> 
 + (defgeneric omNG-save (self &optional values?)) 
 +</code> 
 + 
 +===Saving WorkSpaces=== 
 + 
 +In order to explain how a workspace is stored on the disk, let's take the example illustrated in the next figure: 
 + 
 +{{ :openmusic:dev-resources:wspict.jpg?350 }} 
 + 
 + 
 +When you launch OM and choose a WorkSpace, a current workspace instance of OMWorkSpace is created and its slot //mypathname// is set to the pathname of the associated folder. 
 + 
 +A workSpace folder contains 3 main folders and a few additional files: 
 + 
 + 
 +  * Folders 
 +      * **Elements**: Store patches, maquettes and subfodlers. 
 +      * **Globals**: Store global variables. 
 +      * **User**: Store classes, methods and subpackages of the user package. 
 +  * Files : //preferences.lisp//, //userpackage.lisp//, //wsparams.lisp//. 
 + 
 + 
 +An optional file called //modifs.lisp// can be added to a workspace. It must contain some lisp code that will be automatically loaded with that workspace. 
 + 
 +The next figure shows a folder associated to a workspace: 
 + 
 +{{:openmusic:dev-resources:wsfolfer.jpg|}} 
 + 
 + 
 +Then saving a workspace consists basically of: 
 +  * Saving patches, maquettes and folers in the elements folder 
 +  * Saving instances in the global folder 
 +  * Saving classes and methods in the user packages. 
 + 
 + 
 +===Saving patches=== 
 + 
 +Patches (and maquettes) have each an associated file , it is determinated by the pathname stored in the slot //mypathname//. This pathname is relative to the WorkSpace containing the patch. 
 + 
 +Calling the method ''omng-save'' with a patch as argument opens its associated file and writes in it a lisp expression that, when it is evaluated, returns a patch equal to the patch argument. Principally, saving a patch is saving its boxes and connections ; the method ''omng-save'' calls the method ''omng-save'' for each box in the patch. 
 + 
 + 
 +Boxes are not //OMPersistantObject// instances, so when you call the ''omng-save'' with a box as argument no file on disk is created instead a lisp expression is built, when this expression is evaluated it returns a new box equal to the box argument. There exist ''omng-save'' methods for each subclass of //OMBox//. 
 + 
 + 
 +===Saving OMInstances=== 
 + 
 +An //OMInstance// instance is an //OMPersistantObject//, but when it is not in the globals folders but into a patch as reference of a //omboxinstance// box, its slot //mypathname// is NIL. In this case the method ''omng-save'' does not create a file associated to the //OMInstance// but builds a lisp expression that will be included in the file of the patch containing the //OMInstanceBox//. If the //OMInstance// instance is in the global folder a file is created in the subfolder "globals". 
 + 
 + 
 +===Saving classes and methods in the user package=== 
 + 
 + 
 +Classes and methods are saved automatically when they are defined. 
 + 
 + 
 +A method //M// is defined when you close its //containerFrame//; the method ''modify-genfun'' is called with the //methodPanel// of //M// as argument. ''modify-genfun'' invokes the function ''set-path-element'' and the latter calls ''omng-save'' with //M// as argument. 
 + 
 + 
 +Each time you change a class, the method ''redef-class'' is called and it calls ''omng-save'' for the class. 
 + 
 +The generic function ''omng-save'' is specialized for some lisp classes too. Values in locked boxes are saved if they are instances of an OM class or their type is in the following list : array, bit-vector, character, complex, cons, float, hash-table,integer, list, null, number, ratio, rational, sequence, string, Otherwise the value is replaced by NIL. 
 + 
  
 


openmusic/dev-resources/architecture.1297617137.txt.gz · Dernière modification: 2011/02/13 18:12 par Jean Bresson