Use proper doxygen tags in modular simulator
[gromacs.git] / api / cpp / gmxapi / sessionresources.h
blob3bdaf680183ce704145f2658eee420d03c02193c
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_SESSION_RESOURCES_IMPL_H
37 #define GMXAPI_SESSION_RESOURCES_IMPL_H
39 /*! \file
40 * \brief Implementation details for SessionResources infrastructure.
42 * Define the library interface for classes with opaque external interfaces.
44 * These are specifically details of the gmx Mdrunner session implementation.
46 * \author M. Eric Irrgang <ericirrgang@gmail.com>
47 * \ingroup gmxapi
50 #include <string>
52 #include "gmxapi/session.h"
53 #include "gmxapi/md/mdsignals.h"
54 #include "gmxapi/session/resources.h"
56 namespace gmxapi
59 /*!
60 * \brief Consumer-specific access to Session resources.
62 * Each element of work that is managed by a Session and which may need access to Session resources
63 * is uniquely identified. SessionResources objects allow client code to be identified by the
64 * Session so that appropriate resources can be acquired when needed.
66 * Resources are configured at Session launch by SessionImpl::createResources()
68 * \ingroup gmxapi
70 class SessionResources final
72 public:
73 /*!
74 * \brief Construct a resources object for the named operation.
76 * \param session implementation object backing these resources.
77 * \param name Unique name of workflow operation.
79 SessionResources(SessionImpl* session, std::string name);
81 /*!
82 * \brief no default constructor.
84 * \see SessionResources(SessionImpl* session, std::string name)
86 SessionResources() = delete;
88 ///@{
89 /*!
90 * \brief Not moveable or copyable.
92 * Objects of this type should only exist in their Session container.
93 * If necessary, ownership can be transferred by owning through a unique_ptr handle.
95 SessionResources(const SessionResources&) = delete;
96 SessionResources& operator=(const SessionResources&) = delete;
97 SessionResources(SessionResources&&) = delete;
98 SessionResources& operator=(SessionResources&&) = delete;
99 ///@}
101 ~SessionResources();
104 * \brief Get the name of the gmxapi operation for which these resources exist.
106 * \return workflow element name
108 std::string name() const;
111 * \brief Get a Signal instance implementing the requested MD signal.
113 * The caller is responsible for ensuring that the session is still active.
114 * Unfortunately, there isn't really a way to do that right now. This needs improvemnt
115 * in a near future version.
117 * Also, this is an external interface that should avoid throwing exceptions for ABI compatibility.
119 * \param signal currently must be gmxapi::md::signals::STOP
120 * \return callable object.
122 * Example:
124 * auto signal = sessionResources->getMdrunnerSignal(md::signals::STOP);
125 * signal();
127 * \throws gmxapi::NotImplementedError if an implementation is not available for the requested signal.
128 * \throws gmxapi::ProtocolError if the Session or Signaller is not available.
130 Signal getMdrunnerSignal(md::signals signal);
132 private:
134 * \brief pointer to the session owning these resources
136 SessionImpl* sessionImpl_ = nullptr;
139 * \brief name of the associated gmxapi operation
141 std::string name_;
144 } // end namespace gmxapi
146 #endif // GMXAPI_SESSION_RESOURCES_IMPL_H