/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2010,2011,2012, by the GROMACS development team, led by
- * David van der Spoel, Berk Hess, Erik Lindahl, and including many
- * others, as listed in the AUTHORS file in the top-level source
- * directory and at http://www.gromacs.org.
+ * Copyright (c) 2010,2011,2012,2013,2014, by the GROMACS development team, led by
+ * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
+ * and including many others, as listed in the AUTHORS file in the
+ * top-level source directory and at http://www.gromacs.org.
*
* GROMACS is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
#include <vector>
-#include "../utility/gmxassert.h"
-
-#include "abstractdata.h"
-#include "dataframe.h"
+#include "gromacs/analysisdata/abstractdata.h"
+#include "gromacs/analysisdata/dataframe.h"
+#include "gromacs/utility/gmxassert.h"
namespace gmx
{
* accessed before it is available.
*
* \todo
- * Add methods to take full advantage of AnalysisDataValue features.
+ * Add support for multiple data sets.
*
* \inlibraryapi
* \ingroup module_analysisdata
public:
virtual ~AbstractAnalysisArrayData();
+ virtual int frameCount() const
+ {
+ return bReady_ ? rowCount_ : 0;
+ }
+
/*! \brief
* Returns the number of rows in the data array.
*
//! Returns true if values have been allocated.
bool isAllocated() const { return !value_.empty(); }
//! Returns the x value of the first frame.
- real xstart() const { return xstart_; }
+ real xstart() const { return xvalue_[0]; }
//! Returns the step between frame x values.
- real xstep() const { return xstep_; }
+ real xstep() const
+ {
+ GMX_ASSERT(bUniformX_, "Accessing x step for non-uniform data");
+ return xstep_;
+ }
//! Returns the x value of a row.
real xvalue(int row) const
{
GMX_ASSERT(row >= 0 && row < rowCount(), "Row index out of range");
- return xstart() + row * xstep();
+ return xvalue_[row];
}
//! Returns a given array element.
- real value(int row, int col) const
+ const AnalysisDataValue &value(int row, int col) const
{
GMX_ASSERT(row >= 0 && row < rowCount(), "Row index out of range");
GMX_ASSERT(col >= 0 && col < columnCount(), "Column index out of range");
GMX_ASSERT(isAllocated(), "Data array not allocated");
- return value_[row * columnCount() + col].value();
+ return value_[row * columnCount() + col];
}
protected:
* \param[in] step Step between x values of successive frames.
*
* Must not be called after valuesReady().
+ * Any values set with setXAxisValue() are overwritten.
*
* Does not throw.
*/
void setXAxis(real start, real step);
- //! Returns a reference to a given array element.
- real &value(int row, int col)
- {
- GMX_ASSERT(row >= 0 && row < rowCount(), "Row index out of range");
- GMX_ASSERT(col >= 0 && col < columnCount(), "Column index out of range");
- GMX_ASSERT(isAllocated(), "Data array not allocated");
- return value_[row * columnCount() + col].value();
- }
/*! \brief
- * Sets the value of an element in the array.
+ * Sets a single value reported as x value for frames.
*
- * \param[in] row Zero-based row index for the value.
- * \param[in] col Zero-based column index for the value.
- * \param[in] val Value to set in the given location.
+ * \param[in] row Row/frame for which to set the value.
+ * \param[in] value x value for the frame specified by \p row.
+ *
+ * Must not be called after valuesReady().
*
* Does not throw.
*/
- void setValue(int row, int col, real val)
+ void setXAxisValue(int row, real value);
+ //! Returns a reference to a given array element.
+ AnalysisDataValue &value(int row, int col)
{
- value(row, col) = val;
+ GMX_ASSERT(row >= 0 && row < rowCount(), "Row index out of range");
+ GMX_ASSERT(col >= 0 && col < columnCount(), "Column index out of range");
+ GMX_ASSERT(isAllocated(), "Data array not allocated");
+ return value_[row * columnCount() + col];
}
/*! \brief
* Notifies modules of the data.
virtual bool requestStorageInternal(int nframes);
int rowCount_;
+ AnalysisDataPointSetInfo pointSetInfo_;
std::vector<AnalysisDataValue> value_;
- real xstart_;
+ std::vector<real> xvalue_;
real xstep_;
+ bool bUniformX_;
bool bReady_;
// Copy and assign disallowed by base.
using AbstractAnalysisArrayData::setRowCount;
using AbstractAnalysisArrayData::allocateValues;
using AbstractAnalysisArrayData::setXAxis;
+ using AbstractAnalysisArrayData::setXAxisValue;
using AbstractAnalysisArrayData::value;
- using AbstractAnalysisArrayData::setValue;
using AbstractAnalysisArrayData::valuesReady;
// Copy and assign disallowed by base.