Update clang-tidy to clang version 8
[gromacs.git] / src / gromacs / restraint / manager.h
blob30b6bab3733d3d57c3a6c2cd413229f3f5a109e5
1 /*
2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2018,2019, by the GROMACS development team, led by
5 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 * and including many others, as listed in the AUTHORS file in the
7 * top-level source directory and at http://www.gromacs.org.
9 * GROMACS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GROMACS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with GROMACS; if not, see
21 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * If you want to redistribute modifications to GROMACS, please
25 * consider that scientific software is very special. Version
26 * control is crucial - bugs must be traceable. We will be happy to
27 * consider code for inclusion in the official distribution, but
28 * derived work must not be called official GROMACS. Details are found
29 * in the README & COPYING files - if they are missing, get the
30 * official version at http://www.gromacs.org.
32 * To help us fund GROMACS development, we humbly ask that you cite
33 * the research papers on the package. Check out http://www.gromacs.org.
36 #ifndef GROMACS_RESTRAINT_MANAGER_H
37 #define GROMACS_RESTRAINT_MANAGER_H
39 /*! \libinternal \file
40 * \brief Declare the Manager for restraint potentials.
42 * \author M. Eric Irrgang <ericirrgang@gmail.com>
44 * \inlibraryapi
45 * \ingroup module_restraint
48 #include <memory>
49 #include <mutex>
50 #include <string>
52 #include "gromacs/restraint/restraintpotential.h"
53 #include "gromacs/utility/basedefinitions.h"
55 struct t_commrec;
56 struct t_mdatoms;
57 struct pull_t;
59 namespace gmx
62 /*! \libinternal \ingroup module_restraint
63 * \brief Manage the Restraint potentials available for Molecular Dynamics.
65 * A simulation runner owns one manager resource to hold restraint objects used
66 * in the simulation. In the case of thread MPI simulations, multiple runner
67 * instances will have handles to the same underlying resource. With further
68 * factoring of the mdrun call stack, this facility can be combined with others
69 * into a simulation context object from which simulation code can retrieve
70 * support code for a user-configured simulation.
72 * Calling code provides the manager with a means to access the various required input data
73 * to be used when restraints are computed.
75 * \todo This should be generalized as work description and factory functions in Context.
77 class RestraintManager final
79 public:
80 //! Create new restraint manager resources with empty set of restraints.
81 RestraintManager();
83 ~RestraintManager();
85 /*!
86 * \brief Client code can access the shared resource by copying or moving a handle.
87 * \{
89 RestraintManager(const RestraintManager &/* unused */) = default;
90 RestraintManager &operator=(const RestraintManager & /* unused */) = default;
91 RestraintManager(RestraintManager &&) noexcept = default;
92 RestraintManager &operator=(RestraintManager && /* unused */) noexcept = default;
93 /*! \} */
95 /*!
96 * \brief Clear registered restraints and reset the manager.
98 void clear() noexcept;
101 * \brief Get the number of currently managed restraints.
103 * \return number of restraints.
105 * \internal
106 * Only considers the IRestraintPotential objects
108 unsigned long countRestraints() noexcept;
110 /*! \brief Obtain the ability to create a restraint MDModule
112 * Though the name is reminiscent of the evolving idea of a work specification, the
113 * Spec here is just a list of restraint modules.
115 * \param restraint shared ownership of a restraint potential interface.
116 * \param name key by which to reference the restraint.
118 void addToSpec(std::shared_ptr<gmx::IRestraintPotential> restraint,
119 const std::string &name);
122 * \brief Get a copy of the current set of restraints to be applied.
124 * This function is to be used when launching a simulation to get the
125 * restraint handles to bind, so it is not performance sensitive. A new
126 * vector is returned with each call because it is unspecified whether
127 * the set of handles point to the same objects on all threads or between
128 * calls to getRestraints.
130 * \return a copy of the list of restraint potentials.
132 std::vector< std::shared_ptr<IRestraintPotential> > getRestraints() const;
134 private:
135 class Impl;
136 //! Ownership of the shared reference to the global manager.
137 std::shared_ptr<Impl> instance_;
140 } // end namespace gmx
142 #endif //GROMACS_RESTRAINT_MANAGER_H