Creator Get (const GPL_ClassId id) const
Return the creator function for the class identified by name.
GPL_Object * Create (const GPL_String & name)
Return a new instance of the class identified by name. The caller
is responsible for deallocating the returned pointer.
GPL_Object * Create (const GPL_ClassId id)
Return a new instance of the class identified by id. The caller is
responsible for deallocating the returned pointer.
GPL_Boolean Add (const GPL_String & name, const GPL_ClassId id, Creator creator)
If there is not already a creator for the class identified by name
and id, add the creator, creator, for that class. Return
TRUE if no such creator exists and FALSE otherwise.
GPL_Boolean Remove (const GPL_String & name)
Remove the creator for the class identified by name. Return
TRUE if a creator exists and was removed and FALSE
otherwise.
GPL_Boolean Remove (const GPL_ClassId id)
Remove the creator for the class identified by id. Return
TRUE if a creator exists and was removed and FALSE
otherwise.
static GPL_ObjectFactory * Instance (void)
Return a pointer to the process-global instance of the object factory.
This is a work-around for most compiler's inability to properly call
default constructors for complex, static data members. It is an
instance of the Singleton pattern.
Some linkers are overly aggressive in their optimization and will not
include an object file in the executable if none of the functions in
that file are used directly in the executable. Since the
GPL_OBJECT_IMPLEMENTATION macro causes GPL_ObjectFactory to
indirectly use the methods of a GPL_Object-derived class, these
linkers may discard the entire object file as part of optimization if
there is not another, explicit instance of that class. The most obvious
symptom of this is when GPL_ObjectFactory has no knowledge of a
class derived from GPL_Object and GPL_ObjectFactory::Create()
returns a null pointer. Putting a static, possibly unused, instance of
the class into the translation unit should solve the problem.