2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2010,2011,2012,2013, by the GROMACS development team, led by
5 * David van der Spoel, Berk Hess, Erik Lindahl, and including many
6 * others, as listed in the AUTHORS file in the top-level source
7 * directory and at http://www.gromacs.org.
9 * GROMACS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GROMACS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with GROMACS; if not, see
21 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * If you want to redistribute modifications to GROMACS, please
25 * consider that scientific software is very special. Version
26 * control is crucial - bugs must be traceable. We will be happy to
27 * consider code for inclusion in the official distribution, but
28 * derived work must not be called official GROMACS. Details are found
29 * in the README & COPYING files - if they are missing, get the
30 * official version at http://www.gromacs.org.
32 * To help us fund GROMACS development, we humbly ask that you cite
33 * the research papers on the package. Check out http://www.gromacs.org.
35 /*! \libinternal \file
37 * Declares gmx::AnalysisDataModuleManager.
39 * \author Teemu Murtola <teemu.murtola@gmail.com>
41 * \ingroup module_analysisdata
43 #ifndef GMX_ANALYSISDATA_DATAMODULEMANAGER_H
44 #define GMX_ANALYSISDATA_DATAMODULEMANAGER_H
46 #include "abstractdata.h"
48 #include "../utility/common.h"
53 /*! \libinternal \brief
54 * Encapsulates handling of data modules attached to AbstractAnalysisData.
57 * \ingroup module_analysisdata
59 class AnalysisDataModuleManager
63 * Identifies data properties to check with data modules.
65 * \see AnalysisDataModuleInterface::Flag
69 eMultipleDataSets, //!< Data has multiple data sets.
70 eMultipleColumns, //!< Data has multiple columns.
71 eMultipoint, //!< Data is multipoint.
72 eDataPropertyNR //!< Number of properties; for internal use only.
75 AnalysisDataModuleManager();
76 ~AnalysisDataModuleManager();
79 * Allows the manager to check modules for compatibility with the data.
81 * \throws APIError if any data module already added is not compatible
82 * with the new setting.
84 * Does two things: checks any modules already attached to the data and
85 * throws if any of them is not compatible, and stores the property
86 * to check modules attached in the future.
88 * Strong exception safety.
90 void dataPropertyAboutToChange(DataProperty property, bool bSet);
93 * Adds a module to process the data.
95 * \param data Data object to add the module to.
96 * \param module Module to add.
97 * \throws std::bad_alloc if out of memory.
99 * - \p module is not compatible with the data object
100 * - data has already been added to the data object and everything
101 * is not available through getDataFrame().
102 * \throws unspecified Any exception thrown by \p module in its
103 * notification methods (if data has been added).
105 * \see AbstractAnalysisData::addModule()
107 void addModule(AbstractAnalysisData *data,
108 AnalysisDataModulePointer module);
110 * Applies a module to process data that is ready.
112 * \param data Data object to apply the module to.
113 * \param module Module to apply.
114 * \throws APIError in same situations as addModule().
115 * \throws unspecified Any exception thrown by \p module in its
116 * notification methods.
118 * \see AbstractAnalysisData::applyModule()
120 void applyModule(AbstractAnalysisData *data,
121 AnalysisDataModuleInterface *module);
124 * Notifies attached modules of the start of data.
126 * \param data Data object that is starting.
127 * \throws APIError if any attached data module is not compatible.
128 * \throws unspecified Any exception thrown by attached data modules
129 * in AnalysisDataModuleInterface::dataStarted().
131 * Should be called once, after data properties have been set with
132 * the methods in AbstractAnalysisData, and before any other
133 * notification methods.
134 * The caller should be prepared for requestStorage() calls to \p data
135 * from the attached modules.
137 * \p data should typically be \c this when calling from a class
138 * derived from AbstractAnalysisData.
140 void notifyDataStart(AbstractAnalysisData *data) const;
142 * Notifies attached modules of the start of a frame.
144 * \param[in] header Header information for the frame that is starting.
145 * \throws unspecified Any exception thrown by attached data modules
146 * in AnalysisDataModuleInterface::frameStarted().
148 * Should be called once for each frame, before notifyPointsAdd() calls
151 void notifyFrameStart(const AnalysisDataFrameHeader &header) const;
153 * Notifies attached modules of the addition of points to the
156 * \param[in] points Set of points added (also provides access to
158 * \throws APIError if any attached data module is not compatible.
159 * \throws unspecified Any exception thrown by attached data modules
160 * in AnalysisDataModuleInterface::pointsAdded().
162 * Can be called zero or more times for each frame.
163 * The caller should ensure that any column occurs at most once in the
164 * calls, unless the data is multipoint.
165 * For efficiency reasons, calls to this method should be aggregated
166 * whenever possible, i.e., it's better to handle multiple columns or
167 * even the whole frame in a single call rather than calling the method
168 * for each column separately.
170 void notifyPointsAdd(const AnalysisDataPointSetRef &points) const;
172 * Notifies attached modules of the end of a frame.
174 * \param[in] header Header information for the frame that is ending.
175 * \throws unspecified Any exception thrown by attached data modules
176 * in AnalysisDataModuleInterface::frameFinished().
178 * Should be called once for each call of notifyFrameStart(), after any
179 * notifyPointsAdd() calls for the frame.
180 * \p header should be identical to that used in the corresponding
181 * notifyFrameStart() call.
183 void notifyFrameFinish(const AnalysisDataFrameHeader &header) const;
185 * Notifies attached modules of the end of data.
187 * \throws unspecified Any exception thrown by attached data modules
188 * in AnalysisDataModuleInterface::dataFinished().
190 * Should be called once, after all the other notification calls.
192 void notifyDataFinish() const;
197 PrivateImplPointer<Impl> impl_;