be28f61040d71632c06c46aa1d9895264dba56bd
[iec.git] / src / type3_AndroidCloud / anbox-master / external / process-cpp-minimal / include / core / posix / signalable.h
1 /*
2  * Copyright © 2013 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU Lesser General Public License version 3,
6  * as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Thomas Voß <thomas.voss@canonical.com>
17  */
18
19 #ifndef CORE_POSIX_SIGNALABLE_H_
20 #define CORE_POSIX_SIGNALABLE_H_
21
22 #include <core/posix/signal.h>
23 #include <core/posix/visibility.h>
24
25 #include <memory>
26 #include <system_error>
27
28 namespace core
29 {
30 namespace posix
31 {
32 /**
33  * @brief The Signalable class abstracts the ability of an entity to be delivered a posix signal.
34  */
35 class CORE_POSIX_DLL_PUBLIC Signalable
36 {
37 public:
38     virtual ~Signalable() { }
39
40     /**
41      * @brief Sends a signal to this signalable object.
42      * @throws std::system_error in case of problems.
43      * @param [in] signal The signal to be sent to the process.
44      */
45     virtual void send_signal_or_throw(Signal signal);
46
47     /**
48      * @brief Sends a signal to this signalable object.
49      * @param [in] signal The signal to be sent to the process.
50      * @param [out] e Set to contain an error if an issue arises.
51      */
52     virtual void send_signal(Signal signal, std::error_code& e) noexcept(true);
53
54 protected:
55     CORE_POSIX_DLL_LOCAL explicit Signalable(pid_t pid);
56
57 private:
58     struct CORE_POSIX_DLL_LOCAL Private;
59     std::shared_ptr<Private> d;
60 };
61 }
62 }
63
64 #endif // CORE_POSIX_SIGNALABLE_H_