Skip to content
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 the possibility to store channels of different types #168

Merged
merged 11 commits into from
May 2, 2022

Conversation

S-Dafarra
Copy link
Collaborator

No description provided.

@S-Dafarra
Copy link
Collaborator Author

This depends on the latest version of matio-cpp. I just released it, but the version in conda is probably not updated yet.

@S-Dafarra S-Dafarra changed the title Add the possibility to store channel of different types Add the possibility to store channels of different types Apr 28, 2022
Copy link
Member

@Nicogene Nicogene left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a very nice addition, thanks a lot @S-Dafarra!

Only some small questions, in particular about how this implementation works.

Moreover, could you please add a line in the CHANGELOG? Thanks!

}

private:
size_t m_payload{0};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The payload information wasn't used anywhere?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was used in some examples using directly the Record struct, but never in BufferManager, which is basically the only interface used by downstream projects. In fact, when pushing to a buffer, we were passing directly the vector, and not a Record. Hence, that information was not accessible anyway.

I had to remove it because it was not clear how to define the payload when using std::any.


// Trying to apply the rule of zero

std::any m_datum;/**< the actual data of the record */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you removed all the constructors for let the compiler generate the default ones?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically yes. Being a simple struct with two fields (having removed m_payload), it is enough to use the direct-list-initialization, and a dedicated constructor was not necessary.

}

// matiomatioCppCanConcatenate<T>::value is true when T has the T::value_type member. If this is true, then we check
// if T is either an Element, a Vector (but not a String), or a MultidimensionalArray
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the usage of this struct?

Copy link
Collaborator Author

@S-Dafarra S-Dafarra May 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is used here: https://github.com/robotology/yarp-telemetry/blob/0063940f1452aa0427884a9e3587f0a2b07f23c1/src/libYARP_telemetry/src/yarp/telemetry/experimental/BufferManager.h#L138

It is used to understand how to "concatenate" the data stored for each time instant. In the case of n-dimensional numeric entries like scalars, vectors, and multi-dimensional arrays, it is possible to concatenate in an n+1 dimensional array. On the other hand, with complex inputs like strings or structs, it is possible to concatenate only in a cell array, or in a struct array. That struct uses SFINAE to detect if we can concatenate in an n+1 dimensional array or not.

I tried to not use SFINAE, but the problem was that I needed to check if the matioCppType::type member existed in matioCppType (being matioCppType the matioCpp type corresponding to the input type T), and this was not possible using if constexpr.

std::mutex m_buff_mutex;
dimensions_t m_dimensions;
size_t m_dimensions_factorial{0};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please explain the usage of this m_dimensions_factorial?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It stores the result of the product of all the dimensions in m_dimensions.

}

template<typename T>
void createMatioCppConvertFunction()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add a few lines of documentation about this function?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in a536901. Let me know if it is ok

@S-Dafarra
Copy link
Collaborator Author

Moreover, could you please add a line in the CHANGELOG? Thanks!

Done in a536901

Copy link
Member

@Nicogene Nicogene left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR and the explanations, is much more clear now!

@Nicogene Nicogene merged commit 1f8e751 into robotology:master May 2, 2022
@Nicogene
Copy link
Member

Nicogene commented May 2, 2022

Merged, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants