3 * This source code is part of
7 * GROningen MAchine for Chemical Simulations
9 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
10 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
11 * Copyright (c) 2001-2009, The GROMACS development team,
12 * check out http://www.gromacs.org for more information.
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * If you want to redistribute modifications, please consider that
20 * scientific software is very special. Version control is crucial -
21 * bugs must be traceable. We will be happy to consider code for
22 * inclusion in the official distribution, but derived work must not
23 * be called official GROMACS. Details are found in the README & COPYING
24 * files - if they are missing, get the official version at www.gromacs.org.
26 * To help us fund GROMACS development, we humbly ask that you cite
27 * the papers on the package - you can find them in the top README file.
29 * For more info, check our website at http://www.gromacs.org
33 * Declares gmx::AnalysisData and related classes.
35 * \author Teemu Murtola <teemu.murtola@cbr.su.se>
37 * \ingroup module_analysisdata
39 #ifndef GMX_ANALYSISDATA_ANALYSISDATA_H
40 #define GMX_ANALYSISDATA_ANALYSISDATA_H
42 #include "abstractdata.h"
47 class AnalysisDataHandle;
48 class AnalysisDataParallelOptions;
51 * Parallelizable data container for raw data.
54 * Special note for MPI implementation: assuming that the initialization of
55 * data objects is identical in all processes, associating the data objects
56 * in different MPI processes should be possible without changes in the
58 * Alternative, more robust implementation could get a unique ID as parameter
59 * to the constructor or a separate function, but would require all tools to
64 * \ingroup module_analysisdata
66 class AnalysisData : public AbstractAnalysisData
69 //! Creates an empty analysis data object.
71 virtual ~AnalysisData();
74 * Sets the number of columns in the data.
76 void setColumnCount(int ncol);
78 * Sets whether the data contains multiple points per column per frame.
82 void setMultipoint(bool bMultipoint);
85 * Create a handle for adding data.
87 * \param[in] opt Options for setting how this handle will be
89 * \returns The created handle.
91 * The caller should retain the returned handle (or a copy of it), and
92 * pass it to finishData() after successfully adding all data.
93 * The caller should discard the returned handle if an error occurs;
94 * memory allocated for the handle will be freed when the AnalysisData
95 * object is destroyed.
97 AnalysisDataHandle startData(const AnalysisDataParallelOptions &opt);
99 * Destroy a handle after all data has been added.
101 * \param[in] handle Handle to destroy.
103 * The \p handle (and any copies) are invalid after the call.
105 void finishData(AnalysisDataHandle handle);
108 virtual AnalysisDataFrameRef tryGetDataFrameInternal(int index) const;
109 virtual bool requestStorageInternal(int nframes);
113 PrivateImplPointer<Impl> impl_;
115 friend class AnalysisDataHandle;
120 class AnalysisDataHandleImpl;
121 } // namespace internal
124 * Handle for inserting data into AnalysisData.
126 * This class works like a pointer type: copying and assignment is lightweight,
127 * and all copies work interchangeably, accessing the same internal handle.
129 * Several handles can exist concurrently.
132 * \ingroup module_analysisdata
134 class AnalysisDataHandle
138 * Constructs an invalid data handle.
140 * This constructor is provided for convenience in cases where it is
141 * easiest to declare an AnalysisDataHandle without immediately
142 * assigning a value to it. Any attempt to call methods without first
143 * assigning a value from AnalysisData::startData() to the handle
146 AnalysisDataHandle();
148 //! Start data for a new frame.
149 void startFrame(int index, real x, real dx = 0.0);
150 //! Set a value for a single column for the current frame.
151 void setPoint(int col, real y, real dy = 0.0, bool present = true);
152 //! Set values for consecutive columns for the current frame.
153 void setPoints(int firstcol, int n, const real *y);
154 //! Finish data for the current point set.
155 void finishPointSet();
156 //! Finish data for the current frame.
158 //! Calls AnalysisData::finishData() for this handle.
163 * Creates a new data handle associated with \p data.
165 * \param data Data to associate the handle with.
167 * The constructor is private because data handles should only be
168 * constructed through AnalysisData::startData().
170 explicit AnalysisDataHandle(internal::AnalysisDataHandleImpl *impl);
173 * Pointer to the internal implementation class.
175 * The memory for this object is managed by the AnalysisData object,
176 * and AnalysisDataHandle simply provides a public interface for
177 * accessing the implementation.
179 internal::AnalysisDataHandleImpl *impl_;
181 friend class AnalysisData;