Difference between revisions of "PrF UG meta metaclass intro"
(Automated import of articles) |
|||
(4 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> |
− | + | === [[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. | ||
A metaclass is a template, | A metaclass is a template, | ||
− | that is, | + | that is, a class whose instances are themselves classes. |
− | a class whose instances are themselves classes. | + | For example, the default metaclass used by {{#var:PrF}} |
− | For example, | + | to create new classes is <b>:STANDARD-CLASS</b>; |
− | the default metaclass used by {{#var:PrF}} to create new classes is <b>:STANDARD-CLASS</b>; | + | by default, all classes you create are instances of it. |
− | by default, | ||
− | all classes you create are instances of it. | ||
Metaclasses allow you to attach additional information to your class at the class level. | Metaclasses allow you to attach additional information to your class at the class level. | ||
This is especially useful if you have several classes, | This is especially useful if you have several classes, | ||
each of which has a similar structure. | 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 {{#var:PrF}} projects. | + | This also allows you to give your classes more complex properties |
+ | and to greatly extend the power of your {{#var:PrF}} projects. | ||
Because of the power of metaclasses, | Because of the power of metaclasses, | ||
you may want to be particularly cautious how much you experiment with a current project. | 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 | + | It is a good idea to work on a copy |
− | [[PrF_UG_projects_archive_project|archive]] | + | or to [[PrF_UG_projects_archive_project|archive]] your project beforehand. |
− | your project beforehand. | ||
=== Metaclasses in the Class Hierarchy === | === Metaclasses in the Class Hierarchy === | ||
Line 37: | 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| |
+ | Class Browser, showing metaclasses]]</div> | ||
=== Metaclasses and the Class Editor === | === Metaclasses and the Class Editor === | ||
When you attach a | When you attach a | ||
− | [[PrF_UG_classes_template_slot_pane|template slot]] | + | [[PrF_UG_classes_template_slot_pane|template slot]] to a metaclass, |
− | to a metaclass, | + | it appears as an entry field |
− | it appears as an entry field on the | + | on the [[PrF_UG_classes_class_editor|Class Editor]] |
− | [[PrF_UG_classes_class_editor|Class Editor]] | ||
for all classes that you create with that metaclass. | for all classes that you create with that metaclass. | ||
For example, <b>:STANDARD-CLASS</b> has the slot :<i>NAME</i>; | For example, <b>:STANDARD-CLASS</b> has the slot :<i>NAME</i>; | ||
Line 54: | 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 | ||
! Facet in Class Editor for classes created with that metaclass | ! Facet in Class Editor for classes created with that metaclass | ||
|- | |- | ||
− | | <i>best_wineries</i> slot | + | | |
− | | <b>Best Wineries</b> field | + | <i>best_wineries</i> slot |
+ | | | ||
+ | <b>Best Wineries</b> field | ||
|- | |- | ||
| | | | ||
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 - |
− | by creating a subclass of <b>:STANDARD-CLASS</b> and then creating new slots or overriding existing ones - you can create additional templates for your classes. | + | for example, by creating a subclass of <b>:STANDARD-CLASS</b> |
− | You can then create all or some of the classes in your project using the new metaclass as a template instead of <b>:STANDARD-CLASS</b>. | + | 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 <b>:STANDARD-CLASS</b>. | ||
− | </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.