-
Notifications
You must be signed in to change notification settings - Fork 714
Support conversion between vector<Any>
and vector<typename T::value_type>
#873
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
base: master
Are you sure you want to change the base?
Support conversion between vector<Any>
and vector<typename T::value_type>
#873
Conversation
Don't check port type alignment for vector<Any>
3e23456
to
d55f69e
Compare
vector<Any>
and vector<typename T::value_type>
d55f69e
to
fbb6583
Compare
29c90be
to
7d0219e
Compare
Also update checks to allow mismatch when a port was declared as a vector<T> and we have an input port that takes it in as a vector<Any>
7d0219e
to
f8493e5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you document the gcc and clang demangled output for the std::vector<std::string>
for reference here in the PR if it isn't possible to add a unit test establishing the demangled output passes the regex max? Ideally we'd have a unit test for partial specialization as well.
Co-authored-by: Nathan Brooks <[email protected]>
I checked clang and gcc with the type demangler and get the the same output for the demangled typeid of a
|
Oops, when I hit |
looks like a good addition. Can you please:
|
55a9f5a
to
6607968
Compare
How does that look @facontidavide ? |
Tagging @facontidavide , could you give me another review on this? |
Friendly ping @facontidavide , please let me know if there's anything else you'd like me to change here. We want to keep our fork as up to date with your base as possible |
Ok, I am finally looking into this. std::string xml_txt_bad = R"(
<root BTCPP_format="4" >
<BehaviorTree>
<Sequence name="root_sequence">
<OutputVectorStringNode/>
<InputVectorDoubleNode double_vector="{string_vector}"/>
</Sequence>
</BehaviorTree>
</root>)";
ASSERT_NO_THROW(tree = factory.createTreeFromText(xml_txt_bad)); In my opinion this is SUPPOSED to throw. You are basically bypassing the entire type safety mechanism, unless you rely on the fact that string is the usual "wildcard" that has conversion to numbers. |
Another problem I see is that this will not play nicely with this: https://github.com/BehaviorTree/BehaviorTree.CPP/blob/master/examples/t13_access_by_ref.cpp If I try to access any vector by reference, I will find a |
Summary:
I understand your problem and the annoyance of templates, and I would like to find a solution, but I am not sure that this is the one I want to merge. I was thinking about doing the conversion to A potential solution might be to store a to/from On the other hand, what the "right" type of the blackboard is is based on some "fuzzy" criteria, i.e. the order of the XMl parsing... I am not sure how to proceed. Probably creating a better test/use case first and then discussing that. |
If you want, we can arrange a meeting, and iterate faster to find alternatives. You can contact me at [email protected] |
These changes make way for us to do general vector operations like iterate over, index, append, and remove using BT.CPP. Using
vector<Any>
objects on the blackboard allows us to create these operations as singletons, rather than requiring each operation to be templated for eachvector<T>
The 2 primary components to this PR:
vector<T>
objects tovector<Any>
before placing them on the blackboardvector<Any>
tovector<T>
if avector<T>
is expected