![]() | InDesign SDK 20.5 |
#include <ClassFactory.h>
Public Member Functions | |
| ClassFactory (ClassID id, BossConstructor classFact=nil) | |
| ClassID | GetClassID () |
| BossConstructor | GetFactory () |
Static Public Member Functions | |
| static void | InstallClasses (PluginID ownerComponent) |
By default, all bosses are implemented using pre-supplied implementations of IControllingUnknown. You can supply your own implementation for your boss if you supply a class factory that will create the boss on demand from the object model. You should try this only if you know what you're doing – it's not a recommended way to fix problems, and solutions using this method are inherently fragile. You've been warned.
If you must do it, here's how it works. First declare a factory function, based on the name of the boss.
void *CreateMyBoss(ClassID clsID)
{ return new MyControllingUnknown(clsID); }
Then use this macro to declare a dummy usage for your Create function, so the factory won't get stripped out by the linker:
CREATE_CLASSFACTORY(MyBoss, kMyBoss)
If you don't have one already, make a ClassFactoryList.h file, similar to a FactoryList.h file. Add a line to the file that declares your special boss type:
REGISTER_CLASSFACTORY(MyBoss, kMyBoss)
Your Class.fr file should include a resource declaring the boss. This declares to the object model that when it gets a request to create your boss, it should use your factory function. You can do this as follows:
resource FactoryList (129)
{
kClassIDSpace,
{
#include "MyClassFactoryList.h"
}
};