preCICE v3.2.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SampleResult.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <Eigen/Core>
4
5namespace precice::time {
6
15public:
17 SampleResult(const Eigen::VectorXd &ref) noexcept
18 : _view(ref.data(), ref.size()) {}
19
21 SampleResult(Eigen::VectorXd &&vec)
22 : _owned(std::move(vec)), _view(_owned.data(), _owned.size()) {}
23
24 // No copy
25 SampleResult(const SampleResult &other) = delete;
26 SampleResult &operator=(const SampleResult &other) = delete;
27
28 // Move is allowed
29 SampleResult(SampleResult &&other) = default;
30 SampleResult &operator=(SampleResult &&other) = default;
31
33 Eigen::Map<const Eigen::VectorXd> values() const noexcept
34 {
35 return _view;
36 }
37
39 auto operator()(Eigen::Index index) const
40 {
41 return _view(index);
42 }
43
44private:
45 Eigen::VectorXd _owned;
46 Eigen::Map<const Eigen::VectorXd> _view;
47};
48
49} // namespace precice::time
unsigned int index
SampleResult & operator=(const SampleResult &other)=delete
SampleResult(Eigen::VectorXd &&vec)
Creates an owning SampleResult.
auto operator()(Eigen::Index index) const
Direct read-access to a value in the underlying view.
SampleResult(const SampleResult &other)=delete
Eigen::Map< const Eigen::VectorXd > _view
SampleResult(SampleResult &&other)=default
Eigen::Map< const Eigen::VectorXd > values() const noexcept
Access the values as a vector.
SampleResult & operator=(SampleResult &&other)=default
SampleResult(const Eigen::VectorXd &ref) noexcept
Creates a non-owning SampleResult.
contains the time interpolation logic.
Definition Sample.hpp:8
STL namespace.