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

Document 'Collection' comparison with 'Container' named requirement #598

Merged
merged 43 commits into from
Jun 10, 2024

Conversation

m-fila
Copy link
Contributor

@m-fila m-fila commented May 7, 2024

BEGINRELEASENOTES

  • Added documentation on collection compatibility with container named requirement
  • Added container-like methods cbegin, cend, max_size and aliases size_type, difference_type to collection

ENDRELEASENOTES

Fixes #479, Fixes #546

The goal of this PR is to document current behavior not to fix things. It'll be easier to fix later once we known what is missing. A few methods and aliases were added but they don't collide with anything else

C++ specifies Container as a named requirement, that means specifies required types, functions, semantics and behaviors as well post requirements on its iterators.

The requirements were collected in a form of a markdown file. Next to each requirement it's indicated whether it's fulfilled by the collection/iterators. A short comment indicates any peculiar behaviors or why it isn't fulfilled.
The document is accompanied by a set of tests. The tests are meant to detect changes in collection semantic and interface, and fail indicating need to update the documentation

Beside Container a short paragraph and a few tests are added for checking AllocationAwareContainer (collection uses default allocator implicitly #424), iterator adapters. Another short paragraph is added on interactions with standard algorithms (algorithms require at least LegacyInputIterator which is not fulfilled by collection iterators, the code may compile but it's std-implementation depended #150) and ranges (which use at least std::input_iterator constrain that again isn't fulfilled by collection iterators #273)

  • comparison in text document
  • test Container interface
  • test Container semantics
  • test iterator interface
  • test iterator semantics
  • test iterator concepts
  • simple test for AllocationAwareContainer
  • explain why algorithms and ranges are broken
  • test both iterator and const_iterator
  • tests with subcollections

@hegner hegner self-requested a review May 7, 2024 20:28
include/podio/UserDataCollection.h Outdated Show resolved Hide resolved
@m-fila m-fila marked this pull request as ready for review May 22, 2024 08:35
@m-fila m-fila requested a review from hegner May 23, 2024 09:08
m-fila and others added 25 commits May 25, 2024 20:22
@m-fila m-fila force-pushed the collection_container branch from 9850736 to e25de51 Compare May 25, 2024 18:23
Copy link
Collaborator

@tmadlener tmadlener left a comment

Choose a reason for hiding this comment

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

AFAICT this is ready for review, right? One general comment this has to be included in the doc/index.rst file to show up in the documentation in the end.

@m-fila
Copy link
Contributor Author

m-fila commented Jun 3, 2024

AFAICT this is ready for review, right? One general comment this has to be included in the doc/index.rst file to show up in the documentation in the end.

Yes, please 🙂

I realized that we have a detection idiom implemented in utils. I could rewrite the traits in test with it to reduce the boiler plate a bit if you think it's worth it

@tmadlener
Copy link
Collaborator

No strong opinion on the usage of the detection idiom, I leave it up to you.

Copy link
Collaborator

@tmadlener tmadlener left a comment

Choose a reason for hiding this comment

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

Thanks again for putting this together. I like this quite a lot, and I have mainly smaller comments (see below).

One thing that I am not sure how to handle best yet is the fact, that you stayed entirely within the STL language of using iterator and const_iterator. This makes this document self contained and it is straight forward to compare to the STL and the named requirements. However, there is no mention yet of the Iterator and MutableIterator that we generate. Do you think there is an easy way to at least mention them somewhere. I think that could reduce the potential for confusion if people look e.g. at the doxygen API documentation for EDM4hep.

doc/collections_as_container.md Outdated Show resolved Hide resolved
doc/collections_as_container.md Show resolved Hide resolved
doc/collections_as_container.md Outdated Show resolved Hide resolved
doc/collections_as_container.md Outdated Show resolved Hide resolved
doc/collections_as_container.md Outdated Show resolved Hide resolved
doc/collections_as_container.md Outdated Show resolved Hide resolved
fix typos
fix swap docs
clarify iterator as CollectionIterator
fix destructor behaviour docs
add standard algorithm links and warnings

Co-authored-by: tmadlener <[email protected]>
@m-fila
Copy link
Contributor Author

m-fila commented Jun 4, 2024

Thanks again for putting this together. I like this quite a lot, and I have mainly smaller comments (see below).

One thing that I am not sure how to handle best yet is the fact, that you stayed entirely within the STL language of using iterator and const_iterator. This makes this document self contained and it is straight forward to compare to the STL and the named requirements. However, there is no mention yet of the Iterator and MutableIterator that we generate. Do you think there is an easy way to at least mention them somewhere. I think that could reduce the potential for confusion if people look e.g. at the doxygen API documentation for EDM4hep.

Thank you very much 😊
I added in the collection table that iterator is defined as MutableCollectionIterator and similar for const_iterator. And a short paragraph at the start of iterator part that this convention is used for iterator and const_iterator

As for the detection idiom I think I'll leave it as is

Copy link
Collaborator

@tmadlener tmadlener left a comment

Choose a reason for hiding this comment

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

I am happy with this as it is. In case we really want to go through all > 100 STL algorithms and document them we can do that later as well, but for now this should serve as a very good basis and we have something that we can refer to for capabilities.

@hegner do you want to have another look?

@tmadlener
Copy link
Collaborator

I heard no complaints, so I will merge this.

@tmadlener tmadlener merged commit 9cd68c0 into AIDASoft:master Jun 10, 2024
18 checks passed
@hegner
Copy link
Collaborator

hegner commented Jun 10, 2024

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
3 participants