[Incomplete] Testing Solution 1 - Explicit Factory Class#10
Draft
riley-dixon wants to merge 3 commits intodevelopfrom
Draft
[Incomplete] Testing Solution 1 - Explicit Factory Class#10riley-dixon wants to merge 3 commits intodevelopfrom
riley-dixon wants to merge 3 commits intodevelopfrom
Conversation
This is not a complete solution. This was an attempt to use a templated generic factory that would match a call to make an instance to the templated constructor. This mechanism would choose the most suitable constructor if it is overloaded, or fail at compile time if no suitable constructor is found. The most obvious code smell is that in order to get this to compile, a dummy "IFactory<IBatchOperation>" class needs to be inherited from. This is so that we do not need to declare the implementation of BatchOperation in the submit_operations() signature. IFactory is empty and does not actually contain the functions we are interested in. Those instead lie with the GenericFactory which can't be listed in the signature as GenericFactory needs to know the implementation. I am leaving this here in case anyone wants to take a peek at the diff and has an idea if this is worthwhile to pursue.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR is not a complete solution and does not work. However, I have left it as-is in case someone wants to take a look and see the idea I had here. This attempted to use a Generic template Factory that will automatically take a variadic list of arguments and match it to an appropriate constructor at compile time. If no constructor is found, a compiler error is issued. The benefit of this approach is not needing a specially typed Factory for each subclass we want to create a factory for.
Ultimately, I think this approach is incompatible with using a virtual type to allow for both a GenericFactory<Real> and GenericFactory<Mock> to be passed into the same function.
Edit: Fix hidden <> arrows.