Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions Framework/Core/include/Framework/InputRecord.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class InputRecord

size_t getNofParts(int pos) const
{
if (pos < 0) {
if (pos < 0 || pos >= mSpan.size()) {
return 0;
}
return mSpan.getNofParts(pos);
Expand Down Expand Up @@ -226,7 +226,7 @@ class InputRecord
/// incoming data. See @ref Inputrecord class description for supported types.
/// @param ref DataRef with pointers to input spec, header, and payload
template <typename T>
decltype(auto) get(DataRef ref) const
static decltype(auto) get(DataRef ref)
{
if constexpr (std::is_same<T, std::string>::value) {
// substitution for std::string
Expand Down Expand Up @@ -468,7 +468,7 @@ class InputRecord
if (mParent->isValid(mPosition)) {
mElement = mParent->getByPos(mPosition);
} else {
(*this)++;
++(*this);
}
}
}
Expand Down Expand Up @@ -499,17 +499,17 @@ class InputRecord
return copy;
}
// return reference
reference operator*()
reference operator*() const
{
return mElement;
}
// comparison
bool operator==(const SelfType& rh)
bool operator==(const SelfType& rh) const
{
return mPosition == rh.mPosition;
}
// comparison
bool operator!=(const SelfType& rh)
bool operator!=(const SelfType& rh) const
{
return mPosition != rh.mPosition;
}
Expand Down Expand Up @@ -588,7 +588,10 @@ class InputRecord
/// Check if slot is valid, index of part is not used
bool isValid(size_t = 0) const
{
return this->parent()->isValid(this->position());
if (this->position() < this->parent()->size()) {
return this->parent()->isValid(this->position());
}
return false;
}

/// Get number of parts in input slot
Expand Down
7 changes: 7 additions & 0 deletions Framework/Core/include/Framework/InputSpan.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ namespace framework
class InputSpan
{
public:
InputSpan() = delete;
InputSpan(InputSpan const&) = delete;
InputSpan(InputSpan&&) = default;

Comment on lines +26 to +29

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are fine, but we should also override operator= then.

/// @a getter is the mapping between an element of the span referred by
/// index and the buffer associated.
/// @a size is the number of elements in the span.
Expand Down Expand Up @@ -60,6 +64,9 @@ class InputSpan
/// @a number of parts in the i-th element of the InputSpan
size_t getNofParts(size_t i) const
{
if (i >= mSize) {
return 0;
}
if (!mNofPartsGetter) {
return 1;
}
Expand Down
5 changes: 4 additions & 1 deletion Framework/Core/src/InputRecord.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace framework
InputRecord::InputRecord(std::vector<InputRoute> const& inputsSchema,
InputSpan&& span)
: mInputsSchema{inputsSchema},
mSpan{span}
mSpan{std::move(span)}
{
}

Expand Down Expand Up @@ -71,6 +71,9 @@ bool InputRecord::isValid(char const* s) const

bool InputRecord::isValid(int s) const
{
if (s >= size()) {
return false;
}
DataRef ref = getByPos(s);
if (ref.header == nullptr || ref.payload == nullptr) {
return false;
Expand Down
8 changes: 8 additions & 0 deletions Framework/Core/test/test_InputRecord.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ BOOST_AUTO_TEST_CASE(TestInputRecord)
// check if invalid slots are filtered out by the iterator
BOOST_CHECK(position != 2);
}

// the 2-level iterator to access inputs and their parts
// all inputs have 1 part, we check the first input
BOOST_CHECK(record.begin().size() == 1);
// the end-instance of the inputs has no parts
BOOST_CHECK(record.end().size() == 0);
// thus there is no element and begin == end
BOOST_CHECK(record.end().begin() == record.end().end());
}

// TODO:
Expand Down