2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
5template <typename T_RawDataContainerCollection, typename T_RawDataContainerPtr, typename T_RangeType>
6inline void moveModuleDataToNewContainer(T_RawDataContainerCollection &rdo_container_collection,
7 ContainerRangeGuard<T_RawDataContainerPtr, T_RangeType> &range_guard) {
8 // estimate the size of the new container.
9 // Currently the capacity of old and new container together simply doubles the
11 // @TODO if startIndex ==0 then no data of this container was "published", so more storage
12 // could just be reserved for this container. Is it useful to handle this even less
13 // likely case than the case that the container list needs to be extended ?
14 std::size_t new_size = range_guard.ptr()->capacity()*2 - range_guard.startIndex();
15 // the new container needs to store at least one element.
16 if (new_size==0u) ++new_size;
17 // create a new guard for the element range in the new container.
18 ContainerRangeGuard<T_RawDataContainerPtr, T_RangeType> new_range_guard(rdo_container_collection.getNewContainerPtr());
19 // reserve enough storeage and move the data which had been added already for the current module.
20 new_range_guard.ptr()->reserve(new_size);
21 range_guard.ptr()->move(*new_range_guard.ptr(), range_guard.startIndex());
22 // update the range guard, with the information about the new container, and the new element range.
23 range_guard=new_range_guard;
26template <typename T_RawDataContainerCollection, typename T_RawDataContainerPtr, typename T_RangeType, typename T_Coordinates >
27inline void addDataForModule(T_RawDataContainerCollection &rdo_container_collection,
28 ContainerRangeGuard<T_RawDataContainerPtr, T_RangeType> &range_guard,
29 T_Coordinates &&coordinates,
30 std::uint32_t data_word) {
31 // if the container has a dynamic container list assume that the capacity of a single container
32 // must not be exceeded, but rather than resizing the container obtain a new container when
34 if constexpr(hasDynamicContainerList<T_RawDataContainerCollection>) {
35 if (range_guard.ptr()->size() == range_guard.ptr()->capacity()) {
36 // if this happens, the only solution is to get a new container, copy all the data that has been added already
37 // for the current module to the new rdo_container, delete this data from the old container, and from now
38 // on add the data to the new container.
39 moveModuleDataToNewContainer(rdo_container_collection,range_guard);
42 // store the data of one hit
43 range_guard.ptr()->emplace_back(std::forward<decltype(coordinates)>(coordinates),