+++ /dev/null
-/*
- *
- * This source code is part of
- *
- * G R O M A C S
- *
- * GROningen MAchine for Chemical Simulations
- *
- * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
- * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2009, The GROMACS development team,
- * check out http://www.gromacs.org for more information.
-
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * If you want to redistribute modifications, please consider that
- * scientific software is very special. Version control is crucial -
- * bugs must be traceable. We will be happy to consider code for
- * inclusion in the official distribution, but derived work must not
- * be called official GROMACS. Details are found in the README & COPYING
- * files - if they are missing, get the official version at www.gromacs.org.
- *
- * To help us fund GROMACS development, we humbly ask that you cite
- * the papers on the package - you can find them in the top README file.
- *
- * For more info, check our website at http://www.gromacs.org
- */
-/*! \internal \file
- * \brief
- * Declares internal implementation class for gmx::AbstractAnalysisData.
- *
- * \author Teemu Murtola <teemu.murtola@cbr.su.se>
- * \ingroup module_analysisdata
- */
-#ifndef GMX_ANALYSISDATA_ABSTRACTDATA_IMPL_H
-#define GMX_ANALYSISDATA_ABSTRACTDATA_IMPL_H
-
-#include <vector>
-
-#include "../legacyheaders/types/simple.h"
-
-#include "gromacs/utility/uniqueptr.h"
-
-#include "abstractdata.h"
-#include "dataframe.h"
-
-namespace gmx
-{
-
-/*! \internal \brief
- * Private implementation class for AbstractAnalysisData.
- *
- * \ingroup module_analysisdata
- */
-class AbstractAnalysisData::Impl
-{
- public:
- //! Shorthand for list of modules added to the data.
- typedef std::vector<AnalysisDataModulePointer> ModuleList;
-
- Impl();
- ~Impl();
-
- /*! \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
- * object.
- * \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,
- AnalysisDataModuleInterface *module);
-
- //! List of modules added to the data.
- ModuleList _modules;
- //! true if all modules support missing data.
- bool _bAllowMissing;
- //! Whether notifyDataStart() has been called.
- mutable bool _bDataStart;
- //! Whether new data is being added.
- mutable bool _bInData;
- //! Whether data for a frame is being added.
- mutable bool _bInFrame;
- //! Index of the currently active frame.
- mutable int _currIndex;
- /*! \brief
- * Total number of frames in the data.
- *
- * The counter is incremented in notifyFrameFinish().
- */
- int _nframes;
-};
-
-} // namespace gmx
-
-#endif
*/
#include "gromacs/analysisdata/abstractdata.h"
+#include <vector>
+
+#include "gromacs/analysisdata/datamodule.h"
#include "gromacs/utility/exceptions.h"
#include "gromacs/utility/gmxassert.h"
+#include "gromacs/utility/uniqueptr.h"
-#include "abstractdata-impl.h"
#include "dataframe.h"
#include "dataproxy.h"
* AbstractAnalysisData::Impl
*/
+/*! \internal \brief
+ * Private implementation class for AbstractAnalysisData.
+ *
+ * \ingroup module_analysisdata
+ */
+class AbstractAnalysisData::Impl
+{
+ public:
+ //! Shorthand for list of modules added to the data.
+ typedef std::vector<AnalysisDataModulePointer> ModuleList;
+
+ Impl();
+
+ /*! \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
+ * object.
+ * \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,
+ AnalysisDataModuleInterface *module);
+
+ //! List of modules added to the data.
+ ModuleList _modules;
+ //! true if all modules support missing data.
+ bool _bAllowMissing;
+ //! Whether notifyDataStart() has been called.
+ mutable bool _bDataStart;
+ //! Whether new data is being added.
+ mutable bool _bInData;
+ //! Whether data for a frame is being added.
+ mutable bool _bInFrame;
+ //! Index of the currently active frame.
+ mutable int _currIndex;
+ /*! \brief
+ * Total number of frames in the data.
+ *
+ * The counter is incremented in notifyFrameFinish().
+ */
+ int _nframes;
+};
+
AbstractAnalysisData::Impl::Impl()
: _bAllowMissing(true), _bDataStart(false), _bInData(false), _bInFrame(false),
_currIndex(-1), _nframes(0)
{
}
-AbstractAnalysisData::Impl::~Impl()
-{
-}
-
-
void
AbstractAnalysisData::Impl::presentData(AbstractAnalysisData *data,
AnalysisDataModuleInterface *module)
+++ /dev/null
-/*
- *
- * This source code is part of
- *
- * G R O M A C S
- *
- * GROningen MAchine for Chemical Simulations
- *
- * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
- * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2009, The GROMACS development team,
- * check out http://www.gromacs.org for more information.
-
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * If you want to redistribute modifications, please consider that
- * scientific software is very special. Version control is crucial -
- * bugs must be traceable. We will be happy to consider code for
- * inclusion in the official distribution, but derived work must not
- * be called official GROMACS. Details are found in the README & COPYING
- * files - if they are missing, get the official version at www.gromacs.org.
- *
- * To help us fund GROMACS development, we humbly ask that you cite
- * the papers on the package - you can find them in the top README file.
- *
- * For more info, check our website at http://www.gromacs.org
- */
-/*! \internal \file
- * \brief
- * Declares private implementation class for gmx::AnalysisData.
- *
- * \author Teemu Murtola <teemu.murtola@cbr.su.se>
- * \ingroup module_analysisdata
- */
-#ifndef GMX_ANALYSISDATA_ANALYSISDATA_IMPL_H
-#define GMX_ANALYSISDATA_ANALYSISDATA_IMPL_H
-
-#include <vector>
-
-#include "gromacs/utility/uniqueptr.h"
-
-#include "analysisdata.h"
-#include "datastorage.h"
-
-namespace gmx
-{
-
-namespace internal
-{
-/*! \internal \brief
- * Private implementation class for AnalysisDataHandle.
- *
- * \ingroup module_analysisdata
- */
-class AnalysisDataHandleImpl
-{
- public:
- //! Creates a handle associated with the given data object.
- explicit AnalysisDataHandleImpl(AnalysisData *data);
-
- //! The data object that this handle belongs to.
- AnalysisData &data_;
- //! Current storage frame object, or NULL if no current frame.
- AnalysisDataStorageFrame *currentFrame_;
-};
-} // namespace internal
-
-/*! \internal \brief
- * Private implementation class for AnalysisData.
- *
- * \ingroup module_analysisdata
- */
-class AnalysisData::Impl
-{
- public:
- //! Smart pointer type to manage a data handle implementation.
- typedef gmx_unique_ptr<internal::AnalysisDataHandleImpl>::type
- HandlePointer;
- //! Shorthand for a list of data handles.
- typedef std::vector<HandlePointer> HandleList;
-
- Impl();
- ~Impl();
-
- //! Storage implementation.
- AnalysisDataStorage storage_;
- /*! \brief
- * List of handles for this data object.
- *
- * Note that AnalysisDataHandle objects also contain (raw) pointers
- * to these objects.
- */
- HandleList handles_;
-};
-
-} // namespace gmx
-
-#endif
#include "gromacs/analysisdata/paralleloptions.h"
#include "gromacs/utility/exceptions.h"
#include "gromacs/utility/gmxassert.h"
-
-#include "analysisdata-impl.h"
+#include "gromacs/utility/uniqueptr.h"
namespace gmx
{
/********************************************************************
- * AnalysisData::Impl
+ * AnalysisDataHandleImpl
*/
-AnalysisData::Impl::Impl()
+namespace internal
{
-}
-
-AnalysisData::Impl::~Impl()
+/*! \internal \brief
+ * Private implementation class for AnalysisDataHandle.
+ *
+ * \ingroup module_analysisdata
+ */
+class AnalysisDataHandleImpl
{
-}
+ public:
+ //! Creates a handle associated with the given data object.
+ explicit AnalysisDataHandleImpl(AnalysisData *data)
+ : data_(*data), currentFrame_(NULL)
+ {
+ }
+
+ //! The data object that this handle belongs to.
+ AnalysisData &data_;
+ //! Current storage frame object, or NULL if no current frame.
+ AnalysisDataStorageFrame *currentFrame_;
+};
+} // namespace internal
+
+/********************************************************************
+ * AnalysisData::Impl
+ */
+
+/*! \internal \brief
+ * Private implementation class for AnalysisData.
+ *
+ * \ingroup module_analysisdata
+ */
+class AnalysisData::Impl
+{
+ public:
+ //! Smart pointer type to manage a data handle implementation.
+ typedef gmx_unique_ptr<internal::AnalysisDataHandleImpl>::type
+ HandlePointer;
+ //! Shorthand for a list of data handles.
+ typedef std::vector<HandlePointer> HandleList;
+
+ //! Storage implementation.
+ AnalysisDataStorage storage_;
+ /*! \brief
+ * List of handles for this data object.
+ *
+ * Note that AnalysisDataHandle objects also contain (raw) pointers
+ * to these objects.
+ */
+ HandleList handles_;
+};
/********************************************************************
* AnalysisData
}
-/********************************************************************
- * AnalysisDataHandleImpl
- */
-
-internal::AnalysisDataHandleImpl::AnalysisDataHandleImpl(AnalysisData *data)
- : data_(*data), currentFrame_(NULL)
-{
-}
-
-
/********************************************************************
* AnalysisDataHandle
*/
+++ /dev/null
-/*
- *
- * This source code is part of
- *
- * G R O M A C S
- *
- * GROningen MAchine for Chemical Simulations
- *
- * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
- * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2009, The GROMACS development team,
- * check out http://www.gromacs.org for more information.
-
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * If you want to redistribute modifications, please consider that
- * scientific software is very special. Version control is crucial -
- * bugs must be traceable. We will be happy to consider code for
- * inclusion in the official distribution, but derived work must not
- * be called official GROMACS. Details are found in the README & COPYING
- * files - if they are missing, get the official version at www.gromacs.org.
- *
- * To help us fund GROMACS development, we humbly ask that you cite
- * the papers on the package - you can find them in the top README file.
- *
- * For more info, check our website at http://www.gromacs.org
- */
-/*! \internal \file
- * \brief
- * Declares internal implementation classes for gmx::AnalysisDataStorage.
- *
- * \author Teemu Murtola <teemu.murtola@cbr.su.se>
- * \ingroup module_analysisdata
- */
-#ifndef GMX_ANALYSISDATA_DATASTORAGE_IMPL_H
-#define GMX_ANALYSISDATA_DATASTORAGE_IMPL_H
-
-#include <limits>
-#include <vector>
-
-#include "gromacs/utility/uniqueptr.h"
-
-#include "datastorage.h"
-
-namespace gmx
-{
-
-class AbstractAnalysisData;
-class AnalysisDataPointSetRef;
-class AnalysisDataStorageFrame;
-
-/*! \internal \brief
- * Private implementation class for AnalysisDataStorage.
- *
- * \ingroup module_analysisdata
- */
-class AnalysisDataStorage::Impl
-{
- public:
- //! Smart pointer type for managing a stored frame.
- typedef gmx_unique_ptr<AnalysisDataStorageFrame>::type FramePointer;
-
- /*! \brief
- * Stored information about a single stored frame.
- *
- * Methods in this class do not throw.
- */
- struct StoredFrame
- {
- //! Indicates what operations have been performed on a frame.
- enum Status
- {
- eMissing, //!< Frame has not yet been started.
- eStarted, //!< startFrame() has been called.
- eFinished, //!< finishFrame() has been called.
- eNotified //!< Appropriate notifications have been sent.
- };
-
- //! Constructs an object that manages a given frame object.
- explicit StoredFrame(AnalysisDataStorageFrame *frame)
- : frame(frame), status(eMissing)
- {
- }
- //! Whether the frame has been started with startFrame().
- bool isStarted() const { return status >= eStarted; }
- //! Whether the frame has been finished with finishFrame().
- bool isFinished() const { return status >= eFinished; }
- //! Whether all notifications have been sent.
- bool isNotified() const { return status >= eNotified; }
- //! Whether the frame is ready to be available outside the storage.
- bool isAvailable() const { return status >= eFinished; }
-
- /*! \brief
- * Actual frame data.
- *
- * Never NULL.
- */
- FramePointer frame;
- //! In what state the frame currently is.
- Status status;
- };
-
- //! Shorthand for a list of data frames that are currently stored.
- typedef std::vector<StoredFrame> FrameList;
-
- Impl();
- ~Impl();
-
- //! Returns the number of columns in the attached data.
- int columnCount() const;
- //! Returns whether the storage is set to use multipoint data.
- bool isMultipoint() const;
- /*! \brief
- * Whether storage of all frames has been requested.
- *
- * Storage of all frames also works as expected if \a storageLimit_ is
- * used in comparisons directly, but this method should be used to
- * check how to manage \a frames_.
- */
- bool storeAll() const
- {
- return storageLimit_ == std::numeric_limits<int>::max();
- }
- //! Returns the index of the oldest frame that may be currently stored.
- int firstStoredIndex() const;
- /*! \brief
- * Computes index into \a frames_ for accessing frame \p index.
- *
- * \param[in] index Zero-based frame index.
- * \retval -1 if \p index is not available in \a frames_.
- *
- * Does not throw.
- */
- int computeStorageLocation(int index) const;
-
- /*! \brief
- * Computes an index into \a frames_ that is one past the last frame
- * stored.
- *
- * Does not throw.
- */
- size_t endStorageLocation() const;
-
- /*! \brief
- * Extends \a frames_ to a new size.
- *
- * \throws std::bad_alloc if out of memory.
- */
- void extendBuffer(AnalysisDataStorage *storage, size_t newSize);
- /*! \brief
- * Remove oldest frame from the storage to make space for a new one.
- *
- * Increments \a firstFrameLocation_ and reinitializes the frame that
- * was made unavailable by this operation.
- *
- * Does not throw.
- *
- * \see frames_
- */
- void rotateBuffer();
-
- /*! \brief
- * Calls notification method in \a data_.
- *
- * \throws unspecified Any exception thrown by
- * AbstractAnalysisData::notifyPointsAdd().
- */
- void notifyPointSet(const AnalysisDataPointSetRef &points);
- /*! \brief
- * Calls notification methods for new frames.
- *
- * \param[in] firstLocation First frame to consider.
- * \throws unspecified Any exception thrown by frame notification
- * methods in AbstractAnalysisData.
- *
- * Notifies \a data_ of new frames (from \p firstLocation and after
- * that) if all previous frames have already been notified.
- * Also rotates the \a frames_ buffer as necessary.
- */
- void notifyNextFrames(size_t firstLocation);
-
- //! Data object to use for notification calls.
- AbstractAnalysisData *data_;
- /*! \brief
- * Whether the storage has been set to allow multipoint.
- *
- * Should be possible to remove once full support for multipoint data
- * has been implemented; isMultipoint() can simply return
- * \c data_->isMultipoint() in that case.
- */
- bool bMultipoint_;
- /*! \brief
- * Number of past frames that need to be stored.
- *
- * Always non-negative. If storage of all frames has been requested,
- * this is set to a large number.
- */
- int storageLimit_;
- /*! \brief
- * Number of future frames that may need to be started.
- *
- * Should always be at least one.
- *
- * \see AnalysisDataStorage::startFrame()
- */
- int pendingLimit_;
- /*! \brief
- * Data frames that are currently stored.
- *
- * If storage of all frames has been requested, this is simply a vector
- * of frames up to the latest frame that has been started.
- * In this case, \a firstFrameLocation_ is always zero.
- *
- * If storage of all frames is not requested, this is a ring buffer of
- * frames of size \c n=storageLimit_+pendingLimit_+1. If a frame with
- * index \c index is currently stored, its location is
- * \c index%frames_.size().
- * When at most \a storageLimit_ first frames have been finished,
- * this contains storage for the first \c n-1 frames.
- * When more than \a storageLimit_ first frames have been finished,
- * the oldest stored frame is stored in the location
- * \a firstFrameLocation_, and \a storageLimit_ frames starting from
- * this location are the last finished frames. \a pendingLimit_ frames
- * follow, and some of these may be in progress or finished.
- * There is always one unused frame in the buffer, which is initialized
- * such that when \a firstFrameLocation_ is incremented, it becomes
- * valid. This makes it easier to rotate the buffer in concurrent
- * access scenarions (which are not yet otherwise implemented).
- */
- FrameList frames_;
- //! Location of oldest frame in \a frames_.
- size_t firstFrameLocation_;
- /*! \brief
- * Index of next frame that will be added to \a frames_.
- *
- * If all frames are not stored, this will be the index of the unused
- * frame (see \a frames_).
- */
- int nextIndex_;
-};
-
-} // namespace gmx
-
-#endif
#include "datastorage.h"
#include <limits>
+#include <vector>
#include "gromacs/analysisdata/abstractdata.h"
#include "gromacs/analysisdata/dataframe.h"
#include "gromacs/analysisdata/paralleloptions.h"
#include "gromacs/utility/exceptions.h"
#include "gromacs/utility/gmxassert.h"
-
-#include "datastorage-impl.h"
+#include "gromacs/utility/uniqueptr.h"
namespace gmx
{
/********************************************************************
- * AnalysisDataStorageFrame
+ * AnalysisDataStorage::Impl
*/
-AnalysisDataStorageFrame::AnalysisDataStorageFrame(AnalysisDataStorage *storage,
- int columnCount, int index)
- : storage_(*storage), header_(index, 0.0, 0.0), values_(columnCount)
-{
-}
-
-
-AnalysisDataStorageFrame::~AnalysisDataStorageFrame()
-{
-}
-
-
-AnalysisDataPointSetRef
-AnalysisDataStorageFrame::currentPoints() const
-{
- std::vector<AnalysisDataValue>::const_iterator begin = values_.begin();
- std::vector<AnalysisDataValue>::const_iterator end = values_.end();
- while (begin != end && !begin->isSet())
- {
- ++begin;
- }
- while (end != begin && !(end-1)->isSet())
- {
- --end;
- }
- int firstColumn = (begin != end) ? begin - values_.begin() : 0;
- return AnalysisDataPointSetRef(header_, firstColumn,
- AnalysisDataValuesRef(begin, end));
-}
-
-
-void
-AnalysisDataStorageFrame::clearValues()
-{
- std::vector<AnalysisDataValue>::iterator i;
- for (i = values_.begin(); i != values_.end(); ++i)
- {
- i->clear();
- }
-}
-
-
-void
-AnalysisDataStorageFrame::finishPointSet()
-{
- storage_.impl_->notifyPointSet(currentPoints());
- clearValues();
-}
-
-
-/********************************************************************
- * AnalysisDataStorage::Impl
+/*! \internal \brief
+ * Private implementation class for AnalysisDataStorage.
+ *
+ * \ingroup module_analysisdata
*/
+class AnalysisDataStorage::Impl
+{
+ public:
+ //! Smart pointer type for managing a stored frame.
+ typedef gmx_unique_ptr<AnalysisDataStorageFrame>::type FramePointer;
+
+ /*! \brief
+ * Stored information about a single stored frame.
+ *
+ * Methods in this class do not throw.
+ */
+ struct StoredFrame
+ {
+ //! Indicates what operations have been performed on a frame.
+ enum Status
+ {
+ eMissing, //!< Frame has not yet been started.
+ eStarted, //!< startFrame() has been called.
+ eFinished, //!< finishFrame() has been called.
+ eNotified //!< Appropriate notifications have been sent.
+ };
+
+ //! Constructs an object that manages a given frame object.
+ explicit StoredFrame(AnalysisDataStorageFrame *frame)
+ : frame(frame), status(eMissing)
+ {
+ }
+ //! Whether the frame has been started with startFrame().
+ bool isStarted() const { return status >= eStarted; }
+ //! Whether the frame has been finished with finishFrame().
+ bool isFinished() const { return status >= eFinished; }
+ //! Whether all notifications have been sent.
+ bool isNotified() const { return status >= eNotified; }
+ //! Whether the frame is ready to be available outside the storage.
+ bool isAvailable() const { return status >= eFinished; }
+
+ /*! \brief
+ * Actual frame data.
+ *
+ * Never NULL.
+ */
+ FramePointer frame;
+ //! In what state the frame currently is.
+ Status status;
+ };
+
+ //! Shorthand for a list of data frames that are currently stored.
+ typedef std::vector<StoredFrame> FrameList;
+
+ Impl();
+
+ //! Returns the number of columns in the attached data.
+ int columnCount() const;
+ //! Returns whether the storage is set to use multipoint data.
+ bool isMultipoint() const;
+ /*! \brief
+ * Whether storage of all frames has been requested.
+ *
+ * Storage of all frames also works as expected if \a storageLimit_ is
+ * used in comparisons directly, but this method should be used to
+ * check how to manage \a frames_.
+ */
+ bool storeAll() const
+ {
+ return storageLimit_ == std::numeric_limits<int>::max();
+ }
+ //! Returns the index of the oldest frame that may be currently stored.
+ int firstStoredIndex() const;
+ /*! \brief
+ * Computes index into \a frames_ for accessing frame \p index.
+ *
+ * \param[in] index Zero-based frame index.
+ * \retval -1 if \p index is not available in \a frames_.
+ *
+ * Does not throw.
+ */
+ int computeStorageLocation(int index) const;
+
+ /*! \brief
+ * Computes an index into \a frames_ that is one past the last frame
+ * stored.
+ *
+ * Does not throw.
+ */
+ size_t endStorageLocation() const;
+
+ /*! \brief
+ * Extends \a frames_ to a new size.
+ *
+ * \throws std::bad_alloc if out of memory.
+ */
+ void extendBuffer(AnalysisDataStorage *storage, size_t newSize);
+ /*! \brief
+ * Remove oldest frame from the storage to make space for a new one.
+ *
+ * Increments \a firstFrameLocation_ and reinitializes the frame that
+ * was made unavailable by this operation.
+ *
+ * Does not throw.
+ *
+ * \see frames_
+ */
+ void rotateBuffer();
+
+ /*! \brief
+ * Calls notification method in \a data_.
+ *
+ * \throws unspecified Any exception thrown by
+ * AbstractAnalysisData::notifyPointsAdd().
+ */
+ void notifyPointSet(const AnalysisDataPointSetRef &points);
+ /*! \brief
+ * Calls notification methods for new frames.
+ *
+ * \param[in] firstLocation First frame to consider.
+ * \throws unspecified Any exception thrown by frame notification
+ * methods in AbstractAnalysisData.
+ *
+ * Notifies \a data_ of new frames (from \p firstLocation and after
+ * that) if all previous frames have already been notified.
+ * Also rotates the \a frames_ buffer as necessary.
+ */
+ void notifyNextFrames(size_t firstLocation);
+
+ //! Data object to use for notification calls.
+ AbstractAnalysisData *data_;
+ /*! \brief
+ * Whether the storage has been set to allow multipoint.
+ *
+ * Should be possible to remove once full support for multipoint data
+ * has been implemented; isMultipoint() can simply return
+ * \c data_->isMultipoint() in that case.
+ */
+ bool bMultipoint_;
+ /*! \brief
+ * Number of past frames that need to be stored.
+ *
+ * Always non-negative. If storage of all frames has been requested,
+ * this is set to a large number.
+ */
+ int storageLimit_;
+ /*! \brief
+ * Number of future frames that may need to be started.
+ *
+ * Should always be at least one.
+ *
+ * \see AnalysisDataStorage::startFrame()
+ */
+ int pendingLimit_;
+ /*! \brief
+ * Data frames that are currently stored.
+ *
+ * If storage of all frames has been requested, this is simply a vector
+ * of frames up to the latest frame that has been started.
+ * In this case, \a firstFrameLocation_ is always zero.
+ *
+ * If storage of all frames is not requested, this is a ring buffer of
+ * frames of size \c n=storageLimit_+pendingLimit_+1. If a frame with
+ * index \c index is currently stored, its location is
+ * \c index%frames_.size().
+ * When at most \a storageLimit_ first frames have been finished,
+ * this contains storage for the first \c n-1 frames.
+ * When more than \a storageLimit_ first frames have been finished,
+ * the oldest stored frame is stored in the location
+ * \a firstFrameLocation_, and \a storageLimit_ frames starting from
+ * this location are the last finished frames. \a pendingLimit_ frames
+ * follow, and some of these may be in progress or finished.
+ * There is always one unused frame in the buffer, which is initialized
+ * such that when \a firstFrameLocation_ is incremented, it becomes
+ * valid. This makes it easier to rotate the buffer in concurrent
+ * access scenarions (which are not yet otherwise implemented).
+ */
+ FrameList frames_;
+ //! Location of oldest frame in \a frames_.
+ size_t firstFrameLocation_;
+ /*! \brief
+ * Index of next frame that will be added to \a frames_.
+ *
+ * If all frames are not stored, this will be the index of the unused
+ * frame (see \a frames_).
+ */
+ int nextIndex_;
+};
AnalysisDataStorage::Impl::Impl()
: data_(NULL), bMultipoint_(false),
}
-AnalysisDataStorage::Impl::~Impl()
-{
-}
-
-
int
AnalysisDataStorage::Impl::columnCount() const
{
}
+/********************************************************************
+ * AnalysisDataStorageFrame
+ */
+
+AnalysisDataStorageFrame::AnalysisDataStorageFrame(AnalysisDataStorage *storage,
+ int columnCount, int index)
+ : storage_(*storage), header_(index, 0.0, 0.0), values_(columnCount)
+{
+}
+
+
+AnalysisDataStorageFrame::~AnalysisDataStorageFrame()
+{
+}
+
+
+AnalysisDataPointSetRef
+AnalysisDataStorageFrame::currentPoints() const
+{
+ std::vector<AnalysisDataValue>::const_iterator begin = values_.begin();
+ std::vector<AnalysisDataValue>::const_iterator end = values_.end();
+ while (begin != end && !begin->isSet())
+ {
+ ++begin;
+ }
+ while (end != begin && !(end-1)->isSet())
+ {
+ --end;
+ }
+ int firstColumn = (begin != end) ? begin - values_.begin() : 0;
+ return AnalysisDataPointSetRef(header_, firstColumn,
+ AnalysisDataValuesRef(begin, end));
+}
+
+
+void
+AnalysisDataStorageFrame::clearValues()
+{
+ std::vector<AnalysisDataValue>::iterator i;
+ for (i = values_.begin(); i != values_.end(); ++i)
+ {
+ i->clear();
+ }
+}
+
+
+void
+AnalysisDataStorageFrame::finishPointSet()
+{
+ storage_.impl_->notifyPointSet(currentPoints());
+ clearValues();
+}
+
+
/********************************************************************
* AnalysisDataStorage
*/
+++ /dev/null
-/*
- *
- * This source code is part of
- *
- * G R O M A C S
- *
- * GROningen MAchine for Chemical Simulations
- *
- * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
- * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2009, The GROMACS development team,
- * check out http://www.gromacs.org for more information.
-
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * If you want to redistribute modifications, please consider that
- * scientific software is very special. Version control is crucial -
- * bugs must be traceable. We will be happy to consider code for
- * inclusion in the official distribution, but derived work must not
- * be called official GROMACS. Details are found in the README & COPYING
- * files - if they are missing, get the official version at www.gromacs.org.
- *
- * To help us fund GROMACS development, we humbly ask that you cite
- * the papers on the package - you can find them in the top README file.
- *
- * For more info, check our website at http://www.gromacs.org
- */
-/*! \internal \file
- * \brief
- * Declares private implementation class for
- * gmx::AnalysisDataDisplacementModule.
- *
- * \author Teemu Murtola <teemu.murtola@cbr.su.se>
- * \ingroup module_analysisdata
- */
-#ifndef GMX_ANALYSISDATA_MODULES_DISPLACEMENT_IMPL_H
-#define GMX_ANALYSISDATA_MODULES_DISPLACEMENT_IMPL_H
-
-#include <vector>
-
-#include "../dataframe.h"
-
-#include "displacement.h"
-
-namespace gmx
-{
-
-class AnalysisDataBinAverageModule;
-
-/*! \internal \brief
- * Private implementation class for AnalysisDataDisplacementModule.
- *
- * \ingroup module_analysisdata
- */
-class AnalysisDataDisplacementModule::Impl
-{
- public:
- Impl();
- ~Impl();
-
- //! Maximum number of particles for which the displacements are calculated.
- int nmax;
- //! Maximum time for which the displacements are needed.
- real tmax;
- //! Number of dimensions per data point.
- int ndim;
-
- //! true if no frames have been read.
- bool bFirst;
- //! Stores the time of the first frame.
- real t0;
- //! Stores the time interval between frames.
- real dt;
- //! Stores the time of the current frame.
- real t;
- //! Stores the index in the store for the current positions.
- int ci;
-
- //! Maximum number of positions to store for a particle.
- int max_store;
- //! The total number of positions ever stored (can be larger than \p max_store).
- int nstored;
- //! Old values.
- real *oldval;
- //! The most recently calculated displacements.
- std::vector<AnalysisDataValue> currValues_;
-
- //! Histogram module for calculating MSD histograms, or NULL if not set.
- AnalysisDataBinAverageModule *histm;
-};
-
-} // namespace gmx
-
-#endif
#include "gromacs/utility/exceptions.h"
#include "gromacs/utility/gmxassert.h"
-#include "displacement-impl.h"
-
namespace gmx
{
* AnalysisDataDisplacementModule::Impl
*/
+/*! \internal \brief
+ * Private implementation class for AnalysisDataDisplacementModule.
+ *
+ * \ingroup module_analysisdata
+ */
+class AnalysisDataDisplacementModule::Impl
+{
+ public:
+ Impl();
+ ~Impl();
+
+ //! Maximum number of particles for which the displacements are calculated.
+ int nmax;
+ //! Maximum time for which the displacements are needed.
+ real tmax;
+ //! Number of dimensions per data point.
+ int ndim;
+
+ //! true if no frames have been read.
+ bool bFirst;
+ //! Stores the time of the first frame.
+ real t0;
+ //! Stores the time interval between frames.
+ real dt;
+ //! Stores the time of the current frame.
+ real t;
+ //! Stores the index in the store for the current positions.
+ int ci;
+
+ //! Maximum number of positions to store for a particle.
+ int max_store;
+ //! The total number of positions ever stored (can be larger than \p max_store).
+ int nstored;
+ //! Old values.
+ real *oldval;
+ //! The most recently calculated displacements.
+ std::vector<AnalysisDataValue> currValues_;
+
+ //! Histogram module for calculating MSD histograms, or NULL if not set.
+ AnalysisDataBinAverageModule *histm;
+};
+
AnalysisDataDisplacementModule::Impl::Impl()
: nmax(0), tmax(0.0), ndim(3),
bFirst(true), t0(0.0), dt(0.0), t(0.0),
+++ /dev/null
-/*
- *
- * This source code is part of
- *
- * G R O M A C S
- *
- * GROningen MAchine for Chemical Simulations
- *
- * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
- * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2009, The GROMACS development team,
- * check out http://www.gromacs.org for more information.
-
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * If you want to redistribute modifications, please consider that
- * scientific software is very special. Version control is crucial -
- * bugs must be traceable. We will be happy to consider code for
- * inclusion in the official distribution, but derived work must not
- * be called official GROMACS. Details are found in the README & COPYING
- * files - if they are missing, get the official version at www.gromacs.org.
- *
- * To help us fund GROMACS development, we humbly ask that you cite
- * the papers on the package - you can find them in the top README file.
- *
- * For more info, check our website at http://www.gromacs.org
- */
-/*! \internal \file
- * \brief
- * Declares private implementation classes for classes in histogram.h.
- *
- * \author Teemu Murtola <teemu.murtola@cbr.su.se>
- * \ingroup module_analysisdata
- */
-#ifndef GMX_ANALYSISDATA_MODULES_HISTOGRAM_IMPL_H
-#define GMX_ANALYSISDATA_MODULES_HISTOGRAM_IMPL_H
-
-#include <vector>
-
-#include "histogram.h"
-
-#include "../datastorage.h"
-
-namespace gmx
-{
-
-namespace internal
-{
-
-/*! \internal \brief
- * Represents copies of average histograms.
- *
- * Methods in AbstractAverageHistogram that return new histogram instances
- * return objects of this class.
- * Initialization of values is handled in those methods.
- *
- * \ingroup module_analysisdata
- */
-class StaticAverageHistogram : public AbstractAverageHistogram
-{
- public:
- StaticAverageHistogram();
- //! Creates an average histogram module with defined bin parameters.
- explicit StaticAverageHistogram(const AnalysisHistogramSettings &settings);
-
- // Copy and assign disallowed by base.
-};
-
-/*! \internal \brief
- * Implements average histogram module that averages per-frame histograms.
- *
- * This class is used for accumulating average histograms in per-frame
- * histogram modules (those that use BasicHistogramImpl as their implementation
- * class).
- * There are two columns, first for the average and second for standard
- * deviation.
- *
- * \ingroup module_analysisdata
- */
-class BasicAverageHistogramModule : public AbstractAverageHistogram,
- public AnalysisDataModuleInterface
-{
- public:
- BasicAverageHistogramModule();
- //! Creates an average histogram module with defined bin parameters.
- explicit BasicAverageHistogramModule(const AnalysisHistogramSettings &settings);
-
- using AbstractAverageHistogram::init;
-
- virtual int flags() const;
-
- virtual void dataStarted(AbstractAnalysisData *data);
- virtual void frameStarted(const AnalysisDataFrameHeader &header);
- virtual void pointsAdded(const AnalysisDataPointSetRef &points);
- virtual void frameFinished(const AnalysisDataFrameHeader &header);
- virtual void dataFinished();
-
- private:
- //! Number of frames accumulated so far.
- int frameCount_;
-
- // Copy and assign disallowed by base.
-};
-
-//! Smart pointer to manage an BasicAverageHistogramModule object.
-typedef boost::shared_ptr<BasicAverageHistogramModule>
- BasicAverageHistogramModulePointer;
-
-/*! \internal \brief
- * Private implementation class for AnalysisDataSimpleHistogramModule and
- * AnalysisDataWeightedHistogramModule.
- *
- * \ingroup module_analysisdata
- */
-class BasicHistogramImpl
-{
- public:
- BasicHistogramImpl();
- //! Creates an histogram impl with defined bin parameters.
- explicit BasicHistogramImpl(const AnalysisHistogramSettings &settings);
- ~BasicHistogramImpl();
-
- /*! \brief
- * (Re)initializes the histogram from settings.
- */
- void init(const AnalysisHistogramSettings &settings);
- /*! \brief
- * Initializes data storage frame when a new frame starts.
- */
- void initFrame(AnalysisDataStorageFrame *frame);
-
- //! Storage implementation object.
- AnalysisDataStorage storage_;
- //! Settings for the histogram object.
- AnalysisHistogramSettings settings_;
- //! Averager module.
- BasicAverageHistogramModulePointer averager_;
-};
-
-} // namespace internal
-
-} // namespace gmx
-
-#endif
#include "gromacs/utility/exceptions.h"
#include "gromacs/utility/gmxassert.h"
-#include "histogram-impl.h"
-
static const real UNDEFINED = std::numeric_limits<real>::max();
static bool isDefined(real value)
{
}
+/********************************************************************
+ * StaticAverageHistogram
+ */
+
+namespace
+{
+
+/*! \internal \brief
+ * Represents copies of average histograms.
+ *
+ * Methods in AbstractAverageHistogram that return new histogram instances
+ * return objects of this class.
+ * Initialization of values is handled in those methods.
+ *
+ * \ingroup module_analysisdata
+ */
+class StaticAverageHistogram : public AbstractAverageHistogram
+{
+ public:
+ StaticAverageHistogram();
+ //! Creates an average histogram module with defined bin parameters.
+ explicit StaticAverageHistogram(const AnalysisHistogramSettings &settings);
+
+ // Copy and assign disallowed by base.
+};
+
+StaticAverageHistogram::StaticAverageHistogram()
+{
+}
+
+
+StaticAverageHistogram::StaticAverageHistogram(
+ const AnalysisHistogramSettings &settings)
+ : AbstractAverageHistogram(settings)
+{
+}
+
+} // namespace
+
+
/********************************************************************
* AbstractAverageHistogram
*/
}
AverageHistogramPointer dest(
- new internal::StaticAverageHistogram(
+ new StaticAverageHistogram(
histogramFromBins(xstart(), nbins, 2*xstep())
.integerBins(bIntegerBins)));
dest->setColumnCount(columnCount());
AverageHistogramPointer
AbstractAverageHistogram::clone() const
{
- AverageHistogramPointer dest(new internal::StaticAverageHistogram());
+ AverageHistogramPointer dest(new StaticAverageHistogram());
copyContents(this, dest.get());
return dest;
}
/********************************************************************
- * StaticAverageHistogram
+ * BasicAverageHistogramModule
*/
namespace internal
{
-StaticAverageHistogram::StaticAverageHistogram()
+/*! \internal \brief
+ * Implements average histogram module that averages per-frame histograms.
+ *
+ * This class is used for accumulating average histograms in per-frame
+ * histogram modules (those that use BasicHistogramImpl as their implementation
+ * class).
+ * There are two columns, first for the average and second for standard
+ * deviation.
+ *
+ * \ingroup module_analysisdata
+ */
+class BasicAverageHistogramModule : public AbstractAverageHistogram,
+ public AnalysisDataModuleInterface
{
-}
+ public:
+ BasicAverageHistogramModule();
+ //! Creates an average histogram module with defined bin parameters.
+ explicit BasicAverageHistogramModule(const AnalysisHistogramSettings &settings);
+ using AbstractAverageHistogram::init;
-StaticAverageHistogram::StaticAverageHistogram(
- const AnalysisHistogramSettings &settings)
- : AbstractAverageHistogram(settings)
-{
-}
+ virtual int flags() const;
+ virtual void dataStarted(AbstractAnalysisData *data);
+ virtual void frameStarted(const AnalysisDataFrameHeader &header);
+ virtual void pointsAdded(const AnalysisDataPointSetRef &points);
+ virtual void frameFinished(const AnalysisDataFrameHeader &header);
+ virtual void dataFinished();
-/********************************************************************
- * BasicAverageHistogramModule
- */
+ private:
+ //! Number of frames accumulated so far.
+ int frameCount_;
+
+ // Copy and assign disallowed by base.
+};
BasicAverageHistogramModule::BasicAverageHistogramModule()
: frameCount_(0)
* BasicHistogramImpl
*/
+/*! \internal \brief
+ * Private implementation class for AnalysisDataSimpleHistogramModule and
+ * AnalysisDataWeightedHistogramModule.
+ *
+ * \ingroup module_analysisdata
+ */
+class BasicHistogramImpl
+{
+ public:
+ //! Smart pointer to manage an BasicAverageHistogramModule object.
+ typedef boost::shared_ptr<BasicAverageHistogramModule>
+ BasicAverageHistogramModulePointer;
+
+ BasicHistogramImpl();
+ //! Creates an histogram impl with defined bin parameters.
+ explicit BasicHistogramImpl(const AnalysisHistogramSettings &settings);
+ ~BasicHistogramImpl();
+
+ /*! \brief
+ * (Re)initializes the histogram from settings.
+ */
+ void init(const AnalysisHistogramSettings &settings);
+ /*! \brief
+ * Initializes data storage frame when a new frame starts.
+ */
+ void initFrame(AnalysisDataStorageFrame *frame);
+
+ //! Storage implementation object.
+ AnalysisDataStorage storage_;
+ //! Settings for the histogram object.
+ AnalysisHistogramSettings settings_;
+ //! Averager module.
+ BasicAverageHistogramModulePointer averager_;
+};
+
BasicHistogramImpl::BasicHistogramImpl()
: averager_(new BasicAverageHistogramModule())
{
+++ /dev/null
-/*
- *
- * This source code is part of
- *
- * G R O M A C S
- *
- * GROningen MAchine for Chemical Simulations
- *
- * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
- * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2009, The GROMACS development team,
- * check out http://www.gromacs.org for more information.
-
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * If you want to redistribute modifications, please consider that
- * scientific software is very special. Version control is crucial -
- * bugs must be traceable. We will be happy to consider code for
- * inclusion in the official distribution, but derived work must not
- * be called official GROMACS. Details are found in the README & COPYING
- * files - if they are missing, get the official version at www.gromacs.org.
- *
- * To help us fund GROMACS development, we humbly ask that you cite
- * the papers on the package - you can find them in the top README file.
- *
- * For more info, check our website at http://www.gromacs.org
- */
-/*! \internal \file
- * \brief
- * Declares private implementation class for gmx::AbstractPlotModule.
- *
- * \author Teemu Murtola <teemu.murtola@cbr.su.se>
- */
-#ifndef GMX_ANALYSISDATA_MODULES_PLOT_IMPL_H
-#define GMX_ANALYSISDATA_MODULES_PLOT_IMPL_H
-
-#include <string>
-#include <vector>
-
-#include "plot.h"
-
-namespace gmx
-{
-
-class Options;
-
-class AbstractPlotModule::Impl
-{
- public:
- explicit Impl(const AnalysisDataPlotSettings &settings);
- ~Impl();
-
- void closeFile();
-
- AnalysisDataPlotSettings settings;
- std::string fnm;
- FILE *fp;
-
- bool bPlain;
- bool bOmitX;
- std::string title;
- std::string subtitle;
- std::string xlabel;
- std::string ylabel;
- std::vector<std::string> leg;
- char xfmt[15];
- char yfmt[15];
- real xscale;
-};
-
-} // namespace gmx
-
-#endif
#include "gromacs/utility/format.h"
#include "gromacs/utility/gmxassert.h"
-#include "plot-impl.h"
-
static const char *const g_plotFormats[] = {
"none", "xmgrace", "xmgr", NULL
};
* AbstractPlotModule::Impl
*/
+class AbstractPlotModule::Impl
+{
+ public:
+ explicit Impl(const AnalysisDataPlotSettings &settings);
+ ~Impl();
+
+ void closeFile();
+
+ AnalysisDataPlotSettings settings;
+ std::string fnm;
+ FILE *fp;
+
+ bool bPlain;
+ bool bOmitX;
+ std::string title;
+ std::string subtitle;
+ std::string xlabel;
+ std::string ylabel;
+ std::vector<std::string> leg;
+ char xfmt[15];
+ char yfmt[15];
+ real xscale;
+};
+
AbstractPlotModule::Impl::Impl(const AnalysisDataPlotSettings &settings)
: settings(settings), fp(NULL), bPlain(false), bOmitX(false), xscale(1.0)
{
+++ /dev/null
-/*
- *
- * This source code is part of
- *
- * G R O M A C S
- *
- * GROningen MAchine for Chemical Simulations
- *
- * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
- * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2009, The GROMACS development team,
- * check out http://www.gromacs.org for more information.
-
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * If you want to redistribute modifications, please consider that
- * scientific software is very special. Version control is crucial -
- * bugs must be traceable. We will be happy to consider code for
- * inclusion in the official distribution, but derived work must not
- * be called official GROMACS. Details are found in the README & COPYING
- * files - if they are missing, get the official version at www.gromacs.org.
- *
- * To help us fund GROMACS development, we humbly ask that you cite
- * the papers on the package - you can find them in the top README file.
- *
- * For more info, check our website at http://www.gromacs.org
- */
-/*! \internal \file
- * \brief
- * Declares private implementation class for gmx::CommandLineHelpWriter.
- *
- * \author Teemu Murtola <teemu.murtola@cbr.su.se>
- * \ingroup module_commandline
- */
-#ifndef GMX_COMMANDLINE_CMDLINEHELPWRITER_IMPL_H
-#define GMX_COMMANDLINE_CMDLINEHELPWRITER_IMPL_H
-
-#include <string>
-
-#include "cmdlinehelpwriter.h"
-
-namespace gmx
-{
-
-class Options;
-
-/*! \internal \brief
- * Private implementation class for CommandLineHelpWriter.
- *
- * \ingroup module_commandline
- */
-class CommandLineHelpWriter::Impl
-{
- public:
- //! Sets the Options object to use for generating help.
- explicit Impl(const Options &options);
-
- //! Options object to use for generating help.
- const Options &options_;
- //! Time unit to show in descriptions.
- std::string timeUnit_;
- //! Whether to write descriptions to output.
- bool bShowDescriptions_;
- //! Whether to write hidden options to output.
- bool bShowHidden_;
-};
-
-} // namespace gmx
-
-#endif
#include "gromacs/utility/file.h"
#include "gromacs/utility/format.h"
-#include "cmdlinehelpwriter-impl.h"
-
namespace gmx
{
* CommandLineHelpWriter::Impl
*/
+/*! \internal \brief
+ * Private implementation class for CommandLineHelpWriter.
+ *
+ * \ingroup module_commandline
+ */
+class CommandLineHelpWriter::Impl
+{
+ public:
+ //! Sets the Options object to use for generating help.
+ explicit Impl(const Options &options);
+
+ //! Options object to use for generating help.
+ const Options &options_;
+ //! Time unit to show in descriptions.
+ std::string timeUnit_;
+ //! Whether to write descriptions to output.
+ bool bShowDescriptions_;
+ //! Whether to write hidden options to output.
+ bool bShowHidden_;
+};
+
CommandLineHelpWriter::Impl::Impl(const Options &options)
: options_(options), timeUnit_(TimeUnitManager().timeUnitAsString()),
bShowDescriptions_(false), bShowHidden_(false)
+++ /dev/null
-/*
- *
- * This source code is part of
- *
- * G R O M A C S
- *
- * GROningen MAchine for Chemical Simulations
- *
- * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
- * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2009, The GROMACS development team,
- * check out http://www.gromacs.org for more information.
-
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * If you want to redistribute modifications, please consider that
- * scientific software is very special. Version control is crucial -
- * bugs must be traceable. We will be happy to consider code for
- * inclusion in the official distribution, but derived work must not
- * be called official GROMACS. Details are found in the README & COPYING
- * files - if they are missing, get the official version at www.gromacs.org.
- *
- * To help us fund GROMACS development, we humbly ask that you cite
- * the papers on the package - you can find them in the top README file.
- *
- * For more info, check our website at http://www.gromacs.org
- */
-/*! \internal \file
- * \brief
- * Declares private implementation class for gmx::CommandLineParser.
- *
- * \author Teemu Murtola <teemu.murtola@cbr.su.se>
- * \ingroup module_commandline
- */
-#ifndef GMX_COMMANDLINE_CMDLINEPARSER_IMPL_H
-#define GMX_COMMANDLINE_CMDLINEPARSER_IMPL_H
-
-#include "cmdlineparser.h"
-#include "../options/optionsassigner.h"
-
-namespace gmx
-{
-
-/*! \internal \brief
- * Private implementation class for CommandLineParser.
- *
- * \ingroup module_commandline
- */
-class CommandLineParser::Impl
-{
- public:
- //! Sets the options object to parse to.
- explicit Impl(Options *options);
-
- //! Helper object for assigning the options.
- OptionsAssigner _assigner;
-};
-
-} // namespace gmx
-
-#endif
#include "gromacs/utility/exceptions.h"
#include "gromacs/utility/messagestringcollector.h"
-#include "cmdlineparser-impl.h"
-
namespace gmx
{
* CommandLineParser::Impl
*/
+/*! \internal \brief
+ * Private implementation class for CommandLineParser.
+ *
+ * \ingroup module_commandline
+ */
+class CommandLineParser::Impl
+{
+ public:
+ //! Sets the options object to parse to.
+ explicit Impl(Options *options);
+
+ //! Helper object for assigning the options.
+ OptionsAssigner _assigner;
+};
+
CommandLineParser::Impl::Impl(Options *options)
: _assigner(options)
{
+++ /dev/null
-/*
- *
- * This source code is part of
- *
- * G R O M A C S
- *
- * GROningen MAchine for Chemical Simulations
- *
- * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
- * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2009, The GROMACS development team,
- * check out http://www.gromacs.org for more information.
-
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * If you want to redistribute modifications, please consider that
- * scientific software is very special. Version control is crucial -
- * bugs must be traceable. We will be happy to consider code for
- * inclusion in the official distribution, but derived work must not
- * be called official GROMACS. Details are found in the README & COPYING
- * files - if they are missing, get the official version at www.gromacs.org.
- *
- * To help us fund GROMACS development, we humbly ask that you cite
- * the papers on the package - you can find them in the top README file.
- *
- * For more info, check our website at http://www.gromacs.org
- */
-/*! \internal \file
- * \brief
- * Declares private implementation class for gmx::OptionsAssigner.
- *
- * \author Teemu Murtola <teemu.murtola@cbr.su.se>
- * \ingroup module_options
- */
-#ifndef GMX_OPTIONS_OPTIONSASSIGNER_IMPL_H
-#define GMX_OPTIONS_OPTIONSASSIGNER_IMPL_H
-
-#include <vector>
-
-#include "optionsassigner.h"
-
-namespace gmx
-{
-
-class AbstractOptionStorage;
-class Options;
-
-/*! \internal \brief
- * Private implementation class for OptionsAssigner.
- *
- * \ingroup module_options
- */
-class OptionsAssigner::Impl
-{
- public:
- //! Possible flags for controlling assignment behavior.
- enum Flag
- {
- //! Recognize boolean option "name" also as "noname".
- efAcceptBooleanNoPrefix = 1<<0,
- //! Look for options in all sections, not just the current one.
- efNoStrictSectioning = 1<<1,
- };
- //! Sets the option object to assign to.
- Impl(Options *options);
-
- //! Sets or clears the given flag.
- void setFlag(Flag flag, bool bSet);
-
- //! Returns true if the given flag is set.
- bool hasFlag(Flag flag) const { return _flags & flag; }
- //! Returns true if a subsection has been set.
- bool inSubSection() const { return _sectionStack.size() > 1; }
- //! Returns the Options object for the current section.
- Options ¤tSection() const { return *_sectionStack.back(); }
- /*! \brief
- * Finds an option by the given name.
- *
- * \param[in] name Name of the option to look for.
- * \returns Pointer to the found option, or NULL if none found.
- *
- * This function takes into account the flags specified, and may change
- * the internal state of the assigner to match the option found.
- * If no option is found, the internal state is not modified.
- */
- AbstractOptionStorage *findOption(const char *name);
-
- //! Options object to assign to.
- Options &_options;
- //! Flags that control assignment behavior.
- unsigned long _flags;
- /*! \brief
- * List of (sub)sections being assigned to.
- *
- * The first element always points to \a _options.
- */
- std::vector<Options *> _sectionStack;
- //! Current option being assigned to, or NULL if none.
- AbstractOptionStorage *_currentOption;
- //! Number of values assigned so far to the current option.
- int _currentValueCount;
- //! If true, a "no" prefix was given for the current boolean option.
- bool _reverseBoolean;
-};
-
-} // namespace gmx
-
-#endif
#include "gromacs/utility/exceptions.h"
#include "gromacs/utility/gmxassert.h"
-#include "optionsassigner-impl.h"
#include "options-impl.h"
namespace gmx
* OptionsAssigner::Impl
*/
+/*! \internal \brief
+ * Private implementation class for OptionsAssigner.
+ *
+ * \ingroup module_options
+ */
+class OptionsAssigner::Impl
+{
+ public:
+ //! Possible flags for controlling assignment behavior.
+ enum Flag
+ {
+ //! Recognize boolean option "name" also as "noname".
+ efAcceptBooleanNoPrefix = 1<<0,
+ //! Look for options in all sections, not just the current one.
+ efNoStrictSectioning = 1<<1,
+ };
+ //! Sets the option object to assign to.
+ Impl(Options *options);
+
+ //! Sets or clears the given flag.
+ void setFlag(Flag flag, bool bSet);
+
+ //! Returns true if the given flag is set.
+ bool hasFlag(Flag flag) const { return _flags & flag; }
+ //! Returns true if a subsection has been set.
+ bool inSubSection() const { return _sectionStack.size() > 1; }
+ //! Returns the Options object for the current section.
+ Options ¤tSection() const { return *_sectionStack.back(); }
+ /*! \brief
+ * Finds an option by the given name.
+ *
+ * \param[in] name Name of the option to look for.
+ * \returns Pointer to the found option, or NULL if none found.
+ *
+ * This function takes into account the flags specified, and may change
+ * the internal state of the assigner to match the option found.
+ * If no option is found, the internal state is not modified.
+ */
+ AbstractOptionStorage *findOption(const char *name);
+
+ //! Options object to assign to.
+ Options &_options;
+ //! Flags that control assignment behavior.
+ unsigned long _flags;
+ /*! \brief
+ * List of (sub)sections being assigned to.
+ *
+ * The first element always points to \a _options.
+ */
+ std::vector<Options *> _sectionStack;
+ //! Current option being assigned to, or NULL if none.
+ AbstractOptionStorage *_currentOption;
+ //! Number of values assigned so far to the current option.
+ int _currentValueCount;
+ //! If true, a "no" prefix was given for the current boolean option.
+ bool _reverseBoolean;
+};
+
OptionsAssigner::Impl::Impl(Options *options)
: _options(*options), _flags(0), _currentOption(NULL),
_currentValueCount(0), _reverseBoolean(false)
+++ /dev/null
-/*
- *
- * This source code is part of
- *
- * G R O M A C S
- *
- * GROningen MAchine for Chemical Simulations
- *
- * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
- * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2009, The GROMACS development team,
- * check out http://www.gromacs.org for more information.
-
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * If you want to redistribute modifications, please consider that
- * scientific software is very special. Version control is crucial -
- * bugs must be traceable. We will be happy to consider code for
- * inclusion in the official distribution, but derived work must not
- * be called official GROMACS. Details are found in the README & COPYING
- * files - if they are missing, get the official version at www.gromacs.org.
- *
- * To help us fund GROMACS development, we humbly ask that you cite
- * the papers on the package - you can find them in the top README file.
- *
- * For more info, check our website at http://www.gromacs.org
- */
-/*! \internal \file
- * \brief
- * Declares private implementation classes for gmx::TrajectoryAnalysisModule
- * and gmx::TrajectoryAnalysisModuleData.
- *
- * \ingroup module_trajectoryanalysis
- * \author Teemu Murtola <teemu.murtola@cbr.su.se>
- */
-#ifndef GMX_TRAJECTORYANALYSIS_ANALYSISMODULE_IMPL_H
-#define GMX_TRAJECTORYANALYSIS_ANALYSISMODULE_IMPL_H
-
-#include <map>
-#include <string>
-#include <vector>
-
-#include "analysismodule.h"
-
-namespace gmx
-{
-
-class AbstractAnalysisData;
-class AnalysisData;
-class AnalysisDataHandle;
-
-/*! \internal \brief
- * Private implementation class for TrajectoryAnalysisModuleData.
- *
- * \ingroup module_trajectoryanalysis
- */
-class TrajectoryAnalysisModuleData::Impl
-{
- public:
- //! Container that associates a data handle to its AnalysisData object.
- typedef std::map<const AnalysisData *, AnalysisDataHandle>
- HandleContainer;
-
- //! \copydoc TrajectoryAnalysisModuleData::TrajectoryAnalysisModuleData()
- Impl(TrajectoryAnalysisModule *module,
- const AnalysisDataParallelOptions &opt,
- const SelectionCollection &selections);
- ~Impl();
-
- //! Keeps a data handle for each AnalysisData object.
- HandleContainer _handles;
- //! Stores thread-local selections.
- const SelectionCollection &_selections;
-};
-
-/*! \internal \brief
- * Private implementation class for TrajectoryAnalysisModule.
- *
- * \ingroup module_trajectoryanalysis
- */
-class TrajectoryAnalysisModule::Impl
-{
- public:
- //! Container that associates a data set with its name.
- typedef std::map<std::string, AbstractAnalysisData *> DatasetContainer;
- //! Container that associates a AnalysisData object with its name.
- typedef std::map<std::string, AnalysisData *> AnalysisDatasetContainer;
-
- //! List of registered data set names.
- std::vector<std::string> _datasetNames;
- /*! \brief
- * Keeps all registered data sets.
- *
- * This container also includes datasets from \a _analysisDatasets.
- */
- DatasetContainer _datasets;
- //! Keeps registered AnalysisData objects.
- AnalysisDatasetContainer _analysisDatasets;
-};
-
-/*! \internal \brief
- * Basic thread-local trajectory analysis data storage class.
- *
- * Most simple tools should only require data handles and selections to be
- * thread-local, so this class implements just that.
- *
- * \ingroup module_trajectoryanalysis
- */
-class TrajectoryAnalysisModuleDataBasic : public TrajectoryAnalysisModuleData
-{
- public:
- /*! \brief
- * Initializes thread-local storage for data handles and selections.
- *
- * \param[in] module Analysis module to use for data objects.
- * \param[in] opt Data parallelization options.
- * \param[in] selections Thread-local selection collection.
- */
- TrajectoryAnalysisModuleDataBasic(TrajectoryAnalysisModule *module,
- const AnalysisDataParallelOptions &opt,
- const SelectionCollection &selections);
-
- virtual void finish();
-};
-
-} // namespace gmx
-
-#endif
#include "gromacs/utility/exceptions.h"
#include "gromacs/utility/gmxassert.h"
-#include "analysismodule-impl.h"
-
namespace gmx
{
+/********************************************************************
+ * TrajectoryAnalysisModule::Impl
+ */
+
+/*! \internal \brief
+ * Private implementation class for TrajectoryAnalysisModule.
+ *
+ * \ingroup module_trajectoryanalysis
+ */
+class TrajectoryAnalysisModule::Impl
+{
+ public:
+ //! Container that associates a data set with its name.
+ typedef std::map<std::string, AbstractAnalysisData *> DatasetContainer;
+ //! Container that associates a AnalysisData object with its name.
+ typedef std::map<std::string, AnalysisData *> AnalysisDatasetContainer;
+
+ //! List of registered data set names.
+ std::vector<std::string> _datasetNames;
+ /*! \brief
+ * Keeps all registered data sets.
+ *
+ * This container also includes datasets from \a _analysisDatasets.
+ */
+ DatasetContainer _datasets;
+ //! Keeps registered AnalysisData objects.
+ AnalysisDatasetContainer _analysisDatasets;
+};
+
/********************************************************************
* TrajectoryAnalysisModuleData::Impl
*/
+/*! \internal \brief
+ * Private implementation class for TrajectoryAnalysisModuleData.
+ *
+ * \ingroup module_trajectoryanalysis
+ */
+class TrajectoryAnalysisModuleData::Impl
+{
+ public:
+ //! Container that associates a data handle to its AnalysisData object.
+ typedef std::map<const AnalysisData *, AnalysisDataHandle>
+ HandleContainer;
+
+ //! \copydoc TrajectoryAnalysisModuleData::TrajectoryAnalysisModuleData()
+ Impl(TrajectoryAnalysisModule *module,
+ const AnalysisDataParallelOptions &opt,
+ const SelectionCollection &selections);
+
+ //! Keeps a data handle for each AnalysisData object.
+ HandleContainer _handles;
+ //! Stores thread-local selections.
+ const SelectionCollection &_selections;
+};
+
TrajectoryAnalysisModuleData::Impl::Impl(
TrajectoryAnalysisModule *module,
const AnalysisDataParallelOptions &opt,
}
}
-TrajectoryAnalysisModuleData::Impl::~Impl()
-{
-}
-
/********************************************************************
* TrajectoryAnalysisModuleData
/********************************************************************
* TrajectoryAnalysisModuleDataBasic
*/
+
+namespace
+{
+
+/*! \internal \brief
+ * Basic thread-local trajectory analysis data storage class.
+ *
+ * Most simple tools should only require data handles and selections to be
+ * thread-local, so this class implements just that.
+ *
+ * \ingroup module_trajectoryanalysis
+ */
+class TrajectoryAnalysisModuleDataBasic : public TrajectoryAnalysisModuleData
+{
+ public:
+ /*! \brief
+ * Initializes thread-local storage for data handles and selections.
+ *
+ * \param[in] module Analysis module to use for data objects.
+ * \param[in] opt Data parallelization options.
+ * \param[in] selections Thread-local selection collection.
+ */
+ TrajectoryAnalysisModuleDataBasic(TrajectoryAnalysisModule *module,
+ const AnalysisDataParallelOptions &opt,
+ const SelectionCollection &selections);
+
+ virtual void finish();
+};
+
TrajectoryAnalysisModuleDataBasic::TrajectoryAnalysisModuleDataBasic(
TrajectoryAnalysisModule *module,
const AnalysisDataParallelOptions &opt,
finishDataHandles();
}
+} // namespace
+
/********************************************************************
* TrajectoryAnalysisModule
+++ /dev/null
-/*
- *
- * This source code is part of
- *
- * G R O M A C S
- *
- * GROningen MAchine for Chemical Simulations
- *
- * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
- * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2009, The GROMACS development team,
- * check out http://www.gromacs.org for more information.
-
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * If you want to redistribute modifications, please consider that
- * scientific software is very special. Version control is crucial -
- * bugs must be traceable. We will be happy to consider code for
- * inclusion in the official distribution, but derived work must not
- * be called official GROMACS. Details are found in the README & COPYING
- * files - if they are missing, get the official version at www.gromacs.org.
- *
- * To help us fund GROMACS development, we humbly ask that you cite
- * the papers on the package - you can find them in the top README file.
- *
- * For more info, check our website at http://www.gromacs.org
- */
-/*! \internal \file
- * \brief
- * Declares private implementation class for gmx::test::MockAnalysisDataModule.
- *
- * \author Teemu Murtola <teemu.murtola@cbr.su.se>
- * \ingroup module_testutils
- */
-#ifndef GMX_TESTUTILS_MOCK_DATAMODULE_IMPL_H
-#define GMX_TESTUTILS_MOCK_DATAMODULE_IMPL_H
-
-#include "mock_datamodule.h"
-
-#include <boost/scoped_ptr.hpp>
-
-namespace gmx
-{
-namespace test
-{
-
-/*! \internal \brief
- * Private implementation class for gmx::test::MockAnalysisDataModule.
- *
- * \ingroup module_testutils
- */
-class MockAnalysisDataModule::Impl
-{
- public:
- //! Initializes a mock object with the given flags.
- explicit Impl(int flags);
-
- /*! \brief
- * Callback used to initialize reference data checks
- *
- * Called in response to dataStarted().
- * Records information about the source data for later use.
- */
- void startReferenceData(AbstractAnalysisData *data);
- /*! \brief
- * Callback used to check frame start against reference data.
- *
- * Called to check parameters and order of calls to frameStarted().
- * In addition to reference data checks, this method checks statically
- * that the new frame matches \a frameIndex_.
- */
- void startReferenceFrame(const AnalysisDataFrameHeader &header);
- /*! \brief
- * Callback used to check frame points against reference data.
- *
- * Called to check parameters and order of calls to pointsAdded().
- */
- void checkReferencePoints(const AnalysisDataPointSetRef &points);
- /*! \brief
- * Callback used to check frame finish against reference data.
- *
- * Called to check parameters and order of calls to frameFinished().
- * \a frameIndex_ is incremented here.
- */
- void finishReferenceFrame(const AnalysisDataFrameHeader &header);
-
- /*! \brief
- * Reference data checker to use for checking frames.
- *
- * Must be non-NULL if startReferenceFrame() is called.
- */
- boost::scoped_ptr<TestReferenceChecker> rootChecker_;
- /*! \brief
- * Reference data checker to use to check the current frame.
- *
- * Non-NULL between startReferenceFrame() and finishReferenceFrame()
- * calls.
- */
- boost::scoped_ptr<TestReferenceChecker> frameChecker_;
- //! Flags that will be returned by the mock module.
- int flags_;
- //! Index of the current/next frame.
- int frameIndex_;
- //! Number of columns in the source data (for reference checking only).
- int columnCount_;
-};
-
-} // namespace test
-} // namespace gmx
-
-#endif
#include "testutils/datatest.h"
#include "testutils/refdata.h"
-#include "mock_datamodule-impl.h"
-
namespace gmx
{
namespace test
* MockAnalysisDataModule::Impl
*/
+/*! \internal \brief
+ * Private implementation class for gmx::test::MockAnalysisDataModule.
+ *
+ * \ingroup module_testutils
+ */
+class MockAnalysisDataModule::Impl
+{
+ public:
+ //! Initializes a mock object with the given flags.
+ explicit Impl(int flags);
+
+ /*! \brief
+ * Callback used to initialize reference data checks
+ *
+ * Called in response to dataStarted().
+ * Records information about the source data for later use.
+ */
+ void startReferenceData(AbstractAnalysisData *data);
+ /*! \brief
+ * Callback used to check frame start against reference data.
+ *
+ * Called to check parameters and order of calls to frameStarted().
+ * In addition to reference data checks, this method checks statically
+ * that the new frame matches \a frameIndex_.
+ */
+ void startReferenceFrame(const AnalysisDataFrameHeader &header);
+ /*! \brief
+ * Callback used to check frame points against reference data.
+ *
+ * Called to check parameters and order of calls to pointsAdded().
+ */
+ void checkReferencePoints(const AnalysisDataPointSetRef &points);
+ /*! \brief
+ * Callback used to check frame finish against reference data.
+ *
+ * Called to check parameters and order of calls to frameFinished().
+ * \a frameIndex_ is incremented here.
+ */
+ void finishReferenceFrame(const AnalysisDataFrameHeader &header);
+
+ /*! \brief
+ * Reference data checker to use for checking frames.
+ *
+ * Must be non-NULL if startReferenceFrame() is called.
+ */
+ boost::scoped_ptr<TestReferenceChecker> rootChecker_;
+ /*! \brief
+ * Reference data checker to use to check the current frame.
+ *
+ * Non-NULL between startReferenceFrame() and finishReferenceFrame()
+ * calls.
+ */
+ boost::scoped_ptr<TestReferenceChecker> frameChecker_;
+ //! Flags that will be returned by the mock module.
+ int flags_;
+ //! Index of the current/next frame.
+ int frameIndex_;
+ //! Number of columns in the source data (for reference checking only).
+ int columnCount_;
+};
+
namespace
{
+++ /dev/null
-/*
- *
- * This source code is part of
- *
- * G R O M A C S
- *
- * GROningen MAchine for Chemical Simulations
- *
- * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
- * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2009, The GROMACS development team,
- * check out http://www.gromacs.org for more information.
-
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * If you want to redistribute modifications, please consider that
- * scientific software is very special. Version control is crucial -
- * bugs must be traceable. We will be happy to consider code for
- * inclusion in the official distribution, but derived work must not
- * be called official GROMACS. Details are found in the README & COPYING
- * files - if they are missing, get the official version at www.gromacs.org.
- *
- * To help us fund GROMACS development, we humbly ask that you cite
- * the papers on the package - you can find them in the top README file.
- *
- * For more info, check our website at http://www.gromacs.org
- */
-/*! \internal \file
- * \brief
- * Declares private implementation class for gmx::test::TestReferenceData.
- *
- * \author Teemu Murtola <teemu.murtola@cbr.su.se>
- * \ingroup module_testutils
- */
-#ifndef GMX_TESTUTILS_REFDATA_IMPL_H
-#define GMX_TESTUTILS_REFDATA_IMPL_H
-
-#include <string>
-
-#include <libxml/parser.h>
-
-#include "testutils/refdata.h"
-
-namespace gmx
-{
-namespace test
-{
-
-/*! \internal \brief
- * Private implementation class for TestReferenceData.
- *
- * \ingroup module_testutils
- */
-class TestReferenceData::Impl
-{
- public:
- //! String constant for output XML version string.
- static const xmlChar * const cXmlVersion;
- //! String constant for XML stylesheet processing instruction name.
- static const xmlChar * const cXmlStyleSheetNodeName;
- //! String constant for XML stylesheet reference.
- static const xmlChar * const cXmlStyleSheetContent;
- //! String constant for naming the root XML element.
- static const xmlChar * const cRootNodeName;
-
- //! Initializes a checker in the given mode.
- explicit Impl(ReferenceDataMode mode);
- ~Impl();
-
- //! Full path of the reference data file.
- std::string _fullFilename;
- /*! \brief
- * XML document for the reference data.
- *
- * May be NULL if there was an I/O error in initialization.
- */
- xmlDocPtr _refDoc;
- /*! \brief
- * Whether the reference data is being written (true) or compared
- * (false).
- */
- bool _bWrite;
- /*! \brief
- * Whether any reference checkers have been created for this data.
- */
- bool _bInUse;
-};
-
-
-/*! \internal \brief
- * Private implementation class for TestReferenceChecker.
- *
- * \ingroup module_testutils
- */
-class TestReferenceChecker::Impl
-{
- public:
- //! String constant for naming XML elements for boolean values.
- static const xmlChar * const cBooleanNodeName;
- //! String constant for naming XML elements for string values.
- static const xmlChar * const cStringNodeName;
- //! String constant for naming XML elements for integer values.
- static const xmlChar * const cIntegerNodeName;
- //! String constant for naming XML elements for floating-point values.
- static const xmlChar * const cRealNodeName;
- //! String constant for naming XML attribute for value identifiers.
- static const xmlChar * const cIdAttrName;
- //! String constant for naming compounds for vectors.
- static const char * const cVectorType;
- //! String constant for naming compounds for sequences.
- static const char * const cSequenceType;
- //! String constant for value identifier for sequence length.
- static const char * const cSequenceLengthName;
-
- //! Creates a checker that does nothing.
- explicit Impl(bool bWrite);
- //! Creates a checker with a given root node.
- Impl(const std::string &path, xmlNodePtr rootNode, bool bWrite);
-
- //! Returns a string for SCOPED_TRACE() for checking element \p id.
- std::string traceString(const char *id) const;
- //! Returns the path of this checker with \p id appended.
- std::string appendPath(const char *id) const;
-
- /*! \brief
- * Finds a reference data node.
- *
- * \param[in] name Type of node to find (can be NULL, in which case
- * any type is matched).
- * \param[in] id Unique identifier of the node (can be NULL, in
- * which case the next node without an id is matched).
- * \returns Matching node, or NULL if no matching node found.
- *
- * Searches for a node in the reference data that matches the given
- * \p name and \p id. Searching starts from the node that follows the
- * previously matched node (relevant for performance, and if there are
- * duplicate ids or nodes without ids). Note that the match pointer is
- * not updated by this method.
- */
- xmlNodePtr findNode(const xmlChar *name, const char *id) const;
- /*! \brief
- * Finds/creates a reference data node to match against.
- *
- * \param[in] name Type of node to find.
- * \param[in] id Unique identifier of the node (can be NULL, in
- * which case the next node without an id is matched).
- * \returns Matching node, or NULL if no matching node found
- * (NULL is never returned in write mode).
- * \throws TestException if node creation fails in write mode.
- *
- * Finds a node using findNode() and updates the match pointer is a
- * match is found. If a match is not found, the method returns NULL in
- * read mode and creates a new node in write mode. If the creation
- * fails in write mode, throws.
- */
- xmlNodePtr findOrCreateNode(const xmlChar *name, const char *id);
- /*! \brief
- * Helper method for checking a reference data value.
- *
- * \param[in] name Type of node to find.
- * \param[in] id Unique identifier of the node (can be NULL, in
- * which case the next node without an id is matched).
- * \param[in] value String value of the value to be compared.
- * \param[out] bFound true if a matchin value was found.
- * \returns String value for the reference value.
- * \throws TestException if node creation fails in write mode.
- *
- * Performs common tasks in checking a reference value:
- * finding/creating the correct XML node and reading/writing its string
- * value. Caller is responsible for converting the value to and from
- * string where necessary and performing the actual comparison.
- *
- * In read mode, if a value is not found, adds a Google Test failure
- * and returns an empty string. If the reference value is found,
- * returns it (\p value is not used in this case).
- *
- * In write mode, creates the node if it is not found, sets its value
- * as \p value and returns \p value.
- */
- std::string processItem(const xmlChar *name, const char *id,
- const char *value, bool *bFound);
- //! Convenience wrapper that takes a std::string.
- std::string processItem(const xmlChar *name, const char *id,
- const std::string &value, bool *bFound);
- /*! \brief
- * Whether the checker should ignore all validation calls.
- *
- * This is used to ignore any calls within compounds for which
- * reference data could not be found, such that only one error is
- * issued for the missing compound, instead of every individual value.
- */
- bool shouldIgnore() const;
-
- /*! \brief
- * Human-readable path to the root node of this checker.
- *
- * For the root checker, this will be "/", and for each compound, the
- * id of the compound is added. Used for reporting comparison
- * mismatches.
- */
- std::string _path;
- /*! \brief
- * Current node under which reference data is searched.
- *
- * Points to either the root of TestReferenceData::Impl::_refDoc, or to
- * a compound node.
- *
- * Can be NULL, in which case this checker does nothing (doesn't even
- * report errors, see shouldIgnore()).
- */
- xmlNodePtr _currNode;
- /*! \brief
- * Points to a child of \a _currNode where the next search should start.
- *
- * On initialization, points to the first child of \a _currNode. After
- * every check, is updated to point to the node following the one
- * found, with possible wrapping.
- *
- * Is NULL if and only if \a _currNode contains no children.
- * Otherwise, always points to a direct child of \a _currNode.
- */
- xmlNodePtr _nextSearchNode;
- /*! \brief
- * Whether the reference data is being written (true) or compared
- * (false).
- */
- bool _bWrite;
- /*! \brief
- * Current number of unnamed elements in a sequence.
- *
- * It is the index of the next added unnamed element.
- */
- int _seqIndex;
-};
-
-} // namespace test
-} // namespace gmx
-
-#endif
#include "testutils/datapath.h"
#include "testutils/testexceptions.h"
-#include "refdata-impl.h"
-
namespace
{
* TestReferenceData::Impl
*/
+/*! \internal \brief
+ * Private implementation class for TestReferenceData.
+ *
+ * \ingroup module_testutils
+ */
+class TestReferenceData::Impl
+{
+ public:
+ //! String constant for output XML version string.
+ static const xmlChar * const cXmlVersion;
+ //! String constant for XML stylesheet processing instruction name.
+ static const xmlChar * const cXmlStyleSheetNodeName;
+ //! String constant for XML stylesheet reference.
+ static const xmlChar * const cXmlStyleSheetContent;
+ //! String constant for naming the root XML element.
+ static const xmlChar * const cRootNodeName;
+
+ //! Initializes a checker in the given mode.
+ explicit Impl(ReferenceDataMode mode);
+ ~Impl();
+
+ //! Full path of the reference data file.
+ std::string _fullFilename;
+ /*! \brief
+ * XML document for the reference data.
+ *
+ * May be NULL if there was an I/O error in initialization.
+ */
+ xmlDocPtr _refDoc;
+ /*! \brief
+ * Whether the reference data is being written (true) or compared
+ * (false).
+ */
+ bool _bWrite;
+ /*! \brief
+ * Whether any reference checkers have been created for this data.
+ */
+ bool _bInUse;
+};
+
const xmlChar * const TestReferenceData::Impl::cXmlVersion =
(const xmlChar *)"1.0";
const xmlChar * const TestReferenceData::Impl::cXmlStyleSheetNodeName =
(const xmlChar *)"type=\"text/xsl\" href=\"referencedata.xsl\"";
const xmlChar * const TestReferenceData::Impl::cRootNodeName =
(const xmlChar *)"ReferenceData";
-const xmlChar * const TestReferenceChecker::Impl::cBooleanNodeName =
- (const xmlChar *)"Bool";
-const xmlChar * const TestReferenceChecker::Impl::cStringNodeName =
- (const xmlChar *)"String";
-const xmlChar * const TestReferenceChecker::Impl::cIntegerNodeName =
- (const xmlChar *)"Int";
-const xmlChar * const TestReferenceChecker::Impl::cRealNodeName =
- (const xmlChar *)"Real";
-const xmlChar * const TestReferenceChecker::Impl::cIdAttrName =
- (const xmlChar *)"Name";
-const char * const TestReferenceChecker::Impl::cVectorType =
- "Vector";
-const char * const TestReferenceChecker::Impl::cSequenceType =
- "Sequence";
-const char * const TestReferenceChecker::Impl::cSequenceLengthName =
- "Length";
TestReferenceData::Impl::Impl(ReferenceDataMode mode)
* TestReferenceChecker::Impl
*/
+/*! \internal \brief
+ * Private implementation class for TestReferenceChecker.
+ *
+ * \ingroup module_testutils
+ */
+class TestReferenceChecker::Impl
+{
+ public:
+ //! String constant for naming XML elements for boolean values.
+ static const xmlChar * const cBooleanNodeName;
+ //! String constant for naming XML elements for string values.
+ static const xmlChar * const cStringNodeName;
+ //! String constant for naming XML elements for integer values.
+ static const xmlChar * const cIntegerNodeName;
+ //! String constant for naming XML elements for floating-point values.
+ static const xmlChar * const cRealNodeName;
+ //! String constant for naming XML attribute for value identifiers.
+ static const xmlChar * const cIdAttrName;
+ //! String constant for naming compounds for vectors.
+ static const char * const cVectorType;
+ //! String constant for naming compounds for sequences.
+ static const char * const cSequenceType;
+ //! String constant for value identifier for sequence length.
+ static const char * const cSequenceLengthName;
+
+ //! Creates a checker that does nothing.
+ explicit Impl(bool bWrite);
+ //! Creates a checker with a given root node.
+ Impl(const std::string &path, xmlNodePtr rootNode, bool bWrite);
+
+ //! Returns a string for SCOPED_TRACE() for checking element \p id.
+ std::string traceString(const char *id) const;
+ //! Returns the path of this checker with \p id appended.
+ std::string appendPath(const char *id) const;
+
+ /*! \brief
+ * Finds a reference data node.
+ *
+ * \param[in] name Type of node to find (can be NULL, in which case
+ * any type is matched).
+ * \param[in] id Unique identifier of the node (can be NULL, in
+ * which case the next node without an id is matched).
+ * \returns Matching node, or NULL if no matching node found.
+ *
+ * Searches for a node in the reference data that matches the given
+ * \p name and \p id. Searching starts from the node that follows the
+ * previously matched node (relevant for performance, and if there are
+ * duplicate ids or nodes without ids). Note that the match pointer is
+ * not updated by this method.
+ */
+ xmlNodePtr findNode(const xmlChar *name, const char *id) const;
+ /*! \brief
+ * Finds/creates a reference data node to match against.
+ *
+ * \param[in] name Type of node to find.
+ * \param[in] id Unique identifier of the node (can be NULL, in
+ * which case the next node without an id is matched).
+ * \returns Matching node, or NULL if no matching node found
+ * (NULL is never returned in write mode).
+ * \throws TestException if node creation fails in write mode.
+ *
+ * Finds a node using findNode() and updates the match pointer is a
+ * match is found. If a match is not found, the method returns NULL in
+ * read mode and creates a new node in write mode. If the creation
+ * fails in write mode, throws.
+ */
+ xmlNodePtr findOrCreateNode(const xmlChar *name, const char *id);
+ /*! \brief
+ * Helper method for checking a reference data value.
+ *
+ * \param[in] name Type of node to find.
+ * \param[in] id Unique identifier of the node (can be NULL, in
+ * which case the next node without an id is matched).
+ * \param[in] value String value of the value to be compared.
+ * \param[out] bFound true if a matchin value was found.
+ * \returns String value for the reference value.
+ * \throws TestException if node creation fails in write mode.
+ *
+ * Performs common tasks in checking a reference value:
+ * finding/creating the correct XML node and reading/writing its string
+ * value. Caller is responsible for converting the value to and from
+ * string where necessary and performing the actual comparison.
+ *
+ * In read mode, if a value is not found, adds a Google Test failure
+ * and returns an empty string. If the reference value is found,
+ * returns it (\p value is not used in this case).
+ *
+ * In write mode, creates the node if it is not found, sets its value
+ * as \p value and returns \p value.
+ */
+ std::string processItem(const xmlChar *name, const char *id,
+ const char *value, bool *bFound);
+ //! Convenience wrapper that takes a std::string.
+ std::string processItem(const xmlChar *name, const char *id,
+ const std::string &value, bool *bFound);
+ /*! \brief
+ * Whether the checker should ignore all validation calls.
+ *
+ * This is used to ignore any calls within compounds for which
+ * reference data could not be found, such that only one error is
+ * issued for the missing compound, instead of every individual value.
+ */
+ bool shouldIgnore() const;
+
+ /*! \brief
+ * Human-readable path to the root node of this checker.
+ *
+ * For the root checker, this will be "/", and for each compound, the
+ * id of the compound is added. Used for reporting comparison
+ * mismatches.
+ */
+ std::string _path;
+ /*! \brief
+ * Current node under which reference data is searched.
+ *
+ * Points to either the root of TestReferenceData::Impl::_refDoc, or to
+ * a compound node.
+ *
+ * Can be NULL, in which case this checker does nothing (doesn't even
+ * report errors, see shouldIgnore()).
+ */
+ xmlNodePtr _currNode;
+ /*! \brief
+ * Points to a child of \a _currNode where the next search should start.
+ *
+ * On initialization, points to the first child of \a _currNode. After
+ * every check, is updated to point to the node following the one
+ * found, with possible wrapping.
+ *
+ * Is NULL if and only if \a _currNode contains no children.
+ * Otherwise, always points to a direct child of \a _currNode.
+ */
+ xmlNodePtr _nextSearchNode;
+ /*! \brief
+ * Whether the reference data is being written (true) or compared
+ * (false).
+ */
+ bool _bWrite;
+ /*! \brief
+ * Current number of unnamed elements in a sequence.
+ *
+ * It is the index of the next added unnamed element.
+ */
+ int _seqIndex;
+};
+
+const xmlChar * const TestReferenceChecker::Impl::cBooleanNodeName =
+ (const xmlChar *)"Bool";
+const xmlChar * const TestReferenceChecker::Impl::cStringNodeName =
+ (const xmlChar *)"String";
+const xmlChar * const TestReferenceChecker::Impl::cIntegerNodeName =
+ (const xmlChar *)"Int";
+const xmlChar * const TestReferenceChecker::Impl::cRealNodeName =
+ (const xmlChar *)"Real";
+const xmlChar * const TestReferenceChecker::Impl::cIdAttrName =
+ (const xmlChar *)"Name";
+const char * const TestReferenceChecker::Impl::cVectorType =
+ "Vector";
+const char * const TestReferenceChecker::Impl::cSequenceType =
+ "Sequence";
+const char * const TestReferenceChecker::Impl::cSequenceLengthName =
+ "Length";
+
+
TestReferenceChecker::Impl::Impl(bool bWrite)
: _currNode(NULL), _nextSearchNode(NULL), _bWrite(bWrite), _seqIndex(0)
{