Sort all includes in src/gromacs
[alexxy/gromacs.git] / src / gromacs / analysisdata / arraydata.h
index df30162ac71ecbad62adb2be6cfd80ec3dfedc42..f255ae70f612e34f2e1dd7829fbccbdcb97854c0 100644 (file)
@@ -1,10 +1,10 @@
 /*
  * 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
 {
@@ -66,7 +65,7 @@ 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
@@ -76,6 +75,11 @@ class AbstractAnalysisArrayData : public AbstractAnalysisData
     public:
         virtual ~AbstractAnalysisArrayData();
 
+        virtual int frameCount() const
+        {
+            return bReady_ ? rowCount_ : 0;
+        }
+
         /*! \brief
          * Returns the number of rows in the data array.
          *
@@ -86,22 +90,26 @@ class AbstractAnalysisArrayData : public AbstractAnalysisData
         //! 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:
@@ -149,30 +157,29 @@ class AbstractAnalysisArrayData : public AbstractAnalysisData
          * \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.
@@ -203,9 +210,11 @@ class AbstractAnalysisArrayData : public AbstractAnalysisData
         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.
@@ -244,8 +253,8 @@ class AnalysisArrayData : public AbstractAnalysisArrayData
         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.