/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2010,2011,2012,2013,2014,2015,2016,2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2010-2018, The GROMACS development team.
+ * Copyright (c) 2019, 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.
*/
class AnalysisDataModuleManager::Impl
{
- public:
- //! Stores information about an attached module.
- struct ModuleInfo
+public:
+ //! Stores information about an attached module.
+ struct ModuleInfo
+ {
+ //! Initializes the module information.
+ explicit ModuleInfo(AnalysisDataModulePointer module) :
+ module(std::move(module)),
+ bParallel(false)
{
- //! Initializes the module information.
- explicit ModuleInfo(AnalysisDataModulePointer module)
- : module(std::move(module)), bParallel(false)
- {
- }
+ }
- //! Pointer to the actual module.
- AnalysisDataModulePointer module;
- //! Whether the module supports parallel processing.
- bool bParallel;
- };
+ //! Pointer to the actual module.
+ AnalysisDataModulePointer module;
+ //! Whether the module supports parallel processing.
+ bool bParallel;
+ };
- //! Shorthand for list of modules added to the data.
- typedef std::vector<ModuleInfo> ModuleList;
+ //! Shorthand for list of modules added to the data.
+ typedef std::vector<ModuleInfo> ModuleList;
- //! Describes the current state of the notification methods.
- enum State
- {
- eNotStarted, //!< Initial state (nothing called).
- eInData, //!< notifyDataStart() called, no frame in progress.
- eInFrame, //!< notifyFrameStart() called, but notifyFrameFinish() not.
- eFinished //!< notifyDataFinish() called.
- };
-
- Impl();
-
- /*! \brief
- * Checks whether a module is compatible with a given data property.
- *
- * \param[in] module Module to check.
- * \param[in] property Property to check.
- * \param[in] bSet Value of the property to check against.
- * \throws APIError if \p module is not compatible with the data.
- */
- void checkModuleProperty(const IAnalysisDataModule &module,
- DataProperty property, bool bSet) const;
- /*! \brief
- * Checks whether a module is compatible with the data properties.
- *
- * \param[in] module Module to check.
- * \throws APIError if \p module is not compatible with the data.
- *
- * Does not currently check the actual data (e.g., missing values), but
- * only the dimensionality and other preset properties of the data.
- */
- void checkModuleProperties(const IAnalysisDataModule &module) const;
-
- /*! \brief
- * Present data already added to the data object to a module.
- *
- * \param[in] data Data object to read data from.
- * \param[in] module Module to present the data to.
- * \throws APIError if \p module is not compatible with the data.
- * \throws APIError if all data is not available through
- * getDataFrame().
- * \throws unspecified Any exception thrown by \p module in its data
- * notification methods.
- *
- * Uses getDataFrame() in \p data to access all data in the object, and
- * calls the notification functions in \p module as if the module had
- * been registered to the data object when the data was added.
- */
- void presentData(AbstractAnalysisData *data,
- IAnalysisDataModule *module);
-
- //! List of modules added to the data.
- ModuleList modules_;
- //! Properties of the owning data for module checking.
- bool bDataProperty_[eDataPropertyNR];
- //! true if all modules support missing data.
- bool bAllowMissing_;
- //! true if there are modules that do not support parallel processing.
- bool bSerialModules_;
- //! true if there are modules that support parallel processing.
- bool bParallelModules_;
-
- /*! \brief
- * Current state of the notification methods.
- *
- * This is used together with \a currIndex_ for sanity checks on the
- * input data; invalid call sequences trigger asserts.
- * The state of these variables does not otherwise affect the behavior
- * of this class; this is the reason they can be changed in const
- * methods.
- */
- //! Whether notifyDataStart() has been called.
- mutable State state_;
- //! Index of currently active frame or the next frame if not in frame.
- mutable int currIndex_;
+ //! Describes the current state of the notification methods.
+ enum State
+ {
+ eNotStarted, //!< Initial state (nothing called).
+ eInData, //!< notifyDataStart() called, no frame in progress.
+ eInFrame, //!< notifyFrameStart() called, but notifyFrameFinish() not.
+ eFinished //!< notifyDataFinish() called.
+ };
+
+ Impl();
+
+ /*! \brief
+ * Checks whether a module is compatible with a given data property.
+ *
+ * \param[in] module Module to check.
+ * \param[in] property Property to check.
+ * \param[in] bSet Value of the property to check against.
+ * \throws APIError if \p module is not compatible with the data.
+ */
+ void checkModuleProperty(const IAnalysisDataModule& module, DataProperty property, bool bSet) const;
+ /*! \brief
+ * Checks whether a module is compatible with the data properties.
+ *
+ * \param[in] module Module to check.
+ * \throws APIError if \p module is not compatible with the data.
+ *
+ * Does not currently check the actual data (e.g., missing values), but
+ * only the dimensionality and other preset properties of the data.
+ */
+ void checkModuleProperties(const IAnalysisDataModule& module) const;
+
+ /*! \brief
+ * Present data already added to the data object to a module.
+ *
+ * \param[in] data Data object to read data from.
+ * \param[in] module Module to present the data to.
+ * \throws APIError if \p module is not compatible with the data.
+ * \throws APIError if all data is not available through
+ * getDataFrame().
+ * \throws unspecified Any exception thrown by \p module in its data
+ * notification methods.
+ *
+ * Uses getDataFrame() in \p data to access all data in the object, and
+ * calls the notification functions in \p module as if the module had
+ * been registered to the data object when the data was added.
+ */
+ void presentData(AbstractAnalysisData* data, IAnalysisDataModule* module);
+
+ //! List of modules added to the data.
+ ModuleList modules_;
+ //! Properties of the owning data for module checking.
+ bool bDataProperty_[eDataPropertyNR];
+ //! true if all modules support missing data.
+ bool bAllowMissing_;
+ //! true if there are modules that do not support parallel processing.
+ bool bSerialModules_;
+ //! true if there are modules that support parallel processing.
+ bool bParallelModules_;
+
+ /*! \brief
+ * Current state of the notification methods.
+ *
+ * This is used together with \a currIndex_ for sanity checks on the
+ * input data; invalid call sequences trigger asserts.
+ * The state of these variables does not otherwise affect the behavior
+ * of this class; this is the reason they can be changed in const
+ * methods.
+ */
+ //! Whether notifyDataStart() has been called.
+ mutable State state_;
+ //! Index of currently active frame or the next frame if not in frame.
+ mutable int currIndex_;
};
-AnalysisDataModuleManager::Impl::Impl()
- : bDataProperty_(), // This must be in sync with how AbstractAnalysisData
- // is actually initialized.
- bAllowMissing_(true), bSerialModules_(false), bParallelModules_(false),
- state_(eNotStarted), currIndex_(0)
+AnalysisDataModuleManager::Impl::Impl() :
+ bDataProperty_(), // This must be in sync with how AbstractAnalysisData
+ // is actually initialized.
+ bAllowMissing_(true),
+ bSerialModules_(false),
+ bParallelModules_(false),
+ state_(eNotStarted),
+ currIndex_(0)
{
}
-void
-AnalysisDataModuleManager::Impl::checkModuleProperty(
- const IAnalysisDataModule &module,
- DataProperty property, bool bSet) const
+void AnalysisDataModuleManager::Impl::checkModuleProperty(const IAnalysisDataModule& module,
+ DataProperty property,
+ bool bSet) const
{
bool bOk = true;
const int flags = module.flags();
bOk = false;
}
break;
- default:
- GMX_RELEASE_ASSERT(false, "Invalid data property enumeration");
+ default: GMX_RELEASE_ASSERT(false, "Invalid data property enumeration");
}
if (!bOk)
{
}
}
-void
-AnalysisDataModuleManager::Impl::checkModuleProperties(
- const IAnalysisDataModule &module) const
+void AnalysisDataModuleManager::Impl::checkModuleProperties(const IAnalysisDataModule& module) const
{
for (int i = 0; i < eDataPropertyNR; ++i)
{
}
}
-void
-AnalysisDataModuleManager::Impl::presentData(AbstractAnalysisData *data,
- IAnalysisDataModule *module)
+void AnalysisDataModuleManager::Impl::presentData(AbstractAnalysisData* data, IAnalysisDataModule* module)
{
if (state_ == eNotStarted)
{
return;
}
- GMX_RELEASE_ASSERT(state_ != eInFrame,
- "Cannot apply a modules in mid-frame");
+ GMX_RELEASE_ASSERT(state_ != eInFrame, "Cannot apply a modules in mid-frame");
module->dataStarted(data);
- const bool bCheckMissing = bAllowMissing_
- && ((module->flags() & IAnalysisDataModule::efAllowMissing) == 0);
+ const bool bCheckMissing =
+ bAllowMissing_ && ((module->flags() & IAnalysisDataModule::efAllowMissing) == 0);
for (int i = 0; i < data->frameCount(); ++i)
{
AnalysisDataFrameRef frame = data->getDataFrame(i);
* AnalysisDataModuleManager
*/
-AnalysisDataModuleManager::AnalysisDataModuleManager()
- : impl_(new Impl())
-{
-}
+AnalysisDataModuleManager::AnalysisDataModuleManager() : impl_(new Impl()) {}
-AnalysisDataModuleManager::~AnalysisDataModuleManager()
-{
-}
+AnalysisDataModuleManager::~AnalysisDataModuleManager() {}
-void
-AnalysisDataModuleManager::dataPropertyAboutToChange(DataProperty property, bool bSet)
+void AnalysisDataModuleManager::dataPropertyAboutToChange(DataProperty property, bool bSet)
{
GMX_RELEASE_ASSERT(impl_->state_ == Impl::eNotStarted,
"Cannot change data properties after data has been started");
}
}
-void
-AnalysisDataModuleManager::addModule(AbstractAnalysisData *data,
- const AnalysisDataModulePointer &module)
+void AnalysisDataModuleManager::addModule(AbstractAnalysisData* data, const AnalysisDataModulePointer& module)
{
impl_->checkModuleProperties(*module);
// TODO: Ensure that the system does not end up in an inconsistent state by
// adding a module in mid-data during parallel processing (probably best to
// prevent alltogether).
- GMX_RELEASE_ASSERT(impl_->state_ != Impl::eInFrame,
- "Cannot add a data module in mid-frame");
+ GMX_RELEASE_ASSERT(impl_->state_ != Impl::eInFrame, "Cannot add a data module in mid-frame");
impl_->presentData(data, module.get());
if (!(module->flags() & IAnalysisDataModule::efAllowMissing))
impl_->modules_.emplace_back(module);
}
-void
-AnalysisDataModuleManager::applyModule(AbstractAnalysisData *data,
- IAnalysisDataModule *module)
+void AnalysisDataModuleManager::applyModule(AbstractAnalysisData* data, IAnalysisDataModule* module)
{
impl_->checkModuleProperties(*module);
GMX_RELEASE_ASSERT(impl_->state_ == Impl::eFinished,
}
-bool
-AnalysisDataModuleManager::hasSerialModules() const
+bool AnalysisDataModuleManager::hasSerialModules() const
{
GMX_ASSERT(impl_->state_ != Impl::eNotStarted,
"Module state not accessible before data is started");
}
-void
-AnalysisDataModuleManager::notifyDataStart(AbstractAnalysisData *data)
+void AnalysisDataModuleManager::notifyDataStart(AbstractAnalysisData* data)
{
GMX_RELEASE_ASSERT(impl_->state_ == Impl::eNotStarted,
"notifyDataStart() called more than once");
for (int d = 0; d < data->dataSetCount(); ++d)
{
- GMX_RELEASE_ASSERT(data->columnCount(d) > 0,
- "Data column count is not set");
+ GMX_RELEASE_ASSERT(data->columnCount(d) > 0, "Data column count is not set");
}
impl_->state_ = Impl::eInData;
impl_->bSerialModules_ = !impl_->modules_.empty();
}
-void
-AnalysisDataModuleManager::notifyParallelDataStart(
- AbstractAnalysisData *data,
- const AnalysisDataParallelOptions &options)
+void AnalysisDataModuleManager::notifyParallelDataStart(AbstractAnalysisData* data,
+ const AnalysisDataParallelOptions& options)
{
GMX_RELEASE_ASSERT(impl_->state_ == Impl::eNotStarted,
"notifyDataStart() called more than once");
for (int d = 0; d < data->dataSetCount(); ++d)
{
- GMX_RELEASE_ASSERT(data->columnCount(d) > 0,
- "Data column count is not set");
+ GMX_RELEASE_ASSERT(data->columnCount(d) > 0, "Data column count is not set");
}
impl_->state_ = Impl::eInData;
impl_->bSerialModules_ = false;
}
-void
-AnalysisDataModuleManager::notifyFrameStart(const AnalysisDataFrameHeader &header) const
+void AnalysisDataModuleManager::notifyFrameStart(const AnalysisDataFrameHeader& header) const
{
GMX_ASSERT(impl_->state_ == Impl::eInData, "Invalid call sequence");
GMX_ASSERT(header.index() == impl_->currIndex_, "Out of order frames");
- impl_->state_ = Impl::eInFrame;
+ impl_->state_ = Impl::eInFrame;
if (impl_->bSerialModules_)
{
}
}
-void
-AnalysisDataModuleManager::notifyParallelFrameStart(
- const AnalysisDataFrameHeader &header) const
+void AnalysisDataModuleManager::notifyParallelFrameStart(const AnalysisDataFrameHeader& header) const
{
if (impl_->bParallelModules_)
{
}
-void
-AnalysisDataModuleManager::notifyPointsAdd(const AnalysisDataPointSetRef &points) const
+void AnalysisDataModuleManager::notifyPointsAdd(const AnalysisDataPointSetRef& points) const
{
GMX_ASSERT(impl_->state_ == Impl::eInFrame, "notifyFrameStart() not called");
// TODO: Add checks for column spans (requires passing the information
// about the column counts from somewhere).
- //GMX_ASSERT(points.lastColumn() < columnCount(points.dataSetIndex()),
+ // GMX_ASSERT(points.lastColumn() < columnCount(points.dataSetIndex()),
// "Invalid columns");
GMX_ASSERT(points.frameIndex() == impl_->currIndex_,
"Points do not correspond to current frame");
}
-void
-AnalysisDataModuleManager::notifyParallelPointsAdd(
- const AnalysisDataPointSetRef &points) const
+void AnalysisDataModuleManager::notifyParallelPointsAdd(const AnalysisDataPointSetRef& points) const
{
// TODO: Add checks for column spans (requires passing the information
// about the column counts from somewhere).
- //GMX_ASSERT(points.lastColumn() < columnCount(points.dataSetIndex()),
+ // GMX_ASSERT(points.lastColumn() < columnCount(points.dataSetIndex()),
// "Invalid columns");
if (impl_->bParallelModules_)
{
}
-void
-AnalysisDataModuleManager::notifyFrameFinish(const AnalysisDataFrameHeader &header) const
+void AnalysisDataModuleManager::notifyFrameFinish(const AnalysisDataFrameHeader& header) const
{
GMX_ASSERT(impl_->state_ == Impl::eInFrame, "notifyFrameStart() not called");
- GMX_ASSERT(header.index() == impl_->currIndex_,
- "Header does not correspond to current frame");
+ GMX_ASSERT(header.index() == impl_->currIndex_, "Header does not correspond to current frame");
// TODO: Add a check for the frame count in the source data including this
// frame.
impl_->state_ = Impl::eInData;
}
-void
-AnalysisDataModuleManager::notifyParallelFrameFinish(
- const AnalysisDataFrameHeader &header) const
+void AnalysisDataModuleManager::notifyParallelFrameFinish(const AnalysisDataFrameHeader& header) const
{
if (impl_->bParallelModules_)
{
}
-void
-AnalysisDataModuleManager::notifyDataFinish() const
+void AnalysisDataModuleManager::notifyDataFinish() const
{
GMX_RELEASE_ASSERT(impl_->state_ == Impl::eInData, "Invalid call sequence");
impl_->state_ = Impl::eFinished;