LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
projectmetadata.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_PROJECT_PROJECTMETADATA_H
21 #define LIBREPCB_PROJECT_PROJECTMETADATA_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
29 
30 #include <QtCore>
31 
32 /*******************************************************************************
33  * Namespace / Forward Declarations
34  ******************************************************************************/
35 namespace librepcb {
36 namespace project {
37 
38 /*******************************************************************************
39  * Class ProjectMetadata
40  ******************************************************************************/
41 
45 class ProjectMetadata final : public QObject, public SerializableObject {
46  Q_OBJECT
47 
48 public:
49  // Constructors / Destructor
50  ProjectMetadata() = delete;
51  ProjectMetadata(const ProjectMetadata& other) = delete;
52  ProjectMetadata(const Uuid& uuid, const ElementName& name,
53  const QString& author, const QString& version,
54  const QDateTime& created, const QDateTime& lastModified);
55  explicit ProjectMetadata(const SExpression& node);
56  ~ProjectMetadata() noexcept;
57 
58  // Getters
59  const Uuid& getUuid() const noexcept { return mUuid; }
60 
66  const ElementName& getName() const noexcept { return mName; }
67 
73  const QString& getAuthor() const noexcept { return mAuthor; }
74 
80  const QString& getVersion() const noexcept { return mVersion; }
81 
87  const QDateTime& getCreated() const noexcept { return mCreated; }
88 
97  const QDateTime& getLastModified() const noexcept { return mLastModified; }
98 
104  const AttributeList& getAttributes() const noexcept { return mAttributes; }
105 
106  // Setters
107 
115  void setName(const ElementName& newName) noexcept;
116 
124  void setAuthor(const QString& newAuthor) noexcept;
125 
133  void setVersion(const QString& newVersion) noexcept;
134 
142  void setAttributes(const AttributeList& newAttributes) noexcept;
143 
147  void updateLastModified() noexcept;
148 
149  // General Methods
150 
152  void serialize(SExpression& root) const override;
153 
154  // Operator Overloadings
155  ProjectMetadata& operator=(const ProjectMetadata& rhs) = delete;
156 
157 signals:
158  void attributesChanged();
159 
160 private: // Data
163  QString mAuthor;
164  QString mVersion;
165  QDateTime mCreated;
166  QDateTime mLastModified;
168 };
169 
170 /*******************************************************************************
171  * End of File
172  ******************************************************************************/
173 
174 } // namespace project
175 } // namespace librepcb
176 
177 #endif // LIBREPCB_PROJECT_PROJECTMETADATA_H
const QString & getAuthor() const noexcept
Get the author of the project.
Definition: projectmetadata.h:73
void setAuthor(const QString &newAuthor) noexcept
Set the author of the project.
Definition: projectmetadata.cpp:82
const QString & getVersion() const noexcept
Get the version of the project.
Definition: projectmetadata.h:80
void setName(const ElementName &newName) noexcept
Set the name of the project.
Definition: projectmetadata.cpp:75
The ProjectMetadata class.
Definition: projectmetadata.h:45
ElementName mName
the name of the project
Definition: projectmetadata.h:162
QString mAuthor
the author of the project
Definition: projectmetadata.h:163
AttributeList mAttributes
all attributes in a specific order
Definition: projectmetadata.h:167
The SerializableObject class is the base class for all classes which need to be serializable/deserial...
Definition: serializableobject.h:43
const QDateTime & getCreated() const noexcept
Get the date and time when the project was created.
Definition: projectmetadata.h:87
void setVersion(const QString &newVersion) noexcept
Set the version of the project.
Definition: projectmetadata.cpp:89
const QDateTime & getLastModified() const noexcept
Get the date and time when the project was last modified.
Definition: projectmetadata.h:97
void setAttributes(const AttributeList &newAttributes) noexcept
Set all project attributes.
Definition: projectmetadata.cpp:96
QDateTime mLastModified
the datetime of the last project modification
Definition: projectmetadata.h:166
QDateTime mCreated
the datetime of the project creation
Definition: projectmetadata.h:165
void serialize(SExpression &root) const override
Serialize the object into an existing S-Expression node.
Definition: projectmetadata.cpp:113
void updateLastModified() noexcept
Update the last modified datetime.
Definition: projectmetadata.cpp:104
QString mVersion
the version of the project (arbitrary string)
Definition: projectmetadata.h:164
const AttributeList & getAttributes() const noexcept
Get the list of attributes.
Definition: projectmetadata.h:104
Uuid mUuid
the UUID of the project
Definition: projectmetadata.h:161
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
const ElementName & getName() const noexcept
Get the name of the project.
Definition: projectmetadata.h:66
~ProjectMetadata() noexcept
Definition: projectmetadata.cpp:68
The SExpression class.
Definition: sexpression.h:57
const Uuid & getUuid() const noexcept
Definition: projectmetadata.h:59
type_safe::constrained_type< QString, ElementNameConstraint, ElementNameVerifier > ElementName
Definition: elementname.h:92