1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
|
// SPDX-License-Identifier: GPL-3.0-only
// SPDX-FileCopyrightText: 2026 Project Tick
// SPDX-FileContributor: Project Tick Team
/*
* ProjT Launcher - Minecraft Launcher
* Copyright (C) 2026 Project Tick
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#pragma once
#include <QDateTime>
#include <QJsonObject>
#include <QObject>
#include <memory>
#include "BaseEntity.hpp"
#include "BaseVersion.h"
#include "JsonFormat.hpp"
#include "Version.h"
#include "minecraft/VersionFile.h"
namespace projt::meta
{
/**
* @brief Single version entry in the metadata system.
*/
class MetaVersion : public QObject, public BaseVersion, public MetaEntity
{
Q_OBJECT
public:
using Ptr = std::shared_ptr<MetaVersion>;
MetaVersion(const QString& componentUid, const QString& versionId);
~MetaVersion() override = default;
// BaseVersion interface
QString descriptor() const override
{
return m_versionId;
}
QString name() const override;
QString typeString() const override
{
return m_releaseType;
}
// Identity
QString componentUid() const
{
return m_componentUid;
}
QString versionId() const
{
return m_versionId;
}
// Release info
QString releaseType() const
{
return m_releaseType;
}
QDateTime releaseTime() const;
qint64 releaseTimestamp() const
{
return m_timestamp;
}
// Flags
bool isStable() const
{
return m_stable;
}
bool isVolatile() const
{
return m_volatile;
}
// Dependencies
const DependencySet& dependencies() const
{
return m_dependencies;
}
const DependencySet& conflicts() const
{
return m_conflicts;
}
QString parentComponentVersion() const;
// Detailed data
bool hasDetailedData() const
{
return m_detailedData != nullptr;
}
const VersionFilePtr& detailedData() const
{
return m_detailedData;
}
bool isFullyLoaded() const
{
return hasDetailedData() && isReady();
}
// MetaEntity interface
QString cacheFilePath() const override;
void loadFromJson(const QJsonObject& json) override;
// Version comparison
::Version asComparableVersion() const
{
return ::Version(m_versionId);
}
// Merge operations
void updateFrom(const MetaVersion::Ptr& source);
void updateMetadataFrom(const MetaVersion::Ptr& source);
public: // Setters for parsers
void setReleaseType(const QString& type);
void setReleaseTimestamp(qint64 ts);
void setDependencies(const DependencySet& deps, const DependencySet& conflicts);
void setStable(bool stable);
void setVolatile(bool vol);
void setDetailedData(const VersionFilePtr& data);
void markAsStableCandidate();
signals:
void releaseTypeChanged();
void timestampChanged();
void dependenciesChanged();
private:
QString m_componentUid;
QString m_versionId;
QString m_releaseType;
qint64 m_timestamp = 0;
bool m_stable = false;
bool m_volatile = false;
bool m_providesStability = false;
DependencySet m_dependencies;
DependencySet m_conflicts;
VersionFilePtr m_detailedData;
};
} // namespace projt::meta
Q_DECLARE_METATYPE(projt::meta::MetaVersion::Ptr)
|