Serenity Operating System
1/*
2 * Copyright (c) 2021, Nick Vella <nick@nxk.io>
3 *
4 * SPDX-License-Identifier: BSD-2-Clause
5 */
6
7#pragma once
8
9#include <AK/ByteBuffer.h>
10#include <AK/DeprecatedString.h>
11#include <AK/LexicalPath.h>
12#include <AK/RefCounted.h>
13#include <AK/Result.h>
14#include <AK/Weakable.h>
15#include <LibGUI/Icon.h>
16
17namespace HackStudio {
18
19class ProjectTemplate : public RefCounted<ProjectTemplate> {
20public:
21 static DeprecatedString templates_path() { return "/res/devel/templates"; }
22
23 static RefPtr<ProjectTemplate> load_from_manifest(DeprecatedString const& manifest_path);
24
25 explicit ProjectTemplate(DeprecatedString const& id, DeprecatedString const& name, DeprecatedString const& description, const GUI::Icon& icon, int priority);
26
27 Result<void, DeprecatedString> create_project(DeprecatedString const& name, DeprecatedString const& path);
28
29 DeprecatedString const& id() const { return m_id; }
30 DeprecatedString const& name() const { return m_name; }
31 DeprecatedString const& description() const { return m_description; }
32 const GUI::Icon& icon() const { return m_icon; }
33 const DeprecatedString content_path() const
34 {
35 return LexicalPath::canonicalized_path(DeprecatedString::formatted("{}/{}", templates_path(), m_id));
36 }
37 int priority() const { return m_priority; }
38
39private:
40 DeprecatedString m_id;
41 DeprecatedString m_name;
42 DeprecatedString m_description;
43 GUI::Icon m_icon;
44 int m_priority { 0 };
45};
46
47}