Remove C++ service state

This commit is contained in:
Ken Van Hoeylandt 2026-07-05 17:22:26 +02:00
parent d479359613
commit 2433aeb2d8
4 changed files with 7 additions and 19 deletions

View File

@ -1,15 +1,12 @@
#pragma once
#include <tactility/service/service_instance.h>
#include <memory>
namespace tt::service {
enum class State {
Starting,
Started,
Stopping,
Stopped
};
using State = ::ServiceState;
// Forward declaration
class ServiceContext;

View File

@ -6,6 +6,7 @@
#include <tactility/error.h>
#include <tactility/service/service_paths.h>
#include <cassert>
#include <string>
#include <memory>

View File

@ -102,7 +102,7 @@ void attachDevices() {
// We search for the manifest first, because during the initial start() during boot
// the service won't be registered yet.
if (service::findManifestById("Gui") != nullptr) {
if (service::getState("Gui") == service::State::Stopped) {
if (service::getState("Gui") == SERVICE_STATE_STOPPED) {
service::startService("Gui");
} else {
LOG_E(TAG, "Gui service is not in Stopped state");
@ -112,7 +112,7 @@ void attachDevices() {
// We search for the manifest first, because during the initial start() during boot
// the service won't be registered yet.
if (service::findManifestById("Statusbar") != nullptr) {
if (service::getState("Statusbar") == service::State::Stopped) {
if (service::getState("Statusbar") == SERVICE_STATE_STOPPED) {
service::startService("Statusbar");
} else {
LOG_E(TAG, "Statusbar service is not in Stopped state");

View File

@ -13,16 +13,6 @@ namespace tt::service {
constexpr auto* TAG = "ServiceRegistration";
static State toCppState(ServiceState state) {
switch (state) {
case SERVICE_STATE_STARTING: return State::Starting;
case SERVICE_STATE_STARTED: return State::Started;
case SERVICE_STATE_STOPPING: return State::Stopping;
case SERVICE_STATE_STOPPED:
default: return State::Stopped;
}
}
// Bridges the kernel's context-free C ServiceManifest/Service callbacks to the
// C++ Service instances they wrap. Declared extern "C" to match the linkage of
// the C function-pointer types they're assigned to (see e.g. gpio_controller.cpp).
@ -136,7 +126,7 @@ bool stopService(const std::string& id) {
}
State getState(const std::string& id) {
return toCppState(service_registration_get_state(id.c_str()));
return service_registration_get_state(id.c_str());
}
} // namespace