-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add version of GetUnits to take a set of filters #98
Comments
I'm working on api extensions, and resolved the problem in the following way:
|
I assumed this issue meant we wanted a variable number of arguments to be passable to GetUnits (or similar function). So I think I have the start of a solution with overloading GetUnits() using a std::initializer_list. https://github.com/Nickrader/cpp-sc2/blob/iss_98/src/sc2api/sc2_client.cc
https://github.com/Nickrader/cpp-sc2/blob/iss_98/include/sc2api/sc2_interfaces.h
Open on thoughts on where to go from here, or refinements to make, or if I am missing something and this isn't the right path. |
Here is my new and improved attempt. It lacks testing at the moment, beyond the simple test I put in Tutorial.cc also, edited sc2_api.h for convenience, but that can be undone and include statements added in the working file. |
Is your feature request related to a problem? Please describe.
Currently, only 1 type of Filter can be passed to GetUnits to return a filtered list of units. We then have to do additional manually filtering after the initial call.
Describe the solution you'd like
It would be great to use multiple filters in one call.
alkurbatov: "i.e. assuming that we have IsNonSaturatedTownHall, IsTownHall and IsFinished it would be convenient to use e.g. 'AllOf' predicate which uses inside all of these." -- "I suggest to add it ... in the form of a separate call like getUnits, but getUnitsAllOf with array of filters passed by reference. In this case the implementation will be much simpler."
Describe alternatives you've considered
Instead of an array of filters, allow sequential chaining composition. [e.g. .GetUnits( IsNonSaturated( IsFinished( IsTownHall())) ) ] A filter could take a filter input and output a compound filter.
References for different chaining syntaxes:
https://www.fluentcpp.com/2019/08/06/chaining-output-iterators-into-a-pipeline/
http://cpptruths.blogspot.com/2014/03/fun-with-lambdas-c14-style-part-1.html
https://stackoverflow.com/questions/8367879/c-lambda-expression-for-method-chains
https://chriskohlhepp.wordpress.com/advanced-c-lisp/lambda-over-lambda-in-cplusplus14/
The text was updated successfully, but these errors were encountered: