SOPE also supports "categories" to enhance a SOPE class with either new
methods or new slots ("ivars" which can be navigated).
Some notes, write much more ...
As an example we use the OGo online help system, which is based on
SOPE. What we want to do is to attach a new "Documentation" tree
to the application which can be navigated using such an URL:
/OpenGroupware/so/Documentation/Scheduler/Overview.html
So we need to enhance the main application object (OpenGroupware
class) with a "Documentation" slot which maps to the help hierarchy.
Take a look at the product.plist section:
categories = {
OpenGroupware = {
slots = {
"Documentation" = {
protectedBy = "";
valueClass = OGoHelpDatabase;
value = "Documentation/OpenGroupware.org";
};
};
};
};
This declares a category on the "OpenGroupware" SoClass and adds
a single slot "Documentation". Slots have a value class
(OGoHelpDatabase) which can be initialized using a property list
object (a plain string in this case).
When the SoProduct is registered and the categories are loaded the
OGoHelpDatabase will be instantiated and gets send the
"-initWithString:" method - the string passed is the value of the
"value" key.
Note: This declares a slot on the SOPE class
object, not on the application object instance! So this is
also potentially executed before any object of that class is instantiated.
Thats it ;-) Now SOPE will trigger the OGoHelpDatabase object attached
to the class when the "Documentation" key is triggered. The object is
responsible for lookup up the subobjects as usual (in the help case this
will happen dynamically based on the available help content).