A Note on the RWFactory
The RWDEFINITION_MACROs can appear as the following:
 
RW_DEFINE_COLLECTABLE_CLASS_BY_ID(USER_MODULE, className, numericID)
or, using a string ID:
 
RW_DEFINE_COLLECTABLE_CLASS_BY_NAME(USER_MODULE, className, stringID)
In the .cpp file for the bus example, the macros appear like this:
 
RW_DEFINE_COLLECTABLE_CLASS_BY_ID(USER_MODULE, Bus, 200)
and:
 
RW_DEFINE_COLLECTABLE_CLASS_BY_NAME(USER_MODULE, Client, "a client")
Because you use these macros, a program can allow a new instance of your class to be created given only its RWClassID:
 
Bus* newBus = (Bus*)theFactory->create(200);
or its RWStringID:
 
Client* aClient = (Client*)theFactory->create("a client");
The pointer theFactory is a global pointer that points to a one-of-a-kind global instance of class RWFactory, used to hold information about all RWCollectable classes that have instances in the executable. The create() method of RWFactory is used internally by the polymorphic persistence machinery to create a new instance of a persisted object whose type is not known at run time. You will not normally use this capability in your own source code, because the use of RWFactory is generally transparent to the user. See the SourcePro API Reference Guide for more details on RWFactory.