Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make VariantOfVectors a public type of PointData, add setData overload #496

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
11 changes: 10 additions & 1 deletion HDPS/src/plugins/PointData/src/PointData.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ class POINTDATA_EXPORT PointData : public mv::plugin::RawData
uint8
};

private:
using VariantOfVectors = std::variant <
std::vector<float>,
std::vector<biovault::bfloat16_t>,
Expand All @@ -74,6 +73,7 @@ class POINTDATA_EXPORT PointData : public mv::plugin::RawData
std::vector<std::int8_t>,
std::vector<std::uint8_t> >;

private:
// Sets the index of the specified variant. If the new index is different from the previous one, the value will be reset.
// Inspired by `expand_type` from kmbeutel at
// https://www.reddit.com/r/cpp/comments/f8cbzs/creating_stdvariant_based_on_index_at_runtime/?rdt=52905
Expand Down Expand Up @@ -398,6 +398,15 @@ class POINTDATA_EXPORT PointData : public mv::plugin::RawData
_numDimensions = static_cast<unsigned int>(numDimensions);
}

/// Copies (or "moves") the data from the specified variant into the internal data and sets the number of dimensions as specified.
/// Note that the `data` parameter is passed by-value (non-const), in order to avoid expensive copying (using C++ move semantics).
template <typename T>
void setData(VariantOfVectors data, const std::size_t numDimensions)
{
_variantOfVectors = std::move(data);
_numDimensions = static_cast<unsigned int>(numDimensions);
}

/// Efficiently "moves" the data from the specified vector into the internal
/// data, sets the number of dimensions as specified, and sets the selected
/// internal data type according to the specified data type T.
Expand Down
Loading