Support specifying object factory overrides in executables
vtkObjectFactory class should gain support for preferring certain overrides as given by the executable that is running. For example, one can create two versions of an application, one which is for desktop use and another that is for VR device use. Currently,
vtkRenderingOpenVR disables all other overrides of the classes that it overrides, effectively disabling support of the other overrides while it is loaded.
The proposed solution is to support "override attributes" on override classes. Executables could then register their preferences with
vtkObjectFactory and when a factory base class is requested, it would consult the preferences and the available attributes and construct the "best" option.
vtkObjectFactory::RegisterOverridewould take an additional argument of a linked list of attributes for the override.
- Overriding classes would indicate that they have overrides via the
<classname>_OVERRIDE_ATTRIBUTESpreprocessor definition. It would resolve to the pointer to the head of a linked list describing the attributes for the class (this would allow for intermediate base classes to provide attributes that may be referenced by subclasses).
#ifdefto specify this attribute to the
vtkObjectFactory.cmakewould provide a function to create a source file which indicates preferences to
vtkObjectFactoryas a static initialization function for use in executables.
One question is where the logic of choosing an override lives.
Embedded proposal We describe an algorithm in
vtkObjectFactorywhich performs the selection based on its input data. One could be "strength of preference is from first attribute specified to last and within each attribute, first to last". So the selection between class
AttrA=Y,AttrB=Mwith the preferences
AttrA=X,Y;AttrB=M,Nwould be class
AttrAis a "stronger" preference.
Callback proposal It can either live in a function that is passed to
vtkObjectFactorywhich it then calls for override requests (where attributes are available) with the list of constructor functions paired with the attributes describing each. Here, the
vtkObjectFactory.cmakemodule should have the option to provide a default implementation of this callback, likely similar to whatever the Embedded proposal is.