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 
45 class Repository final : public QObject, public SerializableObject {
46  Q_OBJECT
47 
48 public:
49  // Constructors / Destructor
50  Repository() = delete;
51  explicit Repository(const Repository& other) noexcept;
52  explicit Repository(const QUrl& url) noexcept;
53  explicit Repository(const SExpression& node);
54  ~Repository() noexcept;
55 
56  // Getters
57  bool isValid() const noexcept { return mUrl.isValid(); }
58  const QUrl& getUrl() const noexcept { return mUrl; }
59 
60  // Setters
61  bool setUrl(const QUrl& url) noexcept;
62 
63  // General Methods
64  void requestLibraryList() const noexcept;
65 
67  void serialize(SExpression& root) const override;
68 
69  // Operators
70  Repository& operator=(const Repository& rhs) = delete;
71 
72 signals:
73 
74  void libraryListReceived(const QJsonArray& libs);
75  void errorWhileFetchingLibraryList(const QString& errorMsg);
76 
77 private: // Methods
78  void requestLibraryList(const QUrl& url) const noexcept;
79  void requestedDataReceived(const QByteArray& data) noexcept;
80 
81 private: // Data
82  QUrl mUrl;
83 };
84 
85 /*******************************************************************************
86  * End of File
87  ******************************************************************************/
88 
89 } // namespace librepcb
90 
91 #endif // LIBREPCB_REPOSITORY_H
void libraryListReceived(const QJsonArray &libs)
The Repository class provides access to a LibrePCB API server.
Definition: repository.h:45
The SerializableObject class is the base class for all classes which need to be serializable/deserial...
Definition: serializableobject.h:46
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:58
void errorWhileFetchingLibraryList(const QString &errorMsg)
The SExpression class.
Definition: sexpression.h:60
QUrl mUrl
Definition: repository.h:82
bool isValid() const noexcept
Definition: repository.h:57