Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-13 10:20:53

0001 #ifndef PODIO_DETAIL_LINKFWD_H
0002 #define PODIO_DETAIL_LINKFWD_H
0003 
0004 #include "podio/utilities/TypeHelpers.h"
0005 
0006 #include <algorithm>
0007 #include <deque>
0008 #include <string>
0009 #include <string_view>
0010 #include <vector>
0011 
0012 namespace podio {
0013 namespace detail {
0014 
0015   constexpr std::string_view link_coll_name_prefix = "podio::LinkCollection<";
0016   constexpr std::string_view link_name_prefix = "podio::Link<";
0017   constexpr std::string_view link_name_infix = ",";
0018   constexpr std::string_view link_name_suffix = ">";
0019 
0020   /// Get an SIO friendly type name for a LinkCollection (necessary for
0021   /// registration in the SIOBlockFactory)
0022   ///
0023   /// @tparam FromT the From type of the link
0024   /// @tparam ToT the To type of the link
0025   /// @returns a string that uniquely identifies this combination of From and To
0026   /// types
0027   template <typename FromT, typename ToT>
0028   inline const std::string& linkSIOName() {
0029     static auto n = std::string("LINK_FROM_") + std::string(FromT::typeName) + "_TO_" + std::string(ToT::typeName);
0030     std::replace(n.begin(), n.end(), ':', '_');
0031     return n;
0032   }
0033 } // namespace detail
0034 
0035 // Forward declarations and typedefs used throughout the whole Link business
0036 template <typename FromT, typename ToT>
0037 class LinkObj;
0038 
0039 template <typename FromT, typename ToT>
0040 using LinkObjPointerContainer = std::deque<LinkObj<FromT, ToT>*>;
0041 
0042 /// Simple struct to keep implementation more in line with generated links and
0043 /// to ease evolution of generated links into templated ones
0044 struct LinkData {
0045   float weight{};
0046 };
0047 
0048 using LinkDataContainer = std::vector<LinkData>;
0049 
0050 template <typename FromT, typename ToT, bool Mutable>
0051 class LinkT;
0052 
0053 template <typename FromT, typename ToT>
0054 using Link = LinkT<detail::GetDefaultHandleType<FromT>, detail::GetDefaultHandleType<ToT>, false>;
0055 
0056 template <typename FromT, typename ToT>
0057 using MutableLink = LinkT<detail::GetDefaultHandleType<FromT>, detail::GetDefaultHandleType<ToT>, true>;
0058 
0059 template <typename FromT, typename ToT>
0060 class LinkCollection;
0061 
0062 template <typename FromT, typename ToT>
0063 class LinkCollectionData;
0064 
0065 template <typename FromT, typename ToT, bool Mutable>
0066 class LinkCollectionIteratorT;
0067 
0068 template <typename FromT, typename ToT>
0069 using LinkCollectionIterator = LinkCollectionIteratorT<FromT, ToT, false>;
0070 
0071 template <typename FromT, typename ToT>
0072 using LinkMutableCollectionIterator = LinkCollectionIteratorT<FromT, ToT, true>;
0073 
0074 } // namespace podio
0075 
0076 namespace std {
0077 /// Specialization for enabling structured bindings for Links
0078 template <typename F, typename T, bool M>
0079 struct tuple_size<podio::LinkT<F, T, M>> : std::integral_constant<size_t, 3> {};
0080 
0081 /// Specialization for enabling structured bindings for Links
0082 template <size_t Index, typename F, typename T, bool M>
0083 struct tuple_element<Index, podio::LinkT<F, T, M>> : tuple_element<Index, std::tuple<F, T, float>> {};
0084 } // namespace std
0085 
0086 #endif // PODIO_DETAIL_LINKFWD_H