Apply clang-format to source tree
[alexxy/gromacs.git] / src / gromacs / analysisdata / analysisdata.cpp
index 9ad7136a43893b73beb42ebe0fbc011fc485ab2c..5fe4e5fa7b4cb2be77f2f60d39eb999334c402a4 100644 (file)
@@ -1,7 +1,8 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2010,2011,2012,2013,2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2010-2017, 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.
@@ -68,20 +69,17 @@ namespace internal
  */
 class AnalysisDataHandleImpl
 {
-    public:
-        //! Creates a handle associated with the given data object.
-        explicit AnalysisDataHandleImpl(AnalysisData *data)
-            : data_(*data), currentFrame_(nullptr)
-        {
-        }
-
-        //! The data object that this handle belongs to.
-        AnalysisData             &data_;
-        //! Current storage frame object, or NULL if no current frame.
-        AnalysisDataStorageFrame *currentFrame_;
+public:
+    //! Creates a handle associated with the given data object.
+    explicit AnalysisDataHandleImpl(AnalysisData* data) : data_(*data), currentFrame_(nullptr) {}
+
+    //! The data object that this handle belongs to.
+    AnalysisData& data_;
+    //! Current storage frame object, or NULL if no current frame.
+    AnalysisDataStorageFrame* currentFrame_;
 };
 
-}   // namespace internal
+} // namespace internal
 
 /********************************************************************
  * AnalysisData::Impl
@@ -94,41 +92,34 @@ class AnalysisDataHandleImpl
  */
 class AnalysisData::Impl
 {
-    public:
-        //! Smart pointer type to manage a data handle implementation.
-        typedef std::unique_ptr<internal::AnalysisDataHandleImpl>
-            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_;
+public:
+    //! Smart pointer type to manage a data handle implementation.
+    typedef std::unique_ptr<internal::AnalysisDataHandleImpl> 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
  */
 
-AnalysisData::AnalysisData()
-    : impl_(new Impl)
-{
-}
+AnalysisData::AnalysisData() : impl_(new Impl) {}
 
 
-AnalysisData::~AnalysisData()
-{
-}
+AnalysisData::~AnalysisData() {}
 
 
-void
-AnalysisData::setDataSetCount(int dataSetCount)
+void AnalysisData::setDataSetCount(int dataSetCount)
 {
     GMX_RELEASE_ASSERT(impl_->handles_.empty(),
                        "Cannot change data dimensionality after creating handles");
@@ -136,8 +127,7 @@ AnalysisData::setDataSetCount(int dataSetCount)
 }
 
 
-void
-AnalysisData::setColumnCount(int dataSet, int columnCount)
+void AnalysisData::setColumnCount(int dataSet, int columnCount)
 {
     GMX_RELEASE_ASSERT(impl_->handles_.empty(),
                        "Cannot change data dimensionality after creating handles");
@@ -145,24 +135,20 @@ AnalysisData::setColumnCount(int dataSet, int columnCount)
 }
 
 
-void
-AnalysisData::setMultipoint(bool bMultipoint)
+void AnalysisData::setMultipoint(bool bMultipoint)
 {
-    GMX_RELEASE_ASSERT(impl_->handles_.empty(),
-                       "Cannot change data type after creating handles");
+    GMX_RELEASE_ASSERT(impl_->handles_.empty(), "Cannot change data type after creating handles");
     AbstractAnalysisData::setMultipoint(bMultipoint);
 }
 
 
-int
-AnalysisData::frameCount() const
+int AnalysisData::frameCount() const
 {
     return impl_->storage_.frameCount();
 }
 
 
-AnalysisDataHandle
-AnalysisData::startData(const AnalysisDataParallelOptions &opt)
+AnalysisDataHandle AnalysisData::startData(const AnalysisDataParallelOptions& opt)
 {
     GMX_RELEASE_ASSERT(impl_->handles_.size() < static_cast<unsigned>(opt.parallelizationFactor()),
                        "Too many calls to startData() compared to provided options");
@@ -177,15 +163,13 @@ AnalysisData::startData(const AnalysisDataParallelOptions &opt)
 }
 
 
-void
-AnalysisData::finishFrameSerial(int frameIndex)
+void AnalysisData::finishFrameSerial(int frameIndex)
 {
     impl_->storage_.finishFrameSerial(frameIndex);
 }
 
 
-void
-AnalysisData::finishData(AnalysisDataHandle handle)
+void AnalysisData::finishData(AnalysisDataHandle handle)
 {
     Impl::HandleList::iterator i;
 
@@ -196,8 +180,7 @@ AnalysisData::finishData(AnalysisDataHandle handle)
             break;
         }
     }
-    GMX_RELEASE_ASSERT(i != impl_->handles_.end(),
-                       "finishData() called for an unknown handle");
+    GMX_RELEASE_ASSERT(i != impl_->handles_.end(), "finishData() called for an unknown handle");
 
     impl_->handles_.erase(i);
 
@@ -208,15 +191,13 @@ AnalysisData::finishData(AnalysisDataHandle handle)
 }
 
 
