Introduce SimulatorBuilder
[gromacs.git] / src / api / cpp / include / gmxapi / status.h
blobc6df7c8ff041eea2485f4cd6834836092922b07d
1 /*
2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2018, 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_STATUS_H
37 #define GMXAPI_STATUS_H
38 /*! \file
39 * \brief Declare Status class for API operations with no other results.
41 * \author M. Eric Irrgang <ericirrgang@gmail.com>
42 * \ingroup gmxapi
45 #include <memory>
47 namespace gmxapi
49 /*! \brief Trivial API operation return value.
51 * Returned by some API operations when a richer return value type does not
52 * exist.
54 * \cond internal
55 * In general, API operations should return an object and not to allow
56 * unsuccessful operations to go undetected. In some cases, there is either no
57 * obvious result object or the API needs a placeholder for a more elaborate
58 * result to be implemented in a future version. This class allows a return
59 * value and potential proxy object as a fall-back where no other option exists.
60 * \endcond
62 * \ingroup gmxapi
64 class Status final
66 public:
67 /*!
68 * \brief Status is "unsuccessful" until set otherwise.
70 * \internal
71 * Default constructor can be used for convenience when preparing the
72 * return value for an operation that should be assumed unsuccessful
73 * until proven otherwise.
75 Status();
76 /*!
77 * \brief Can be copy-initialized
79 * \param status
81 Status(const Status &status);
82 /*!
83 * \brief Can be moved.
85 Status(Status &&) noexcept;
86 /*!
87 * \brief Can be copy-assigned.
89 * \param status
90 * \return reference to lhs.
92 Status &operator=(const Status &status);
93 /*!
94 * \brief Transfer ownership by move assignment.
96 * \param status
97 * \return reference to lhs
99 Status &operator=(Status &&status) noexcept;
101 * \brief Set success status from boolean.
103 * \param success true to indicate successful operation.
104 * \return reference to lhs
106 Status &operator=(bool success);
109 * \brief Initialize with success set true or false.
111 * \param success
113 explicit Status(bool success);
116 * \brief Clean up resources.
118 * Note non-virtual destructor. This class is not heritable.
120 ~Status();
123 * \brief Check success status.
125 * Forces evaluation of any pending computation. The operation that
126 * returned the Status object is guaranteed to complete, successfully
127 * or unsuccessfully, before this function returns.
129 * \return true if the operation described was successful.
131 * \internal
132 * Unsuccessful operations should have more useful information associated
133 * than just a boolean. Future versions should behave more like a
134 * `gmx::future<gmx::expected<T>>`, but this functionality is not yet
135 * available.
137 bool success() const;
138 private:
139 //! \cond
140 class Impl;
141 std::unique_ptr<Impl> impl_;
142 //! \endcond
145 } // end namespace gmxapi
147 #endif //GMXAPI_STATUS_H