Difference between revisions of "PrF UG meta metaclass intro"
Line 6: | Line 6: | ||
<div>[[Image:PrF_UG_meta_advanced.gif|metaclasses_advanced]]</div> | <div>[[Image:PrF_UG_meta_advanced.gif|metaclasses_advanced]]</div> | ||
− | === Overview === | + | === [[Image:PrF_UG_meta_advanced.gif|metaclasses_advanced]] Overview === |
<i>Metaclasses</i> are part of the way {{#var:PrF}} internally handles and constructs classes. | <i>Metaclasses</i> are part of the way {{#var:PrF}} internally handles and constructs classes. |
Revision as of 15:49, October 24, 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.