Skip to content

Commit

Permalink
Switch to podio docstring comment style
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadlener committed Jul 17, 2024
1 parent 7ec3fe5 commit 00b36e0
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 78 deletions.
18 changes: 7 additions & 11 deletions include/podio/AssociationCollection.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,19 @@

#if PODIO_ENABLE_SIO && __has_include("podio/detail/AssociationSIOBlock.h")
#include "podio/detail/AssociationSIOBlock.h"
/**
* Main macro for declaring associations. Takes care of the following things:
* - Registering the necessary buffer creation functionality with the
* CollectionBufferFactory.
* - Registering the necessary SIOBlock with the SIOBlock factory
*/
/// Main macro for declaring associations. Takes care of the following things:
/// - Registering the necessary buffer creation functionality with the
/// CollectionBufferFactory.
/// - Registering the necessary SIOBlock with the SIOBlock factory
#define PODIO_DECLARE_ASSOCIATION(FromT, ToT) \
const static auto PODIO_PP_CONCAT(REGISTERED_ASSOCIATION_, __COUNTER__) = \
podio::detail::registerAssociationCollection<FromT, ToT>( \
podio::detail::associationCollTypeName<FromT, ToT>()); \
const static auto PODIO_PP_CONCAT(ASSOCIATION_SIO_BLOCK_, __COUNTER__) = podio::AssociationSIOBlock<FromT, ToT>{};
#else
/**
* Main macro for declaring associations. Takes care of the following things:
* - Registering the necessary buffer creation functionality with the
* CollectionBufferFactory.
*/
/// Main macro for declaring associations. Takes care of the following things:
/// - Registering the necessary buffer creation functionality with the
/// CollectionBufferFactory.
#define PODIO_DECLARE_ASSOCIATION(FromT, ToT) \
const static auto PODIO_PP_CONCAT(REGISTERED_ASSOCIATION_, __COUNTER__) = \
podio::detail::registerAssociationCollection<FromT, ToT>( \
Expand Down
62 changes: 27 additions & 35 deletions include/podio/detail/Association.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@

namespace podio {

/**
* Generalized Association type for both Mutable and immutable (default)
* versions. User facing clases with the expected naming scheme are defined via
* template aliases are defined just below
*/
/// Generalized Association type for both Mutable and immutable (default)
/// versions. User facing clases with the expected naming scheme are defined via
/// template aliases are defined just below
template <typename FromT, typename ToT, bool Mutable>
class AssociationT {
// The typedefs in AssociationFwd.h should make sure that at this point
Expand Down Expand Up @@ -123,16 +121,14 @@ class AssociationT {
m_obj->m_to = new detail::GetDefaultHandleType<ToU>(value);
}

/**
* Templated version for getting an element of the association by type. Only
* available for Associations where FromT and ToT are **not the same type**,
* and if the requested type is actually part of the Association. It is only
* possible to get the immutable types from this. Will result in a compilation
* error if any of these conditions is not met.
*
* @tparam T the desired type
* @returns T the element of the Association
* */
/// Templated version for getting an element of the association by type. Only
/// available for Associations where FromT and ToT are **not the same type**,
/// and if the requested type is actually part of the Association. It is only
/// possible to get the immutable types from this. Will result in a
/// compilation error if any of these conditions is not met.
///
/// @tparam T the desired type
/// @returns T the element of the Association
template <typename T, typename = std::enable_if_t<!std::is_same_v<ToT, FromT> && detail::isFromOrToT<T, FromT, ToT>>>
T get() const {
if constexpr (std::is_same_v<T, FromT>) {
Expand All @@ -142,17 +138,15 @@ class AssociationT {
}
}

/**
* Tuple like index based access to the elements of the Association. Returns
* only immutable types of the associations. This method enables structured
* bindings for Associations.
*
* @tparam Index an index (smaller than 3) to access an element of the Association
* @returns Depending on the value of Index:
* - 0: The From element of the Association
* - 1: The To element of the Association
* - 2: The weight of the Association
*/
/// Tuple like index based access to the elements of the Association. Returns
/// only immutable types of the associations. This method enables structured
/// bindings for Associations.
///
/// @tparam Index an index (smaller than 3) to access an element of the Association
/// @returns Depending on the value of Index:
/// - 0: The From element of the Association
/// - 1: The To element of the Association
/// - 2: The weight of the Association
template <size_t Index, typename = std::enable_if_t<(Index < 3)>>
auto get() const {
if constexpr (Index == 0) {
Expand All @@ -164,15 +158,13 @@ class AssociationT {
}
}

/**
* Templated version for setting an element of the association by type. Only
* available for Associations where FromT and ToT are **not the same type**,
* and if the requested type is actually part of the Association. Will result
* in a compilation error if any of these conditions is not met.
*
* @tparam T type of value (**infered!**)
* @param value the element to set for this association.
*/
/// Templated version for setting an element of the association by type. Only
/// available for Associations where FromT and ToT are **not the same type**,
/// and if the requested type is actually part of the Association. Will result
/// in a compilation error if any of these conditions is not met.
///
/// @tparam T type of value (**infered!**)
/// @param value the element to set for this association.
template <
typename T,
typename = std::enable_if_t<Mutable && !std::is_same_v<ToT, FromT> && detail::isMutableFromOrToT<T, FromT, ToT>>>
Expand Down
54 changes: 22 additions & 32 deletions include/podio/detail/AssociationFwd.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,59 +12,49 @@
namespace podio {
namespace detail {

/**
* Variable template to for determining whether T is either FromT or ToT.
* Mainly defined for convenience
*/
/// Variable template to for determining whether T is either FromT or ToT.
/// Mainly defined for convenience
template <typename T, typename FromT, typename ToT>
static constexpr bool isFromOrToT = detail::isInTuple<T, std::tuple<FromT, ToT>>;

/**
* Variable template to for determining whether T is either FromT or ToT or
* any of their mutable versions.
*/
/// Variable template to for determining whether T is either FromT or ToT or
/// any of their mutable versions.
template <typename T, typename FromT, typename ToT>
static constexpr bool isMutableFromOrToT =
detail::isInTuple<T, std::tuple<FromT, ToT, GetMutableHandleType<FromT>, GetMutableHandleType<ToT>>>;

/**
* Get the collection type name for an AssociationCollection
*
* @tparam FromT the From type of the association
* @tparam ToT the To type of the association
* @returns a type string that is a valid c++ template instantiation
*/
/// Get the collection type name for an AssociationCollection
///
/// @tparam FromT the From type of the association
/// @tparam ToT the To type of the association
/// @returns a type string that is a valid c++ template instantiation
template <typename FromT, typename ToT>
inline const std::string_view associationCollTypeName() {
const static std::string typeName =
std::string("podio::AssociationCollection<") + FromT::typeName + "," + ToT::typeName + ">";
return std::string_view{typeName};
}

/**
* Get the value type name for an AssociationCollection
*
* @tparam FromT the From type of the association
* @tparam ToT the To type of the association
* @returns a type string that is a valid c++ template instantiation
*/
/// Get the value type name for an AssociationCollection
///
/// @tparam FromT the From type of the association
/// @tparam ToT the To type of the association
/// @returns a type string that is a valid c++ template instantiation
template <typename FromT, typename ToT>
inline const std::string_view associationTypeName() {
const static std::string typeName =
std::string("podio::Association<") + FromT::typeName + "," + ToT::typeName + ">";
return std::string_view{typeName};
}

/**
* Get an SIO friendly type name for an AssociationCollection (necessary for
* registration in the SIOBlockFactory)
*
* @tparam FromT the From type of the association
* @tparam ToT the To type of
* the association
* @returns a string that uniquely identifies this combination
* of From and To types
*/
/// Get an SIO friendly type name for an AssociationCollection (necessary for
/// registration in the SIOBlockFactory)
///
/// @tparam FromT the From type of the association
/// @tparam ToT the To type of
/// the association
/// @returns a string that uniquely identifies this combination
/// of From and To types
template <typename FromT, typename ToT>
inline const std::string& associationSIOName() {
static auto n = std::string("ASSOCIATION_FROM_") + FromT::typeName + "_TO_" + ToT::typeName;
Expand Down

0 comments on commit 00b36e0

Please sign in to comment.