Difference between revisions of "PrF UG meta metaclass intro"
(One intermediate revision 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> |
=== [[Image:PrF_UG_meta_advanced.gif|metaclasses_advanced]] Overview === | === [[Image:PrF_UG_meta_advanced.gif|metaclasses_advanced]] Overview === | ||
Line 50: | 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 64: | 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 73: | Line 75: | ||
− | </div> | + | <noinclude></div></noinclude> |
Latest revision as of 17:27, November 13, 2008
Understanding Metaclasses
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.
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 |
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.