-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Allow types from different data models in interfaces #714
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
9514497
add detail function for object rank that can be used for comparison
m-fila 1b0b2a4
add extension data model with interface
m-fila fc04c27
hide rank value in a proxy
m-fila c9aa8f0
rename 'Rank' to 'OrderKey'
m-fila a0a0af9
add comments, mention in docs
m-fila 20eb522
compare with `std::less`, remove obsolete typedefs, sprinkle `noexcept`
m-fila 1d00216
Update include/podio/detail/OrderKey.h
m-fila 403f434
fix format
m-fila 8d88074
allow cross-model interfaces in relations
m-fila b3de0d7
test relations IO with cross-edm interface
m-fila 88146f4
test links IO with cross-edm interfaces
m-fila adecb5f
fix missing link to extension datamodel in cmake testing function
m-fila File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#ifndef PODIO_DETAIL_ORDERKEY_H | ||
#define PODIO_DETAIL_ORDERKEY_H | ||
#include <functional> | ||
namespace podio::detail { | ||
/// Internal class allowing datatype objects to be placed in data structures like maps and sets by providing a way to | ||
/// compare them. The comparison is based on addresses of their internal data objects. | ||
/// | ||
/// This class is intended to be used as the return value of internal `podio::detail::getOrderKey` free functions. These | ||
/// functions are friends of each datatype, allowing them to access the internal data objects and define less-than | ||
/// comparison operators for both datatypes and interface types. | ||
/// | ||
/// The friend free function design is used in order to reduce the coupling between interfaces and datatypes. Interfaces | ||
/// do not need to be friends of datatypes to define the less-than comparison operator, which allows using datatypes | ||
/// from different datamodels in an interface type. | ||
class OrderKey { | ||
public: | ||
OrderKey(void* orderKey) noexcept : m_orderKey(orderKey) { | ||
} | ||
friend bool operator<(const OrderKey& lhs, const OrderKey& rhs) noexcept { | ||
return std::less<void*>{}(lhs.m_orderKey, rhs.m_orderKey); | ||
} | ||
|
||
private: | ||
void* m_orderKey; | ||
}; | ||
} // namespace podio::detail | ||
|
||
#endif // PODIO_DETAIL_ORDERKEY_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
--- | ||
schema_version: 1 | ||
options: | ||
getSyntax: False | ||
exposePODMembers: False | ||
includeSubfolder: True | ||
|
||
components: | ||
iextension::PolarVector: | ||
Members: | ||
- float r | ||
- float theta | ||
- float phi | ||
|
||
datatypes: | ||
iextension::AnotherHit: | ||
Author: "Mateusz Jakub Fila" | ||
Description: "A datatype in the extension with components from the extension and an upstream datamodel" | ||
Members: | ||
- unsigned long long cellID // cellID | ||
- SimpleStruct aStruct // component defined in an upstream datamodel | ||
- iextension::PolarVector aVector // component defined in the extension | ||
- double energy [GeV] // measured energy deposit | ||
|
||
iextension::ExampleWithInterfaceRelation: | ||
Description: "Datatype that uses an interface type as one of its relations" | ||
Author: "Mateusz Jakub Fila" | ||
OneToOneRelations: | ||
- iextension::EnergyInterface singleEnergy // single relation | ||
OneToManyRelations: | ||
- iextension::EnergyInterface manyEnergies // multiple relations | ||
|
||
interfaces: | ||
iextension::EnergyInterface: | ||
Description: "Generic interface for types with an energy member" | ||
Author: "Mateusz Jakub Fila" | ||
Types: | ||
- ExampleHit | ||
- ExampleMC | ||
- ExampleCluster | ||
- iextension::AnotherHit | ||
Members: | ||
- double energy // the energy | ||
links: | ||
iextension::TestInterfaceLink: | ||
Description: "A link with an interface type for testing" | ||
Author: "Mateusz Jakub Fila" | ||
From: ExampleHit | ||
To: iextension::EnergyInterface |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is this strictly necessary? Wondering whether the compiler sees through all of this wrt optimizations.
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.
For datatypes this is not necessary, I just thought it could be easier to maintain if the same mechanism was used for both datatypes and interfaces. I'll have to take a look at the cost