LibrePCB Developers Documentation
resource.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_CORE_RESOURCE_H
21#define LIBREPCB_CORE_RESOURCE_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../serialization/serializableobjectlist.h"
27#include "../types/elementname.h"
28
29#include <QtCore>
30
31#include <memory>
32
33/*******************************************************************************
34 * Namespace / Forward Declarations
35 ******************************************************************************/
36namespace librepcb {
37
38/*******************************************************************************
39 * Class Resource
40 ******************************************************************************/
41
45class Resource final {
46 Q_DECLARE_TR_FUNCTIONS(Resource)
47
48public:
49 // Signals
50 enum class Event {
51 NameChanged,
52 MediaTypeChanged,
53 UrlChanged,
54 };
57
58 // Constructors / Destructor
59 Resource() = delete;
60 Resource(const Resource& other) noexcept;
61 explicit Resource(const SExpression& node);
62 Resource(const ElementName& name, const QString& mimeType,
63 const QUrl& url) noexcept;
64 ~Resource() noexcept;
65
66 // Getters
67 const ElementName& getName() const noexcept { return mName; }
68 const QString& getMediaType() const noexcept { return mMediaType; }
69 const QUrl& getUrl() const noexcept { return mUrl; }
70
71 // Setters
72 void setName(const ElementName& name) noexcept;
73 void setMediaType(const QString& type) noexcept;
74 void setUrl(const QUrl& url) noexcept;
75
76 // General Methods
77
83 void serialize(SExpression& root) const;
84
85 // Operator Overloadings
86 bool operator==(const Resource& rhs) const noexcept;
87 bool operator!=(const Resource& rhs) const noexcept {
88 return !(*this == rhs);
89 }
90 Resource& operator=(const Resource& rhs) noexcept;
91
92private: // Data
94 QString mMediaType;
95 QUrl mUrl;
96};
97
98/*******************************************************************************
99 * Class ResourceList
100 ******************************************************************************/
101
103 static constexpr const char* tagname = "resource";
104};
107
108/*******************************************************************************
109 * End of File
110 ******************************************************************************/
111
112} // namespace librepcb
113
114#endif
The Resource class.
Definition: resource.h:45
void setUrl(const QUrl &url) noexcept
Definition: resource.cpp:77
QUrl mUrl
Definition: resource.h:95
void setName(const ElementName &name) noexcept
Definition: resource.cpp:63
Resource & operator=(const Resource &rhs) noexcept
Definition: resource.cpp:107
const ElementName & getName() const noexcept
Definition: resource.h:67
Event
Definition: resource.h:50
ElementName mName
Definition: resource.h:93
QString mMediaType
Definition: resource.h:94
void setMediaType(const QString &type) noexcept
Definition: resource.cpp:70
const QString & getMediaType() const noexcept
Definition: resource.h:68
void serialize(SExpression &root) const
Serialize into librepcb::SExpression node.
Definition: resource.cpp:88
bool operator==(const Resource &rhs) const noexcept
Definition: resource.cpp:100
~Resource() noexcept
Definition: resource.cpp:56
const QUrl & getUrl() const noexcept
Definition: resource.h:69
Signal< Resource, Event > onEdited
Definition: resource.h:55
bool operator!=(const Resource &rhs) const noexcept
Definition: resource.h:87
Slot< Resource, Event > OnEditedSlot
Definition: resource.h:56
The SExpression class.
Definition: sexpression.h:69
The Signal class is used to emit signals on non-QObject derived classes.
Definition: signalslot.h:65
The Slot class is used to receive signals from non-QObject derived classes.
Definition: signalslot.h:170
Definition: occmodel.cpp:77
type_safe::constrained_type< QString, ElementNameConstraint, ElementNameVerifier > ElementName
Definition: elementname.h:84
Definition: resource.h:102
static constexpr const char * tagname
Definition: resource.h:103