|
| 1 | +/******************************************************************************** |
| 2 | + * Copyright (c) 2026 Contributors to the Eclipse Foundation |
| 3 | + * |
| 4 | + * See the NOTICE file(s) distributed with this work for additional |
| 5 | + * information regarding copyright ownership. |
| 6 | + * |
| 7 | + * This program and the accompanying materials are made available under the |
| 8 | + * terms of the Apache License Version 2.0 which is available at |
| 9 | + * https://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * SPDX-License-Identifier: Apache-2.0 |
| 12 | + ********************************************************************************/ |
| 13 | + |
| 14 | +#ifndef SCORE_LCM_ALIVE_H_ |
| 15 | +#define SCORE_LCM_ALIVE_H_ |
| 16 | + |
| 17 | +#include <cstdint> |
| 18 | +#include <memory> |
| 19 | +#include <string_view> |
| 20 | + |
| 21 | +namespace score::mw::lifecycle |
| 22 | +{ |
| 23 | + |
| 24 | +// Forward declaration |
| 25 | +class AliveImpl; |
| 26 | + |
| 27 | +/// @brief Alive API for reporting alive notifications to the launch manager. |
| 28 | +/// An alive notification indicates that the component is still active and functioning correctly. |
| 29 | +/// The launch manager is configured with an expected alive notification interval, |
| 30 | +/// and if it does not receive an alive notification within that interval, |
| 31 | +/// it executes the configured recovery action. |
| 32 | +/// |
| 33 | +/// Each process may only use a single Alive instance. |
| 34 | +class Alive |
| 35 | +{ |
| 36 | +public: |
| 37 | + /// @brief Creation of an Alive. |
| 38 | + /// @param [in] instance Instance specifier (currently unused) |
| 39 | + /// @throws std::runtime_error if the configured IPC channel to connect to launch manager is not existing |
| 40 | + /// @throws std::bad_alloc in case of insufficient memory |
| 41 | + explicit Alive(const std::string_view& instance) noexcept(false); |
| 42 | + |
| 43 | + /// @brief The copy constructor for Alive shall not be used. |
| 44 | + Alive(const Alive& se) = delete; |
| 45 | + |
| 46 | + /// @brief Move constructor for Alive |
| 47 | + /// @param [in,out] se The Alive object to be moved |
| 48 | + Alive(Alive&& se) noexcept; |
| 49 | + |
| 50 | + /// @brief The copy assignment operator for Alive shall not be used. |
| 51 | + Alive& operator=(const Alive& se) = delete; |
| 52 | + |
| 53 | + /// @brief Move assignment operator for Alive |
| 54 | + /// @param [in,out] se The Alive object to be moved |
| 55 | + /// @return The moved Alive object |
| 56 | + Alive& operator=(Alive&& se) noexcept; |
| 57 | + |
| 58 | + /// @brief Destructor of an Alive |
| 59 | + virtual ~Alive() noexcept; |
| 60 | + |
| 61 | + /// @brief Reports an alive notification |
| 62 | + /// @remark Thread safety: This method is NOT thread safe. |
| 63 | + void ReportAlive() const noexcept; |
| 64 | + |
| 65 | + /// @brief Report a direct failure |
| 66 | + /// @remark Thread safety: This method is NOT thread safe. |
| 67 | + /// @note Not Implemented. This method currently does nothing. |
| 68 | + void ReportFailure() const noexcept; |
| 69 | + |
| 70 | +private: |
| 71 | + /// @brief Unique pointer to implementation class of Alive |
| 72 | + std::unique_ptr<AliveImpl> aliveImplPtr; |
| 73 | +}; |
| 74 | + |
| 75 | +} // namespace score::mw::lifecycle |
| 76 | +#endif // SCORE_LCM_ALIVE_H_ |
0 commit comments