-AnalysisDataFrameRef
-AnalysisData::tryGetDataFrameInternal(int index) const
+AnalysisDataFrameRef AnalysisData::tryGetDataFrameInternal(int index) const
 {
     return impl_->storage_.tryGetDataFrame(index);
 }
 
 
-bool
-AnalysisData::requestStorageInternal(int nframes)
+bool AnalysisData::requestStorageInternal(int nframes)
 {
     return impl_->storage_.requestStorage(nframes);
 }
@@ -226,31 +207,22 @@ AnalysisData::requestStorageInternal(int nframes)
  * AnalysisDataHandle
  */
 
-AnalysisDataHandle::AnalysisDataHandle()
-    : impl_(nullptr)
-{
-}
+AnalysisDataHandle::AnalysisDataHandle() : impl_(nullptr) {}
 
 
-AnalysisDataHandle::AnalysisDataHandle(internal::AnalysisDataHandleImpl *impl)
-    : impl_(impl)
-{
-}
+AnalysisDataHandle::AnalysisDataHandle(internal::AnalysisDataHandleImpl* impl) : impl_(impl) {}
 
 
-void
-AnalysisDataHandle::startFrame(int index, real x, real dx)
+void AnalysisDataHandle::startFrame(int index, real x, real dx)
 {
     GMX_RELEASE_ASSERT(impl_ != nullptr, "Invalid data handle used");
     GMX_RELEASE_ASSERT(impl_->currentFrame_ == nullptr,
                        "startFrame() called twice without calling finishFrame()");
-    impl_->currentFrame_ =
-        &impl_->data_.impl_->storage_.startFrame(index, x, dx);
+    impl_->currentFrame_ = &impl_->data_.impl_->storage_.startFrame(index, x, dx);
 }
 
 
-void
-AnalysisDataHandle::selectDataSet(int index)
+void AnalysisDataHandle::selectDataSet(int index)
 {
     GMX_RELEASE_ASSERT(impl_ != nullptr, "Invalid data handle used");
     GMX_RELEASE_ASSERT(impl_->currentFrame_ != nullptr,
@@ -259,8 +231,7 @@ AnalysisDataHandle::selectDataSet(int index)
 }
 
 
-void
-AnalysisDataHandle::setPoint(int column, real value, bool bPresent)
+void AnalysisDataHandle::setPoint(int column, real value, bool bPresent)
 {
     GMX_RELEASE_ASSERT(impl_ != nullptr, "Invalid data handle used");
     GMX_RELEASE_ASSERT(impl_->currentFrame_ != nullptr,
@@ -269,8 +240,7 @@ AnalysisDataHandle::setPoint(int column, real value, bool bPresent)
 }
 
 
-void
-AnalysisDataHandle::setPoint(int column, real value, real error, bool bPresent)
+void AnalysisDataHandle::setPoint(int column, real value, real error, bool bPresent)
 {
     GMX_RELEASE_ASSERT(impl_ != nullptr, "Invalid data handle used");
     GMX_RELEASE_ASSERT(impl_->currentFrame_ != nullptr,
@@ -279,9 +249,7 @@ AnalysisDataHandle::setPoint(int column, real value, real error, bool bPresent)
 }
 
 
-void
-AnalysisDataHandle::setPoints(int firstColumn, int count, const real *values,
-                              bool bPresent)
+void AnalysisDataHandle::setPoints(int firstColumn, int count, const real* values, bool bPresent)
 {
     GMX_RELEASE_ASSERT(impl_ != nullptr, "Invalid data handle used");
     GMX_RELEASE_ASSERT(impl_->currentFrame_ != nullptr,
@@ -293,8 +261,7 @@ AnalysisDataHandle::setPoints(int firstColumn, int count, const real *values,
 }
 
 
-void
-AnalysisDataHandle::finishPointSet()
+void AnalysisDataHandle::finishPointSet()
 {
     GMX_RELEASE_ASSERT(impl_ != nullptr, "Invalid data handle used");
     GMX_RELEASE_ASSERT(impl_->data_.isMultipoint(),
@@ -305,20 +272,18 @@ AnalysisDataHandle::finishPointSet()
 }
 
 
-void
-AnalysisDataHandle::finishFrame()
+void AnalysisDataHandle::finishFrame()
 {
     GMX_RELEASE_ASSERT(impl_ != nullptr, "Invalid data handle used");
     GMX_RELEASE_ASSERT(impl_->currentFrame_ != nullptr,
                        "finishFrame() called without calling startFrame()");
-    AnalysisDataStorageFrame *frame = impl_->currentFrame_;
-    impl_->currentFrame_ = nullptr;
+    AnalysisDataStorageFrameframe = impl_->currentFrame_;
+    impl_->currentFrame_            = nullptr;
     frame->finishFrame();
 }
 
 
-void
-AnalysisDataHandle::finishData()
+void AnalysisDataHandle::finishData()
 {
     GMX_RELEASE_ASSERT(impl_ != nullptr, "Invalid data handle used");
     // Deletes the implementation pointer.