-
Notifications
You must be signed in to change notification settings - Fork 494
Expand file tree
/
Copy pathInputRecord.h
More file actions
658 lines (597 loc) · 25.9 KB
/
InputRecord.h
File metadata and controls
658 lines (597 loc) · 25.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
// Copyright CERN and copyright holders of ALICE O2. This software is
// distributed under the terms of the GNU General Public License v3 (GPL
// Version 3), copied verbatim in the file "COPYING".
//
// See http://alice-o2.web.cern.ch/license for full licensing information.
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
#ifndef FRAMEWORK_INPUTRECORD_H
#define FRAMEWORK_INPUTRECORD_H
#include "Framework/DataRef.h"
#include "Framework/DataRefUtils.h"
#include "Framework/InputRoute.h"
#include "Framework/TypeTraits.h"
#include "Framework/InputSpan.h"
#include "Framework/TableConsumer.h"
#include "Framework/Traits.h"
#include "Framework/RuntimeError.h"
#include "Headers/DataHeader.h"
#include "CommonUtils/BoostSerializer.h"
#include <gsl/gsl>
#include <iterator>
#include <string>
#include <vector>
#include <cstring>
#include <cassert>
#include <memory>
#include <type_traits>
class FairMQMessage;
namespace o2
{
namespace framework
{
struct InputSpec;
/// @class InputRecord
/// @brief The input API of the Data Processing Layer
/// This class holds the inputs which are valid for processing. The user can get an
/// instance for it via the ProcessingContext and can use it to retrieve the inputs,
/// either by name or by index. A few utility methods are provided to automatically
/// cast the (deserialized) inputs to known types.
///
/// \par The @ref get<T>(binding) method is implemeted for the following types:
/// - (a) @ref DataRef holding header and payload information, this is also the default
/// get method without template parameter
/// - (b) std::string
/// - (c) const char*
/// this is meant for C-style strings which are 0 terminated, there is no length
/// information
/// - (d) @ref TableConsumer
/// - (e) boost serializable types
/// - (f) span over messageable type T
/// - (g) std::vector of messageable type or type with ROOT dictionary
/// - (h) messageable type T
/// - (i) pointer type T* for types with ROOT dictionary or messageable types
///
/// \par The return type of get<T>(binding) is:
/// - (a) @ref DataRef object
/// - (b) std::string copy of the payload
/// - (c) const char* to payload content
/// - (d) unique_ptr of TableConsumer
/// - (e) object by move
/// - (f) span object over original payload
/// - (g) vector by move
/// - (h) reference to object
/// - (i) object with pointer-like behavior (unique_ptr)
///
/// \par Examples
/// <pre>
/// auto& v1 = get<int>("input1");
/// auto v2 = get<vector<int>>("input2");
/// auto v3 = get<TList*>("input3");
/// auto v4 = get<vector<TParticle>>("input4");
/// </pre>
///
/// \par Validity of inputs
/// Not all input slots are always valid if a custom completion policy is chosen. Validity
/// can be checked using method @ref isValid.
///
/// Iterator functionality is implemented to iterate over the list of DataRef objects,
/// including begin() and end() methods.
/// <pre>
/// for (auto const& ref : inputs) {
/// // do something with DataRef object ref
/// }
/// </pre>
class InputRecord
{
public:
using DataHeader = o2::header::DataHeader;
InputRecord(std::vector<InputRoute> const& inputs,
InputSpan&& span);
/// A deleter type to be used with unique_ptr, which can be marked that
/// it does not own the underlying resource and thus should not delete it.
/// The resource ownership property controls the behavior and can only be
/// set at construction of the deleter in the unique_ptr. Falls back to
/// default_delete if not initialized to 'NotOwning'.
/// Usage: unique_ptr<T, Deleter<T>> ptr(..., Deleter<T>(false))
///
/// By contract, the underlying, not owned resource is supposed to be
/// available during the lifetime of the object, which is the case in the
/// InputRecord and DPL processing APIs. The Deleter can be extended
/// to support a callback to call a resource management outside.
template <typename T>
class Deleter : public std::default_delete<T>
{
public:
enum struct OwnershipProperty : short {
Unknown = -1,
NotOwning = 0, /// don't delete the underlying buffer
Owning = 1 /// normal behavior, falling back to default deleter
};
using base = std::default_delete<T>;
using self_type = Deleter<T>;
// using pointer = typename base::pointer;
constexpr Deleter() = default;
constexpr Deleter(bool isOwning)
: base::default_delete(), mProperty(isOwning ? OwnershipProperty::Owning : OwnershipProperty::NotOwning)
{
}
// copy constructor is needed in the setup of unique_ptr
// check that assignments happen only to uninitialized instances
constexpr Deleter(const self_type& other) : base::default_delete(other), mProperty{OwnershipProperty::Unknown}
{
if (mProperty == OwnershipProperty::Unknown) {
mProperty = other.mProperty;
} else if (mProperty != other.mProperty) {
throw runtime_error("Attemp to change resource control");
}
}
// copy constructor for the default delete which simply sets the
// resource ownership control to 'Owning'
constexpr Deleter(const base& other) : base::default_delete(other), mProperty{OwnershipProperty::Owning} {}
// allow assignment operator only for pristine or matching resource control property
self_type& operator=(const self_type& other)
{
// the default_deleter does not have any state, so this could be skipped, but keep the call to
// the base for completeness, and the (small) chance for changing the base
base::operator=(other);
if (mProperty == OwnershipProperty::Unknown) {
mProperty = other.mProperty;
} else if (mProperty != other.mProperty) {
throw runtime_error("Attemp to change resource control");
}
return *this;
}
void operator()(T* ptr) const
{
if (mProperty == OwnershipProperty::NotOwning) {
// nothing done if resource is not owned
return;
}
base::operator()(ptr);
}
private:
OwnershipProperty mProperty = OwnershipProperty::Unknown;
};
int getPos(const char* name) const;
int getPos(const std::string& name) const;
DataRef getByPos(int pos, int part = 0) const
{
if (pos >= mSpan.size() || pos < 0) {
throw runtime_error_f("Unknown message requested at position %d", pos);
}
if (part > 0 && part >= getNofParts(pos)) {
throw runtime_error_f("Invalid message part index at %d:%d", pos, part);
}
if (pos >= mInputsSchema.size()) {
throw runtime_error_f("Unknown schema at position %d", pos);
}
auto ref = mSpan.get(pos, part);
ref.spec = &mInputsSchema[pos].matcher;
return ref;
}
size_t getNofParts(int pos) const
{
if (pos < 0 || pos >= mSpan.size()) {
return 0;
}
return mSpan.getNofParts(pos);
}
/// Get the object of specified type T for the binding R.
/// If R is a string like object, we look up by name the InputSpec and
/// return the data associated to the given label.
/// If R is a DataRef, we extract the result object from the Payload,
/// following the information provided by the Header.
/// The actual operation and cast depends on the target data type and the
/// serialization type of the incoming data.
/// By default we return a DataRef, which is the pair of pointers to
/// the header and payload of the O2 Message.
/// See @ref Inputrecord class description for supported types.
/// @param ref DataRef with pointers to input spec, header, and payload
template <typename T = DataRef, typename R>
decltype(auto) get(R binding, int part = 0) const
{
DataRef ref{nullptr, nullptr};
// Get the actual dataref
if constexpr (std::is_same_v<std::decay_t<R>, char const*> ||
std::is_same_v<std::decay_t<R>, char*> ||
std::is_same_v<std::decay_t<R>, std::string>) {
try {
int pos = -1;
if constexpr (std::is_same_v<std::decay_t<R>, std::string>) {
pos = getPos(binding.c_str());
} else {
pos = getPos(binding);
}
if (pos < 0) {
throw std::invalid_argument("no matching route found for " + std::string(binding));
}
ref = this->getByPos(pos, part);
} catch (const std::exception& e) {
if constexpr (std::is_same_v<std::decay_t<R>, std::string>) {
throw runtime_error_f("Unknown argument requested %s - %s", binding.c_str(), e.what());
} else {
throw runtime_error_f("Unknown argument requested %s - %s", binding, e.what());
}
}
} else if constexpr (std::is_same_v<std::decay_t<R>, DataRef>) {
ref = binding;
} else {
static_assert(always_static_assert_v<R>, "Unknown binding type");
}
if constexpr (std::is_same_v<std::decay_t<T>, DataRef>) {
return ref;
} else if constexpr (std::is_same<T, std::string>::value) {
// substitution for std::string
// If we ask for a string, we need to duplicate it because we do not want
// the buffer to be deleted when it goes out of scope. The string is built
// from the data and its lengh, null-termination is not necessary.
// return std::string object
auto header = header::get<const header::DataHeader*>(ref.header);
assert(header);
return std::string(ref.payload, header->payloadSize);
// implementation (c)
} else if constexpr (std::is_same<T, char const*>::value) {
// substitution for const char*
// If we ask for a char const *, we simply point to the payload. Notice this
// is meant for C-style strings which are expected to be null terminated.
// If you want to actually get hold of the buffer, use gsl::span<char> as that will
// give you the size as well.
// return pointer to payload content
return reinterpret_cast<char const*>(ref.payload);
// implementation (d)
} else if constexpr (std::is_same<T, TableConsumer>::value) {
// substitution for TableConsumer
// For the moment this is dummy, as it requires proper support to
// create the RDataSource from the arrow buffer.
auto header = header::get<const header::DataHeader*>(ref.header);
assert(header);
auto data = reinterpret_cast<uint8_t const*>(ref.payload);
return std::make_unique<TableConsumer>(data, header->payloadSize);
// implementation (e)
} else if constexpr (framework::is_boost_serializable<T>::value || is_specialization<T, BoostSerialized>::value) {
// substitution for boost-serialized entities
// We have to deserialize the ostringstream.
// FIXME: check that the string is null terminated.
// @return deserialized copy of payload
auto header = header::get<const header::DataHeader*>(ref.header);
assert(header);
auto str = std::string(ref.payload, header->payloadSize);
assert(header->payloadSize == sizeof(T));
if constexpr (is_specialization<T, BoostSerialized>::value) {
return o2::utils::BoostDeserialize<typename T::wrapped_type>(str);
} else {
return o2::utils::BoostDeserialize<T>(str);
}
// implementation (f)
} else if constexpr (is_span<T>::value) {
// substitution for span of messageable objects
// FIXME: there will be std::span in C++20
static_assert(is_messageable<typename T::value_type>::value, "span can only be created for messageable types");
auto header = header::get<const header::DataHeader*>(ref.header);
assert(header);
if (sizeof(typename T::value_type) > 1 && header->payloadSerializationMethod != o2::header::gSerializationMethodNone) {
throw runtime_error("Inconsistent serialization method for extracting span");
}
using ValueT = typename T::value_type;
if (header->payloadSize % sizeof(ValueT)) {
throw runtime_error(("Inconsistent type and payload size at " + std::string(ref.spec->binding) + "(" + DataSpecUtils::describe(*ref.spec) + ")" +
": type size " + std::to_string(sizeof(ValueT)) +
" payload size " + std::to_string(header->payloadSize))
.c_str());
}
return gsl::span<ValueT const>(reinterpret_cast<ValueT const*>(ref.payload), header->payloadSize / sizeof(ValueT));
// implementation (g)
} else if constexpr (is_container<T>::value) {
// currently implemented only for vectors
if constexpr (is_specialization<typename std::remove_const<T>::type, std::vector>::value) {
auto header = o2::header::get<const DataHeader*>(ref.header);
auto method = header->payloadSerializationMethod;
if (method == o2::header::gSerializationMethodNone) {
// TODO: construct a vector spectator
// this is a quick solution now which makes a copy of the plain vector data
auto* start = reinterpret_cast<typename T::value_type const*>(ref.payload);
auto* end = start + header->payloadSize / sizeof(typename T::value_type);
T result(start, end);
return result;
} else if (method == o2::header::gSerializationMethodROOT) {
/// substitution for container of non-messageable objects with ROOT dictionary
/// Notice that this will return a copy of the actual contents of the buffer, because
/// the buffer is actually serialised. The extracted container is swaped to local,
/// container, C++11 and beyond will implicitly apply return value optimization.
/// @return std container object
using NonConstT = typename std::remove_const<T>::type;
if constexpr (is_specialization<T, ROOTSerialized>::value == true || has_root_dictionary<T>::value == true) {
// we expect the unique_ptr to hold an object, exception should have been thrown
// otherwise
auto object = DataRefUtils::as<NonConstT>(ref);
// need to swap the content of the deserialized container to a local variable to force return
// value optimization
T container;
std::swap(const_cast<NonConstT&>(container), *object);
return container;
} else {
throw runtime_error("No supported conversion function for ROOT serialized message");
}
} else {
throw runtime_error("Attempt to extract object from message with unsupported serialization type");
}
} else {
static_assert(always_static_assert_v<T>, "unsupported code path");
}
// implementation (h)
} else if constexpr (is_messageable<T>::value) {
// extract a messageable type by reference
// Cast content of payload bound by @a binding to known type.
// we need to check the serialization type, the cast makes only sense for
// unserialized objects
using DataHeader = o2::header::DataHeader;
auto header = o2::header::get<const DataHeader*>(ref.header);
auto method = header->payloadSerializationMethod;
if (method != o2::header::gSerializationMethodNone) {
// FIXME: we could in principle support serialized content here as well if we
// store all extracted objects internally and provide cleanup
throw runtime_error("Can not extract a plain object from serialized message");
}
return *reinterpret_cast<T const*>(ref.payload);
// implementation (i)
} else if constexpr (std::is_pointer<T>::value &&
(is_messageable<typename std::remove_pointer<T>::type>::value || has_root_dictionary<typename std::remove_pointer<T>::type>::value)) {
// extract a messageable type or object with ROOT dictionary by pointer
// return unique_ptr to message content with custom deleter
using DataHeader = o2::header::DataHeader;
using ValueT = typename std::remove_pointer<T>::type;
auto header = o2::header::get<const DataHeader*>(ref.header);
auto method = header->payloadSerializationMethod;
if (method == o2::header::gSerializationMethodNone) {
if constexpr (is_messageable<ValueT>::value) {
auto const* ptr = reinterpret_cast<ValueT const*>(ref.payload);
// return type with non-owning Deleter instance
std::unique_ptr<ValueT const, Deleter<ValueT const>> result(ptr, Deleter<ValueT const>(false));
return result;
} else if constexpr (is_specialization<ValueT, std::vector>::value && has_messageable_value_type<ValueT>::value) {
// TODO: construct a vector spectator
// this is a quick solution now which makes a copy of the plain vector data
auto* start = reinterpret_cast<typename ValueT::value_type const*>(ref.payload);
auto* end = start + header->payloadSize / sizeof(typename ValueT::value_type);
auto container = std::make_unique<ValueT>(start, end);
std::unique_ptr<ValueT const, Deleter<ValueT const>> result(container.release(), Deleter<ValueT const>(true));
return result;
}
throw runtime_error("unsupported code path");
} else if (method == o2::header::gSerializationMethodROOT) {
// This supports the common case of retrieving a root object and getting pointer.
// Notice that this will return a copy of the actual contents of the buffer, because
// the buffer is actually serialised, for this reason we return a unique_ptr<T>.
// FIXME: does it make more sense to keep ownership of all the deserialised
// objects in a single place so that we can avoid duplicate deserializations?
// explicitely specify serialization method to ROOT-serialized because type T
// is messageable and a different method would be deduced in DataRefUtils
// return type with owning Deleter instance, forwarding to default_deleter
std::unique_ptr<ValueT const, Deleter<ValueT const>> result(DataRefUtils::as<ROOTSerialized<ValueT>>(ref).release());
return result;
} else {
throw runtime_error("Attempt to extract object from message with unsupported serialization type");
}
} else if constexpr (has_root_dictionary<T>::value) {
// retrieving ROOT objects follows the pointer approach, i.e. T* has to be specified
// as template parameter and a unique_ptr will be returned, std vectors of ROOT serializable
// objects can be retrieved by move, this is handled above in the "container" code branch
static_assert(always_static_assert_v<T>, "ROOT objects need to be retrieved by pointer");
} else {
// non-messageable objects for which serialization method can not be derived by type,
// the operation depends on the transmitted serialization method
using DataHeader = o2::header::DataHeader;
auto header = o2::header::get<const DataHeader*>(ref.header);
auto method = header->payloadSerializationMethod;
if (method == o2::header::gSerializationMethodNone) {
// this code path is only selected if the type is non-messageable
throw runtime_error(
"Type mismatch: attempt to extract a non-messagable object "
"from message with unserialized data");
} else if (method == o2::header::gSerializationMethodROOT) {
// explicitely specify serialization method to ROOT-serialized because type T
// is messageable and a different method would be deduced in DataRefUtils
// return type with owning Deleter instance, forwarding to default_deleter
std::unique_ptr<T const, Deleter<T const>> result(DataRefUtils::as<ROOTSerialized<T>>(ref).release());
return result;
} else {
throw runtime_error("Attempt to extract object from message with unsupported serialization type");
}
}
}
template <typename T>
T get_boost(char const* binding) const
{
DataRef ref = get<DataRef>(binding);
auto header = header::get<const header::DataHeader*>(ref.header);
assert(header);
auto str = std::string(ref.payload, header->payloadSize);
auto desData = o2::utils::BoostDeserialize<T>(str);
return std::move(desData);
}
/// Helper method to be used to check if a given part of the InputRecord is present.
bool isValid(std::string const& s) const
{
return isValid(s.c_str());
}
/// Helper method to be used to check if a given part of the InputRecord is present.
bool isValid(char const* s) const;
bool isValid(int pos) const;
/// @return the total number of inputs in the InputRecord. Notice that these will include
/// both valid and invalid inputs (i.e. inputs which have not arrived yet), depending
/// on the CompletionPolicy you have (using the default policy all inputs will be valid).
size_t size() const
{
return mSpan.size();
}
/// @return the total number of valid inputs in the InputRecord.
/// Invalid inputs might happen if the CompletionPolicy allows
/// incomplete records to be consumed or processed.
size_t countValidInputs() const;
template <typename T>
using IteratorBase = std::iterator<std::forward_iterator_tag, T>;
template <typename ParentT, typename T>
class Iterator : public IteratorBase<T>
{
public:
using ParentType = ParentT;
using SelfType = Iterator;
using value_type = typename IteratorBase<T>::value_type;
using reference = typename IteratorBase<T>::reference;
using pointer = typename IteratorBase<T>::pointer;
using ElementType = typename std::remove_const<value_type>::type;
Iterator() = delete;
Iterator(ParentType const* parent, size_t position = 0, size_t size = 0)
: mParent(parent), mPosition(position), mSize(size > position ? size : position), mElement{nullptr, nullptr, nullptr}
{
if (mPosition < mSize) {
if (mParent->isValid(mPosition)) {
mElement = mParent->getByPos(mPosition);
} else {
++(*this);
}
}
}
~Iterator() = default;
// prefix increment
SelfType& operator++()
{
while (mPosition < mSize && ++mPosition < mSize) {
if (!mParent->isValid(mPosition)) {
continue;
}
mElement = mParent->getByPos(mPosition);
break;
}
if (mPosition >= mSize) {
// reset the element to the default value of the type
mElement = ElementType{};
}
return *this;
}
// postfix increment
SelfType operator++(int /*unused*/)
{
SelfType copy(*this);
operator++();
return copy;
}
// return reference
reference operator*() const
{
return mElement;
}
// comparison
bool operator==(const SelfType& rh) const
{
return mPosition == rh.mPosition;
}
// comparison
bool operator!=(const SelfType& rh) const
{
return mPosition != rh.mPosition;
}
bool matches(o2::header::DataHeader matcher) const
{
if (mPosition >= mSize || mElement.header == nullptr) {
return false;
}
// at this point there must be a DataHeader, this has been checked by the DPL
// input cache
const auto* dh = DataRefUtils::getHeader<o2::header::DataHeader*>(mElement);
return *dh == matcher;
}
bool matches(o2::header::DataOrigin origin, o2::header::DataDescription description = o2::header::gDataDescriptionInvalid) const
{
if (mPosition >= mSize || mElement.header == nullptr) {
return false;
}
// at this point there must be a DataHeader, this has been checked by the DPL
// input cache
const auto* dh = DataRefUtils::getHeader<o2::header::DataHeader*>(mElement);
return dh->dataOrigin == origin && (description == o2::header::gDataDescriptionInvalid || dh->dataDescription == description);
}
bool matches(o2::header::DataOrigin origin, o2::header::DataDescription description, o2::header::DataHeader::SubSpecificationType subspec) const
{
return matches(o2::header::DataHeader{description, origin, subspec});
}
ParentType const* parent() const
{
return mParent;
}
size_t position() const
{
return mPosition;
}
private:
size_t mPosition;
size_t mSize;
ParentType const* mParent;
ElementType mElement;
};
/// @class InputRecordIterator
/// An iterator over the input slots
/// It supports an iterator interface to access the parts in the slot
template <typename T>
class InputRecordIterator : public Iterator<InputRecord, T>
{
public:
using SelfType = InputRecordIterator;
using BaseType = Iterator<InputRecord, T>;
using value_type = typename BaseType::value_type;
using reference = typename BaseType::reference;
using pointer = typename BaseType::pointer;
using ElementType = typename std::remove_const<value_type>::type;
using iterator = Iterator<SelfType, T>;
using const_iterator = Iterator<SelfType, const T>;
InputRecordIterator(InputRecord const* parent, size_t position = 0, size_t size = 0)
: BaseType(parent, position, size)
{
}
/// Get element at {slotindex, partindex}
ElementType getByPos(size_t pos) const
{
return this->parent()->getByPos(this->position(), pos);
}
/// Check if slot is valid, index of part is not used
bool isValid(size_t = 0) const
{
if (this->position() < this->parent()->size()) {
return this->parent()->isValid(this->position());
}
return false;
}
/// Get number of parts in input slot
size_t size() const
{
return this->parent()->getNofParts(this->position());
}
const_iterator begin() const
{
return const_iterator(this, 0, size());
}
const_iterator end() const
{
return const_iterator(this, size());
}
};
using iterator = InputRecordIterator<DataRef>;
using const_iterator = InputRecordIterator<const DataRef>;
const_iterator begin() const
{
return const_iterator(this, 0, size());
}
const_iterator end() const
{
return const_iterator(this, size());
}
private:
std::vector<InputRoute> const& mInputsSchema;
InputSpan mSpan;
};
} // namespace framework
} // namespace o2
#endif // FRAMEWORK_INPUTREGISTRY_H