Line data Source code
1 : // SPDX-FileCopyrightText: 2013-2025 Paul Colby <git@colby.id.au>
2 : // SPDX-License-Identifier: LGPL-3.0-or-later
3 :
4 : /*!
5 : * \file
6 : * Declares the Model class.
7 : */
8 :
9 : #ifndef QTSMITHY_MODEL_H
10 : #define QTSMITHY_MODEL_H
11 :
12 : #include "shape.h"
13 : #include "shapeid.h"
14 :
15 : #include <QCoreApplication>
16 : #include <QHash>
17 : #include <QJsonObject>
18 :
19 : QTSMITHY_DECLARE_TEST(Model)
20 :
21 : QTSMITHY_BEGIN_NAMESPACE
22 :
23 : class ModelPrivate;
24 :
25 : class QTSMITHY_EXPORT Model
26 : {
27 0 : Q_DECLARE_TR_FUNCTIONS(Model);
28 :
29 : public:
30 : enum class Error {
31 : NoError = 0,
32 : NoData = 1,
33 : InvalidMetadata = 2,
34 : InvalidShapes = 3,
35 : InvalidShapeId = 4,
36 : InvalidShape = 5,
37 : ConflictingMetadata = 6,
38 : };
39 :
40 : Model();
41 : Model(Model &&other);
42 : Model(const Model &other);
43 : Model& operator=(const Model &model);
44 : Model& operator=(const Model &&model);
45 : ~Model();
46 :
47 : void clear();
48 : bool insert(const QJsonObject &ast);
49 : bool finish();
50 :
51 : Error error() const;
52 : bool isValid() const;
53 :
54 : QJsonObject metadata() const;
55 : Shape shape(const ShapeId &shapeId) const;
56 : QHash<ShapeId, Shape> shapes(const Shape::Type &type = Shape::Type::Undefined) const;
57 :
58 : protected:
59 : /// \cond internal
60 : ModelPrivate * d_ptr; ///< Internal d-pointer.
61 : /// \endcond
62 :
63 : private:
64 0 : Q_DECLARE_PRIVATE(Model)
65 : QTSMITHY_BEFRIEND_TEST(Model)
66 : };
67 :
68 : QTSMITHY_END_NAMESPACE
69 :
70 : #endif // QTSMITHY_MODEL_H
|