-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow types from different data models in interfaces (#714)
* add detail function for object rank that can be used for comparison add detecting if `uintptr_t` is defined * add extension data model with interface add test for interface with types from data model and its extension * hide rank value in a proxy * rename 'Rank' to 'OrderKey' * add comments, mention in docs * compare with `std::less`, remove obsolete typedefs, sprinkle `noexcept` * allow cross-model interfaces in relations * test relations IO with cross-edm interface * test links IO with cross-edm interfaces * fix missing link to extension datamodel in cmake testing function
- Loading branch information
Showing
18 changed files
with
255 additions
and
15 deletions.
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.