Difference between revisions of "PrF UG meta metaclass intro"

From Protege Wiki
Jump to: navigation, search
 
(2 intermediate revisions by the same user not shown)
Line 2: Line 2:
 
== Understanding Metaclasses ==
 
== Understanding Metaclasses ==
  
{{PrF_UG_TOC_meta}}<div id='prf_ug'>
+
<noinclude>{{PrF_UG_TOC_meta}}<div id='prf_ug'></noinclude>
 
 
<div>[[Image:PrF_UG_meta_advanced.gif|metaclasses_advanced]]</div>
 
  
 
=== [[Image:PrF_UG_meta_advanced.gif|metaclasses_advanced]] Overview ===
 
=== [[Image:PrF_UG_meta_advanced.gif|metaclasses_advanced]] Overview ===
Line 35: Line 33:
 
metaclasses can be concrete or abstract and can have more than one superclass.
 
metaclasses can be concrete or abstract and can have more than one superclass.
  
<div>[[Image:PrF_UG_meta_standard_class_hierarchy.png|
+
<div>[[Image:PrF_UG_meta_standard_class_hierarchy.png|frame|none|
       metaclasses_standard_class_hierarchy]]</div>
+
       Class Browser, showing metaclasses]]</div>
  
 
=== Metaclasses and the Class Editor ===
 
=== Metaclasses and the Class Editor ===
Line 52: Line 50:
 
this translates to a field <b>Best Wineries</b> on the Class Editor for classes created with that template:
 
this translates to a field <b>Best Wineries</b> on the Class Editor for classes created with that template:
  
 +
<div class='b'>
 
{| summary="metaclass facet example"
 
{| summary="metaclass facet example"
 
! Facet in Metaclass
 
! Facet in Metaclass
Line 66: Line 65:
 
[[Image:PrF_UG_meta_best_wineries_field.png|metaclasses_best_wineries_field]]
 
[[Image:PrF_UG_meta_best_wineries_field.png|metaclasses_best_wineries_field]]
 
|}
 
|}
 +
</div>
  
 
By creating your own metaclasses and defining their slots -
 
By creating your own metaclasses and defining their slots -
Line 74: Line 74:
 
using the new metaclass as a template instead of <b>:STANDARD-CLASS</b>.
 
using the new metaclass as a template instead of <b>:STANDARD-CLASS</b>.
  
</div>
+
 
 +
<noinclude></div></noinclude>

Latest revision as of 17:27, November 13, 2008

Understanding Metaclasses


Protege-Frames User's Guide
Metaclasses
Understanding Metaclasses
Example: Creating and Using a Metaclass
Looking at :STANDARD- CLASS
Creating a Metaclass
Creating a Class Using a Metaclass
Changing the Metaclass of a Class
Changing the Metaclass of Subclasses
Setting the Default Metaclass
Customizing the Class or Slot Editor
Understanding Slot Metaclasses
Creating a Slot Metaclass
Changing the Slot Metaclass of a Slot
Creating a Subslot Using a Slot Metaclass
Changing the Slot Metaclass of Subslots
Setting the Default Slot Metaclass
Glossary, Editing Help

metaclasses_advanced Overview

Metaclasses are part of the way Protege-Frames internally handles and constructs classes. A metaclass is a template, that is, a class whose instances are themselves classes. For example, the default metaclass used by Protege-Frames to create new classes is :STANDARD-CLASS; by default, all classes you create are instances of it.

Metaclasses allow you to attach additional information to your class at the class level. This is especially useful if you have several classes, each of which has a similar structure. This also allows you to give your classes more complex properties and to greatly extend the power of your Protege-Frames projects.

Because of the power of metaclasses, you may want to be particularly cautious how much you experiment with a current project. It is a good idea to work on a copy or to archive your project beforehand.

Metaclasses in the Class Hierarchy

Metaclasses are created as part of the :SYSTEM-CLASS hierarchy, which is included in every project. Metaclasses appear under the :CLASS class. Every class that is created subordinate to :CLASS is a metaclass. Just like regular classes, metaclasses can be concrete or abstract and can have more than one superclass.

Class Browser, showing metaclasses

Metaclasses and the Class Editor

When you attach a template slot to a metaclass, it appears as an entry field on the Class Editor for all classes that you create with that metaclass. For example, :STANDARD-CLASS has the slot :NAME; this slot appears as the Name field in that standard Class Editor. In the Wines project, which is used as an example throughout this section, the Wine Template has a slot best_wineries; this translates to a field Best Wineries on the Class Editor for classes created with that template:

Facet in Metaclass Facet in Class Editor for classes created with that metaclass

best_wineries slot

Best Wineries field

metaclasses_best_wineries_slot

metaclasses_best_wineries_field

By creating your own metaclasses and defining their slots - for example, by creating a subclass of :STANDARD-CLASS and then creating new slots or overriding existing ones - you can create additional templates for your classes. You can then create all or some of the classes in your project using the new metaclass as a template instead of :STANDARD-CLASS.