##// END OF EJS Templates
It's now possible to create the variable and ask data to be retreived...
It's now possible to create the variable and ask data to be retreived asynchronously

File last commit:

r272:321e9d8b134b
r294:c71a61da7f3d
Show More
ArrayData.h
82 lines | 2.2 KiB | text/x-c | CLexer
Alexandre Leroux
Creates ArrayData (struct that holds data as a vector of double)
r116 #ifndef SCIQLOP_ARRAYDATA_H
#define SCIQLOP_ARRAYDATA_H
#include <QVector>
/**
* @brief The ArrayData class represents a dataset for a data series.
*
* A dataset can be unidimensional or two-dimensional. This property is determined by the Dim
* template-parameter.
*
* @tparam Dim the dimension of the ArrayData (one or two)
* @sa IDataSeries
*/
template <int Dim>
class ArrayData {
public:
/**
* Ctor for a unidimensional ArrayData
* @param nbColumns the number of values the ArrayData will hold
*/
template <int D = Dim, typename = std::enable_if_t<D == 1> >
explicit ArrayData(int nbColumns) : m_Data{1, QVector<double>{}}
{
m_Data[0].resize(nbColumns);
}
/**
* Sets a data at a specified index. The index has to be valid to be effective
* @param index the index to which the data will be set
* @param data the data to set
* @remarks this method is only available for a unidimensional ArrayData
*/
template <int D = Dim, typename = std::enable_if_t<D == 1> >
void setData(int index, double data) noexcept
{
if (index >= 0 && index < m_Data.at(0).size()) {
m_Data[0].replace(index, data);
}
}
/**
* @return the data as a vector
* @remarks this method is only available for a unidimensional ArrayData
*/
template <int D = Dim, typename = std::enable_if_t<D == 1> >
Update ArrayData to make it better
r272 const QVector<double> &data() const noexcept
Alexandre Leroux
Creates ArrayData (struct that holds data as a vector of double)
r116 {
Update ArrayData to make it better
r272 return m_Data[0];
Alexandre Leroux
Creates ArrayData (struct that holds data as a vector of double)
r116 }
Add merge API and implement it for the DataSeries
r217 /**
* @return the data as a vector
* @remarks this method is only available for a unidimensional ArrayData
*/
template <int D = Dim, typename = std::enable_if_t<D == 1> >
const QVector<double> &data(double tStart, double tEnd) const noexcept
{
return m_Data.at(tStart);
}
// TODO Comment
template <int D = Dim, typename = std::enable_if_t<D == 1> >
Update ArrayData to make it better
r272 void merge(const ArrayData<1> &arrayData)
Add merge API and implement it for the DataSeries
r217 {
if (!m_Data.empty()) {
Update ArrayData to make it better
r272 m_Data[0] += arrayData.data();
Add merge API and implement it for the DataSeries
r217 }
}
template <int D = Dim, typename = std::enable_if_t<D == 1> >
int size()
{
return m_Data[0].size();
}
Alexandre Leroux
Creates ArrayData (struct that holds data as a vector of double)
r116 private:
QVector<QVector<double> > m_Data;
};
#endif // SCIQLOP_ARRAYDATA_H