Allow more granularity for public interfaces in build tree.
[gromacs.git] / api / gmxapi / include / gmxapi / md / mdsignals.h
blob3aee6383b4e826f7f3c05e938e21f1a8cef1fca9
1 /*
2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2018,2019,2020, 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 GMXAPI_MDSIGNALS_H
37 #define GMXAPI_MDSIGNALS_H
39 /*!
40 * \file
41 * \brief Temporary infrastructure for signalling MD simulations.
43 * These interfaces are not considered to be part of the gmxapi spec, but will exist in 0.0.6 and
44 * possibly 0.0.7 until more abstract data flow is available to MD plugin developers, at which point
45 * any remaining functionality here will be moved to private implementation details.
47 * \ingroup gmxapi_md
50 #include <memory>
52 namespace gmxapi
55 /*!
56 * \brief Internal details of gmxapi MD functionality
58 namespace md
61 /*!
62 * \brief Symbolic signal slots for MD signalling.
64 * \see getMdrunnerSignal()
66 enum class signals
68 STOP
71 } // end namespace md
74 class SessionResources; // reference gmxapi/session/resources.h
76 /*!
77 * \brief Proxy for signalling function objects.
79 * Objects of this type are simple callables that issue a specific signal.
81 * \todo This class and its implementations should be replaced with a std::function.
83 * \ingroup gmxapi_md
85 class Signal
87 public:
88 //! \internal
89 class SignalImpl;
91 /*!
92 * \brief Construct by taking ownership of an implementation object.
94 * \param signal
96 explicit Signal(std::unique_ptr<SignalImpl> signal);
98 /*!
99 * \brief Object is trivially moveable.
101 * \{
103 Signal(Signal&& /*unused*/) noexcept;
104 Signal& operator=(Signal&& /*unused*/) noexcept;
105 //! \}
107 //! \cond
108 ~Signal();
109 //! \endcond
112 * \brief Signal interface is a function object that issues a signal when called.
114 * \todo replace with more concise named type based on std::function.
116 void operator()();
118 private:
119 //! Wrapped signaller.
120 std::unique_ptr<SignalImpl> impl_;
124 * \brief Get a function object that issues a signal to the currently active MD runner.
126 * For use during execution of extension code. E.g. within a MD simulation plugin
127 * during an MD step.
129 * \param resources non-null pointer to the active Session resources.
130 * \param signal type of signal the client would like to issue.
131 * \return Callable function object handle to issue a stop signal.
133 * \throws gmxapi::NotImplementedError for unknown values of signal.
134 * \throws gmxapi::UsageError for invalid resources argument.
136 * \ingroup gmxapi_md
138 Signal getMdrunnerSignal(SessionResources* resources, md::signals signal);
140 } // end namespace gmxapi
142 #endif // GMXAPI_MDSIGNALS_H