/* * Copyright (c) 2023, Liav A. * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include "Port.h" #include #include #include #include #include #include constexpr StringView ports_database = "/usr/Ports/installed.db"sv; class InstalledPort : public Port { public: enum class Type { Auto, Manual, }; static Optional type_from_string(StringView); static ErrorOr> read_ports_database(); static ErrorOr for_each_by_type(HashMap&, Type type, Function(InstalledPort const&)> callback); InstalledPort(String const& name, String const& version, Type type) : Port(name, version) , m_type(type) { } Type type() const { return m_type; } StringView type_as_string_view() const { if (m_type == Type::Auto) return "Automatic"sv; if (m_type == Type::Manual) return "Manual"sv; VERIFY_NOT_REACHED(); } ReadonlySpan dependencies() const { return m_dependencies.span(); } private: Type m_type; Vector m_dependencies; };