ObjectFactory needs an RAII way to enable/disable overrides
The API currently is very anemic here. There's a way to turn on and off all overrides of a given class. There's no way to (ergonomically) query and restore the state either. One would need to iterate over the registered object factories, remember the state, flip the desired states, make the object in question, then finally restore the state.
This is:
- finicky
- error-prone
- not at all thread-aware (e.g., new factories could come in, other threads do this machination too, etc.)
There should be a way to scope an object that does this. Something like:
vtkFactoryable* base = nullptr;
{
vtkFactoryModifier modifer("vtkFactoryable");
// modifier.DisableAllOverloads();
modifier.DisableOverload("vtkFactoryWeDontWantHere");
base = vtkFactoryable::New();
// `modifer` goes out of scope and restores the state
}