Skip to content

Draft: Resolve "Support DynamicFeature arguments to static Actions" - #197

Open
joergbrech wants to merge 2 commits into
grunk-0.3from
71-how-to-cast-dynamic-feature-into-typed-feature
Open

joergbrech wants to merge 2 commits into
grunk-0.3from
71-how-to-cast-dynamic-feature-into-typed-feature

Conversation

@joergbrech

Copy link
Copy Markdown
Collaborator

In GitLab by @joergbrech on Dec 5, 2023, 13:03 UTC:

Closes #71

Migrated from GitLab: https://gitlab.dlr.de/paradigms/grunk/-/merge_requests/58

@joergbrech

Copy link
Copy Markdown
Collaborator Author

In GitLab by @joergbrech on Dec 5, 2023, 16:08 UTC:

added 1 commit

Compare with previous version

@joergbrech

Copy link
Copy Markdown
Collaborator Author

In GitLab by @joergbrech on Dec 5, 2023, 16:20 UTC:

Note to self:

Currently, Action supports functors with overloaded call operators and function templates, because when I call grunk::action("id", some_func, a, b, c) I am passing in concrete argument types. From this information, I can implicitly instantiate the template, if some_func is a template. Also, I can query a concrete return value to initialize the result node of the compute node.

If some of the argument that I pass in are DynamicFeatures, I cannot instantiate a template, resolve an overload and in consequence I cannot determine the return type of the function template or overloaded function.

So I seem to have two choices:

  1. Support DynamicFeature arguments to static Actions, but loose the support for function templates and overloaded functions
  2. Support function templates and overloaded functions, but not DynamicFeature arguments to static Actions.

The best middle ground that I can imagine is: In grunk::action, if constexpr-check if the passed function can be invoked on the passed arguments. If yes, none of the arguments are reflect::DynamicObjects, or they are expected to be, and we can procede as always. If no, we check if the reason for this is that one or more arguments are DynamicFeature instances. Then we have to use reflect::details::function_traits to determine the return type and argument type so that we can cast the DynamicFeature instances to Feature<Arg> at some point. This means that we only loose support for function templates and overloaded functions in this scenario. We still need to think about how to cast the DynamicFeature instances to the expected type, but I suppose we could do something similar to what DynamicAction does with its list of evaluators.

@joergbrech

Copy link
Copy Markdown
Collaborator Author

In GitLab by @joergbrech on Jan 30, 2024, 15:06 UTC:

added 1 commit

Compare with previous version

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support DynamicFeature arguments to static Actions

1 participant