20#ifndef LIBREPCB_CORE_LIBRARYBASEELEMENT_H
21#define LIBREPCB_CORE_LIBRARYBASEELEMENT_H
26#include "../fileio/transactionaldirectory.h"
27#include "../rulecheck/rulecheckmessage.h"
28#include "../serialization/serializablekeyvaluemap.h"
29#include "../types/uuid.h"
30#include "../types/version.h"
56 const QString& longElementName,
const Uuid& uuid,
57 const Version& version,
const QString& author,
59 const QString& description_en_US,
60 const QString& keywords_en_US);
62 const QString& longElementName,
bool dirnameMustBeUuid,
63 std::unique_ptr<TransactionalDirectory> directory,
116 template <
typename ElementType>
118 return dir.getPathTo(
".librepcb-" % ElementType::getShortElementName())
121 template <
typename ElementType>
123 const QString& path)
noexcept {
124 return dir.fileExists((path.isEmpty() ? path : path %
"/") %
".librepcb-" %
125 ElementType::getShortElementName());
141 const QString& fileName);
This class represents absolute, well-formatted paths to files or directories.
Definition filepath.h:127
The LibraryBaseElement class.
Definition librarybaseelement.h:48
TransactionalDirectory & getDirectory() noexcept
Definition librarybaseelement.h:71
void serializeMessageApprovals(SExpression &root) const
Definition librarybaseelement.cpp:174
QDateTime mCreated
Definition librarybaseelement.h:153
const TransactionalDirectory & getDirectory() const noexcept
Definition librarybaseelement.h:68
QSet< SExpression > mMessageApprovals
Definition librarybaseelement.h:160
LocalizedKeywordsMap mKeywords
Definition librarybaseelement.h:157
const QString mShortElementName
e.g. "lib", "cmpcat"
Definition librarybaseelement.h:145
const LocalizedKeywordsMap & getKeywords() const noexcept
Definition librarybaseelement.h:83
const LocalizedNameMap & getNames() const noexcept
Definition librarybaseelement.h:79
bool mIsDeprecated
Definition librarybaseelement.h:154
void setVersion(const Version &version) noexcept
Definition librarybaseelement.h:90
void setKeywords(const LocalizedKeywordsMap &keywords) noexcept
Definition librarybaseelement.h:97
const QString & getAuthor() const noexcept
Definition librarybaseelement.h:76
LibraryBaseElement & operator=(const LibraryBaseElement &rhs)=delete
void setDeprecated(bool deprecated) noexcept
Definition librarybaseelement.h:92
QStringList getAllAvailableLocales() const noexcept
Definition librarybaseelement.cpp:103
void setMessageApprovals(const QSet< SExpression > &approvals) noexcept
Definition librarybaseelement.h:100
Version mVersion
Definition librarybaseelement.h:151
Uuid mUuid
Definition librarybaseelement.h:150
void removeObsoleteMessageApprovals()
Definition librarybaseelement.cpp:182
void setNames(const LocalizedNameMap &names) noexcept
Definition librarybaseelement.h:93
virtual void moveIntoParentDirectory(TransactionalDirectory &dest)
Definition librarybaseelement.cpp:150
LibraryBaseElement()=delete
virtual void saveTo(TransactionalDirectory &dest)
Definition librarybaseelement.cpp:135
LocalizedDescriptionMap mDescriptions
Definition librarybaseelement.h:156
bool isDeprecated() const noexcept
Definition librarybaseelement.h:78
const QSet< SExpression > & getMessageApprovals() const noexcept
Definition librarybaseelement.h:85
const QDateTime & getCreated() const noexcept
Definition librarybaseelement.h:77
virtual ~LibraryBaseElement() noexcept
Definition librarybaseelement.cpp:96
LocalizedNameMap mNames
Definition librarybaseelement.h:155
static bool isValidElementDirectory(const TransactionalDirectory &dir, const QString &path) noexcept
Definition librarybaseelement.h:122
virtual void serialize(SExpression &root) const
Serialize into librepcb::SExpression node.
Definition librarybaseelement.cpp:155
virtual void save()
Definition librarybaseelement.cpp:122
const LocalizedDescriptionMap & getDescriptions() const noexcept
Definition librarybaseelement.h:80
const Uuid & getUuid() const noexcept
Definition librarybaseelement.h:74
static Version readFileFormat(const TransactionalDirectory &directory, const QString &fileName)
Definition librarybaseelement.cpp:187
LibraryBaseElement(const LibraryBaseElement &other)=delete
static bool isValidElementDirectory(const FilePath &dir) noexcept
Definition librarybaseelement.h:117
virtual void saveIntoParentDirectory(TransactionalDirectory &dest)
Definition librarybaseelement.cpp:145
std::unique_ptr< TransactionalDirectory > mDirectory
Definition librarybaseelement.h:147
void setDescriptions(const LocalizedDescriptionMap &descriptions) noexcept
Definition librarybaseelement.h:94
const Version & getVersion() const noexcept
Definition librarybaseelement.h:75
virtual void moveTo(TransactionalDirectory &dest)
Definition librarybaseelement.cpp:140
const QString mLongElementName
e.g. "library", "component_category"
Definition librarybaseelement.h:146
virtual RuleCheckMessageList runChecks() const
Definition librarybaseelement.cpp:117
void setAuthor(const QString &author) noexcept
Definition librarybaseelement.h:91
QString mAuthor
Definition librarybaseelement.h:152
The SExpression class.
Definition sexpression.h:69
Helper class to access a subdirectory of TransactionalFileSystem.
Definition transactionaldirectory.h:51
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition uuid.h:56
The Version class represents a version number in the format "1.42.7".
Definition version.h:58
Definition occmodel.cpp:76
QVector< std::shared_ptr< const RuleCheckMessage > > RuleCheckMessageList
Definition rulecheckmessage.h:104
type_safe::constrained_type< QString, ElementNameConstraint, ElementNameVerifier > ElementName
Definition elementname.h:84