Skip to content

Commit

Permalink
Bring documentation up-to-date
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadlener committed Jan 30, 2024
1 parent cbed5aa commit 5a17140
Showing 1 changed file with 9 additions and 18 deletions.
27 changes: 9 additions & 18 deletions doc/associations.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Associationg unrelated objects with each other
Sometimes it is necessary to build relations between objects whose datatypes are
Sometimes it is necessary to build associations between objects whose datatypes are
not related via a `OneToOneRelation` or a `OneToManyRelation`. These *external
relations* are called *Associations* in podio, and they are implemented as a
templated version of the code that would be generated by the following yaml
Expand Down Expand Up @@ -188,28 +188,19 @@ template <typename FromT, typename ToT>
using MutableAssociation = AssociationT<FromT, ToT, true>;
```

All podio generated datatypes have the following three public typedefs
- `DefT` yields the default type
- `MutT` yields the mutable type
- `CollT` yields the collection type

There are corresponding template helpers to retrieve these types in
`AssocationFwd.h`. Note that these are not
[*SFINAE*](https://en.cppreference.com/w/cpp/language/sfinae) friendly. However,
since they are only used in contexts internally in non-SFINAE contexts, this
doesn't really matter.

Throught the implementation it is assumed that `FromT` and `ToT` always are the
default types. This is ensured through `static_assert`s, resp. through usage of
the aforementioned template helpers at the possible entry points. With this in
mind, effectively all mutating operations on `Association`s are defined using
SFINAE using the following template structure (taking here `setFrom` as an
example)
default handle types. This is ensured through `static_assert`s in the
`AssociationCollection` to make sure it can only be instantiated with those. The
`GetDefaultHandleType` helper templates are used to retrieve the correct type
from any `FromT` regardless of whether it is a mutable or a default handle type
With this in mind, effectively all mutating operations on `Association`s are
defined using [*SFINAE*](https://en.cppreference.com/w/cpp/language/sfinae)
using the following template structure (taking here `setFrom` as an example)

```cpp
template <typename FromU,
typename = std::enable_if_t<Mutable &&
std::is_same_v<detail::GetDefT<FromU>, FromT>>>
std::is_same_v<detail::GetDefaultHandleType<FromU>, FromT>>>
void setFrom(FromU value);
```

Expand Down

0 comments on commit 5a17140

Please sign in to comment.