Skip to content

Commit b7838e6

Browse files
authored
Merge 855ea9c into sapling-pr-archive-ktf
2 parents 7f6490d + 855ea9c commit b7838e6

File tree

4 files changed

+37
-34
lines changed

4 files changed

+37
-34
lines changed

DataFormats/Headers/include/Headers/Stack.h

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@
1414
#include "MemoryResources/MemoryResources.h"
1515
#include "Headers/DataHeader.h"
1616

17-
namespace o2
18-
{
19-
20-
namespace header
17+
namespace o2::header
2118
{
2219
//__________________________________________________________________________________________________
2320
/// @struct Stack
@@ -53,12 +50,12 @@ struct Stack {
5350
Stack(Stack&&) = default;
5451
Stack(Stack&) = delete;
5552
Stack& operator=(Stack&) = delete;
56-
Stack& operator=(Stack&&) = default;
53+
Stack& operator=(Stack&&) = delete;
5754

58-
value_type* data() const { return buffer.get(); }
59-
size_t size() const { return bufferSize; }
55+
[[nodiscard]] value_type* data() const { return buffer.get(); }
56+
[[nodiscard]] size_t size() const { return bufferSize; }
6057
allocator_type get_allocator() const { return allocator; }
61-
const BaseHeader* first() const { return reinterpret_cast<const BaseHeader*>(this->data()); }
58+
[[nodiscard]] const BaseHeader* first() const { return reinterpret_cast<const BaseHeader*>(this->data()); }
6259
static const BaseHeader* firstHeader(std::byte const* buf) { return BaseHeader::get(buf); }
6360
static const BaseHeader* lastHeader(std::byte const* buf)
6461
{
@@ -231,7 +228,7 @@ struct Stack {
231228
}
232229
};
233230

234-
} // namespace header
235-
} // namespace o2
231+
} // namespace o2::header
232+
236233

237234
#endif // HEADERS_STACK_H

Framework/Core/include/Framework/Output.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,7 @@ struct Output {
5959

6060
Output& operator=(const Output&) = delete;
6161

62-
Output& operator=(Output&& rhs)
63-
{
64-
origin = rhs.origin;
65-
description = rhs.description;
66-
subSpec = rhs.subSpec;
67-
metaHeader = std::move(rhs.metaHeader);
68-
return *this;
69-
}
62+
Output& operator=(Output&& rhs) = delete;
7063

7164
bool operator==(const Output& that) const
7265
{

Utilities/DataSampling/include/DataSampling/Dispatcher.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ class Dispatcher : public framework::Task
6565

6666
private:
6767
DataSamplingHeader prepareDataSamplingHeader(const DataSamplingPolicy& policy, header::DataHeader const& original);
68-
header::Stack extractAdditionalHeaders(const char* inputHeaderStack) const;
6968
void reportStats(monitoring::Monitoring& monitoring) const;
7069
void send(framework::DataAllocator& dataAllocator, const framework::DataRef& inputData, const framework::Output& output) const;
7170

Utilities/DataSampling/src/Dispatcher.cxx

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
#include <Configuration/ConfigurationInterface.h>
3131
#include <Configuration/ConfigurationFactory.h>
32+
#include <stdexcept>
3233

3334
using namespace o2::configuration;
3435
using namespace o2::monitoring;
@@ -77,6 +78,33 @@ void Dispatcher::init(InitContext& ctx)
7778
mDeviceID.runtimeInit(spec.id.substr(0, DataSamplingHeader::deviceIDTypeSize).c_str());
7879
}
7980

81+
header::Stack extractAdditionalHeaders(const char* inputHeaderStack)
82+
{
83+
std::array<header::BaseHeader const*, 5> headers;
84+
int count = 0;
85+
const auto* first = header::BaseHeader::get(reinterpret_cast<const std::byte*>(inputHeaderStack));
86+
for (const auto* current = first; current != nullptr; current = current->next()) {
87+
if (current->description != header::DataHeader::sHeaderType && current->description != DataProcessingHeader::sHeaderType) {
88+
headers[count++] = current;
89+
}
90+
}
91+
92+
switch (count) {
93+
case 1:
94+
return header::Stack{*headers[0]};
95+
case 2:
96+
return header::Stack{*headers[0], *headers[1]};
97+
case 3:
98+
return header::Stack{*headers[0], *headers[1], *headers[2]};
99+
case 4:
100+
return header::Stack{*headers[0], *headers[1], *headers[2], *headers[3]};
101+
case 5:
102+
return header::Stack{*headers[0], *headers[1], *headers[2], *headers[3], *headers[4]};
103+
default:
104+
throw std::runtime_error("To many headers to copy");
105+
}
106+
}
107+
80108
void Dispatcher::run(ProcessingContext& ctx)
81109
{
82110
// todo: consider matching (and deciding) in completion policy to save some time
@@ -106,7 +134,7 @@ void Dispatcher::run(ProcessingContext& ctx)
106134
// so that custom data-dependent headers are passed forward,
107135
// and we add a DataSamplingHeader.
108136
header::Stack headerStack{
109-
std::move(extractAdditionalHeaders(part.header)),
137+
extractAdditionalHeaders(part.header),
110138
dsheader};
111139
const auto* partInputHeader = DataRefUtils::getHeader<header::DataHeader*>(part);
112140

@@ -156,20 +184,6 @@ DataSamplingHeader Dispatcher::prepareDataSamplingHeader(const DataSamplingPolic
156184
original};
157185
}
158186

159-
header::Stack Dispatcher::extractAdditionalHeaders(const char* inputHeaderStack) const
160-
{
161-
header::Stack headerStack;
162-
163-
const auto* first = header::BaseHeader::get(reinterpret_cast<const std::byte*>(inputHeaderStack));
164-
for (const auto* current = first; current != nullptr; current = current->next()) {
165-
if (current->description != header::DataHeader::sHeaderType &&
166-
current->description != DataProcessingHeader::sHeaderType) {
167-
headerStack = std::move(header::Stack{std::move(headerStack), *current});
168-
}
169-
}
170-
171-
return headerStack;
172-
}
173187

174188
void Dispatcher::send(DataAllocator& dataAllocator, const DataRef& inputData, const Output& output) const
175189
{

0 commit comments

Comments
 (0)