LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
repository.h
Go to the documentation of this file.
1 /*
2  * LibrePCB - Professional EDA for everyone!
3  * Copyright (C) 2013 LibrePCB Developers, see AUTHORS.md for contributors.
4  * https://librepcb.org/
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef LIBREPCB_REPOSITORY_H
21 #define LIBREPCB_REPOSITORY_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "../fileio/serializableobject.h"
27 
28 #include <QtCore>
29 
30 /*******************************************************************************
31  * Namespace / Forward Declarations
32  ******************************************************************************/
33 namespace librepcb {
34 
35 /*******************************************************************************
36  * Class Repository
37  ******************************************************************************/
38 
42 class Repository final : public QObject, public SerializableObject {
43  Q_OBJECT
44 
45 public:
46  // Constructors / Destructor
47  Repository() = delete;
48  explicit Repository(const Repository& other) noexcept;
49  explicit Repository(const QUrl& url) noexcept;
50  explicit Repository(const SExpression& node);
51  ~Repository() noexcept;
52 
53  // Getters
54  bool isValid() const noexcept { return mUrl.isValid(); }
55  const QUrl& getUrl() const noexcept { return mUrl; }
56 
57  // Setters
58  bool setUrl(const QUrl& url) noexcept;
59 
60  // General Methods
61  void requestLibraryList() const noexcept;
62 
64  void serialize(SExpression& root) const override;
65 
66  // Operators
67  Repository& operator=(const Repository& rhs) = delete;
68 
69 signals:
70 
71  void libraryListReceived(const QJsonArray& libs);
72  void errorWhileFetchingLibraryList(const QString& errorMsg);
73 
74 private: // Methods
75  void requestLibraryList(const QUrl& url) const noexcept;
76  void requestedDataReceived(const QByteArray& data) noexcept;
77 
78 private: // Data
79  QUrl mUrl;
80 };
81 
82 /*******************************************************************************
83  * End of File
84  ******************************************************************************/
85 
86 } // namespace librepcb
87 
88 #endif // LIBREPCB_REPOSITORY_H
void libraryListReceived(const QJsonArray &libs)
The Repository class provides access to a LibrePCB API server.
Definition: repository.h:42
The SerializableObject class is the base class for all classes which need to be serializable/deserial...
Definition: serializableobject.h:43
void requestedDataReceived(const QByteArray &data) noexcept
Definition: repository.cpp:94
bool setUrl(const QUrl &url) noexcept
Definition: repository.cpp:57
void requestLibraryList() const noexcept
Definition: repository.cpp:70
void serialize(SExpression &root) const override
Serialize the object into an existing S-Expression node.
Definition: repository.cpp:75
~Repository() noexcept
Definition: repository.cpp:50
const QUrl & getUrl() const noexcept
Definition: repository.h:55
void errorWhileFetchingLibraryList(const QString &errorMsg)
The SExpression class.
Definition: sexpression.h:57
QUrl mUrl
Definition: repository.h:79
bool isValid() const noexcept
Definition: repository.h:54