r5339: *** empty log message ***
[umlisp.git] / class-support.lisp
index 5f8778da086ce822185cdf9f420d9dd2ae33a896..b106046d2b732387a6c248d5b25f0ffac2940756 100644 (file)
@@ -7,7 +7,7 @@
 ;;;; Author:       Kevin M. Rosenberg
 ;;;; Date Started: Apr 2000
 ;;;;
-;;;; $Id: class-support.lisp,v 1.12 2003/06/12 16:37:44 kevin Exp $
+;;;; $Id: class-support.lisp,v 1.17 2003/07/19 20:32:48 kevin Exp $
 ;;;;
 ;;;; This file, part of UMLisp, is
 ;;;;    Copyright (c) 2000-2003 by Kevin M. Rosenberg, M.D.
 (defmethod fmt-eui ((e null))
   (format nil "nil"))
 
+(defun cui-p (ui)
+  "Check if a string is a CUI"
+  (check-ui ui #\C 7))
+
+(defun lui-p (ui)
+  "Check if a string is a LUI"
+  (check-ui ui #\L 7))
+
+(defun sui-p (ui)
+  "Check if a string is a SUI"
+  (check-ui ui #\S 7))
+
+(defun tui-p (ui)
+  (check-ui ui #\T 3))
+
+(defun eui-p (ui)
+  (check-ui ui #\E 7))
+
+(defun check-ui (ui start-char len)
+  (when (and (stringp ui)
+            (= (length ui) (1+ len))
+            (char-equal start-char (schar ui 0))
+            (ignore-errors (parse-integer ui :start 1)))
+    t))
+
+
 ;;; Generic display functions
 
 (eval-when (:compile-toplevel :load-toplevel :execute)
       (or (not is-term) is-english)))
 
 (defun print-umlsclass (obj &key (stream *standard-output*)
-                       (category :compact-text)
-                       (file-wrapper t) (english-only t) (subobjects nil)
+                       (vid :compact-text)
+                       (file-wrapper nil) (english-only t) (subobjects nil)
                        (refvars nil) (link-printer nil))
-  (view obj :stream stream :category category :subobjects subobjects
+  (view obj :stream stream :vid vid :subobjects subobjects
        :file-wrapper file-wrapper
        :filter (if english-only nil #'english-term-filter)
        :link-printer link-printer
 
 (defmacro define-lookup-display (newfuncname lookup-func)
   "Defines functions for looking up and displaying objects"
-  `(defun ,newfuncname  (keyval &key (stream *standard-output*) (category :compact-text)
+  `(defun ,newfuncname  (keyval &key (stream *standard-output*) (vid :compact-text)
                         (file-wrapper t) (english-only nil) (subobjects nil))
      (let ((obj (funcall ,lookup-func keyval)))
-       (print-umlsclass obj :stream stream :category category
+       (print-umlsclass obj :stream stream :vid vid
                        :file-wrapper file-wrapper :english-only english-only
                        :subobjects subobjects)
        obj)))
   "Return the string for a ulo object"
   (find-string-sui (sui lo)))
 
-(defun uterm-pfstr (uterm)
+(defmethod pfstr ((uterm uterm))
   "Return the preferred string for a uterm"
   (dolist (ustr (s#str uterm))
     (when (string= "PF" (stt ustr))
-      (return-from uterm-pfstr (str ustr)))))
+      (return-from pfstr (str ustr)))))
 
 (defun remove-non-english-terms (uterms)
   (remove-if-not #'english-term-p uterms))
 
+(defun remove-english-terms (uterms)
+  (remove-if #'english-term-p uterms))
+
 
 #+(or scl cmu)
 (dolist (c '(urank udef usat uso ucxt ustr ulo uterm usty urel ucoc uatx ucon uxw uxnw uxns lexterm labr lagr lcmp lmod lnom lprn lprp lspl ltrm ltyp lwd sdef sstr sstre1 sstre2 usrl))