// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once #include #include #include namespace sys { class Service; // Forward declaration struct ServiceManifest { using ServiceName = std::string; using Timeout = std::chrono::milliseconds; static constexpr auto DefaultTimeout = Timeout{5000}; std::vector dependencies; ServiceName name; Timeout timeout = DefaultTimeout; }; /// Type traits pattern used to enforce user-defined types to implement "GetManifest" function. template struct ManifestTraits; template struct HasManifest : std::false_type {}; /// Checks whether T implements "GetManifest" static method. /// Provides the member constant "value" that is equal to true if T implements "GetManifest" static method. /// Otherwise, "value" is equal to false. template struct HasManifest::GetManifest)>> : std::is_same::GetManifest())> {}; /// Retrieves the manifest of T, if T implements ManifestTraits. /// Otherwise, reports an error during compile time. template ::value, int> = 0> auto ManifestOf() -> ServiceManifest { return ManifestTraits::GetManifest(); } } // namespace sys