Line data Source code
1 : /** 2 : * @file Data.hpp 3 : * 4 : * @brief Encapsulating DTWC data in a class. 5 : * 6 : * @author Volkan Kumtepeli 7 : * @author Becky Perriment 8 : * @date 04 Dec 2022 9 : */ 10 : 11 : #pragma once 12 : 13 : #include "settings.hpp" 14 : 15 : #include <cstddef> // for size_t 16 : #include <cassert> // for assert 17 : #include <string> // for string 18 : #include <utility> // for move 19 : #include <vector> // for vector 20 : 21 : namespace dtwc { 22 : 23 : /** 24 : * @brief Struct to encapsulate DTWC data. 25 : * This struct holds data vectors and their corresponding names, providing 26 : * functionalities to manage and access the data. 27 : */ 28 : struct Data 29 : { 30 : std::vector<std::vector<data_t>> p_vec; //!< Vector of data vectors 31 : std::vector<std::string> p_names; //!< Vector of data point names 32 : 33 : /** 34 : * @brief Returns the number of data points. 35 : * @return Integer representing the size of the data vector. 36 : */ 37 3 : auto size() const { return static_cast<int>(p_vec.size()); } 38 : 39 3 : Data() = default; //!< Default constructor 40 : 41 : /** 42 : * @brief Constructor that initializes data and name vectors. 43 : * @param p_vec_new Rvalue reference to a vector of data vectors. 44 : * @param p_names_new Rvalue reference to a vector of data point names. 45 : * @throws std::runtime_error if data and name vectors are not of the same size. 46 : */ 47 2 : Data(std::vector<std::vector<data_t>> &&p_vec_new, std::vector<std::string> &&p_names_new) 48 2 : { 49 2 : if (p_vec_new.size() != p_names_new.size()) 50 1 : throw std::runtime_error("Data and name vectors should be of the same size"); 51 : 52 1 : p_vec = std::move(p_vec_new); 53 1 : p_names = std::move(p_names_new); 54 3 : } 55 : }; 56 : 57 : } // namespace dtwc