diff --git a/HDPS/src/plugins/PointData/src/PointData.h b/HDPS/src/plugins/PointData/src/PointData.h index f0379c1fd..640763fac 100644 --- a/HDPS/src/plugins/PointData/src/PointData.h +++ b/HDPS/src/plugins/PointData/src/PointData.h @@ -65,7 +65,6 @@ class POINTDATA_EXPORT PointData : public mv::plugin::RawData uint8 }; -private: using VariantOfVectors = std::variant < std::vector, std::vector, @@ -74,6 +73,7 @@ class POINTDATA_EXPORT PointData : public mv::plugin::RawData std::vector, std::vector >; +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 @@ -398,6 +398,15 @@ class POINTDATA_EXPORT PointData : public mv::plugin::RawData _numDimensions = static_cast(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 + void setData(VariantOfVectors data, const std::size_t numDimensions) + { + _variantOfVectors = std::move(data); + _numDimensions = static_cast(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.