12#ifndef LIBRARYHANDLER_H
13#define LIBRARYHANDLER_H
26#include <IPXACTmodels/common/Document.h>
27#include <IPXACTmodels/common/TagData.h>
29#include <IPXACTmodels/kactusExtensions/KactusAttribute.h>
31#include <KactusAPI/KactusAPIGlobal.h>
36#include <QSharedPointer>
73 QSharedPointer<Document>
getModel(VLNV const& vlnv) final;
105 const QString
getPath(VLNV const& vlnv) const final;
203 int getOwners(QList<VLNV>& list, VLNV const& vlnvToSearch) const final;
212 int getChildren(QList<VLNV>& list, VLNV const& vlnvToSearch) const final;
242 QSharedPointer<Design>
getDesign(VLNV const& hierarchyRef) final;
412 void onItemSaved(VLNV const& vlnv);
419 QSharedPointer<Document> document;
424 explicit DocumentInfo(QString
const& filePath = QString(),
425 QSharedPointer<Document> doc = QSharedPointer<Document>(),
426 bool valid =
false): document(doc), path(filePath),
isValid(valid) {}
430 struct DocumentStatistics
433 int documentCount = 0;
449 void syncronizeModels();
452 void showNotFoundError(VLNV
const& vlnv)
const;
455 bool addObject(QSharedPointer<Document> model, QString
const& filePath);
461 void loadAvailableVLNVs();
467 void showIntegrityResults()
const;
476 bool removeFile(QString
const& filePath)
const;
486 bool validateDocument(QSharedPointer<Document> document, QString
const& documentPath);
495 bool validateDependentVLNVReferencences(QSharedPointer<Document> document);
503 void findErrorsInDependentVLNVReferencences(QSharedPointer<const Document> document, QVector<QString>& errorList);
513 bool validateDependentDirectories(QSharedPointer<Document> document, QString
const& documentPath);
522 void findErrorsInDependentDirectories(QSharedPointer<const Document> document, QString
const& documentPath,
523 QVector<QString>& errorList);
531 bool validateDependentFiles(QSharedPointer<Document> document, QString
const& documentPath);
540 void findErrorsInDependentFiles(QSharedPointer<const Document> document, QString
const& documentPath,
541 QVector<QString>& errorList);
549 NullChannel defaultChannel;
552 MessageMediator* messageChannel_{ &defaultChannel };
555 LibraryLoader loader_{ };
562 QMap<VLNV, DocumentInfo> documentCache_;
568 DocumentValidator validator_{
this };
571 LibraryTreeModel treeModel_{
this,
this };
574 HierarchyModel hierarchyModel_{
this,
this };
577 bool saveInProgress_{
false };
580 DocumentStatistics checkResults_;
Contains the items to display the library component hierarchy to user.
void openComDefinition(VLNV const &vlnv)
Signal that user wants to open specified COM definition for editing.
static LibraryHandler & getInstance()
The the instance of the library.
void removeObjects(const QList< VLNV > &vlnvList) final
void updatedVLNV(VLNV const &vlnv)
Inform that object has been updated.
HierarchyModel * getHierarchyModel()
void onOpenDesign(VLNV const &vlnv, QString const &viewName) final
VLNV getDesignVLNV(VLNV const &hierarchyRef) final
void searchForIPXactFiles() final
Search for IP-Xact files in the file system and add them to library.
void openCatalog(VLNV const &vlnv)
Signal that user wants to open specified catalog for editing.
void removeObject(VLNV const &vlnv) final
const QString getPath(VLNV const &vlnv) const final
LibraryHandler(const LibraryHandler &other)=delete
No copying.
void openComponent(VLNV const &vlnv)
Signal that user wants to open specified component for editing.
void openDesign(VLNV const &vlnv, const QString &viewName)
Signal that user wants to open the specified component for editing.
LibraryItem const * getTreeRoot() const final
QVector< QString > findErrorsInDocument(QSharedPointer< Document > document, QString const &path)
void openAbsDef(VLNV const &absDefVLNV)
Signal that user wants to open specified abstraction for editing.
void removeVLNV(VLNV const &vlnv)
Inform tree model that a vlnv is to be removed from the tree.
bool writeModelToFile(QString const &path, QSharedPointer< Document > model) final
void onOpenSystemDesign(VLNV const &vlnv)
QSharedPointer< Document > getModel(VLNV const &vlnv) final
void getDependencyFiles(VLNV const &vlnv, QStringList &list) final
LibraryTreeModel * getTreeModel()
void onEditItem(VLNV const &vlnv) final
void openSystemDesign(VLNV const &vlnv, QString const &viewName)
Signal that user wants to open a system for editing.
QSharedPointer< Design > getDesign(VLNV const &hierarchyRef) final
void addVLNV(VLNV const &vlnv)
Inform tree model that a vlnv is to be added to the tree.
void setOutputChannel(MessageMediator *messageChannel)
LibraryHandler & operator=(const LibraryHandler &other)=delete
No assignment.
void openPlatformComponent(VLNV const &vlnv)
Signal that user wants to open a platform component.
void onOpenMemoryDesign(VLNV const &vlnv, QString const &activeView)
void getNeededVLNVs(VLNV const &vlnv, QList< VLNV > &list) final
bool contains(VLNV const &vlnv) const final
int referenceCount(VLNV const &vlnv) const final
void openBus(VLNV const &busDefVLNV)
Signal that user wants to open specified bus for editing.
void openApiDefinition(VLNV const &vlnv)
Signal that user wants to open specified API definition for editing.
QString getDirectoryPath(VLNV const &vlnv) const final
void onOpenSWDesign(VLNV const &vlnv)
void onCheckLibraryIntegrity() final
int getOwners(QList< VLNV > &list, VLNV const &vlnvToSearch) const final
int getChildren(QList< VLNV > &list, VLNV const &vlnvToSearch) const final
void openMemoryDesign(VLNV const &vlnv, const QString &viewName)
Signal that user wants to open the memory design of the specified component for editing.
~LibraryHandler() final=default
The destructor.
bool isValid(VLNV const &vlnv) final
void openSWDesign(VLNV const &vlnv, QString const &viewName)
Signal that user wants to open the specified software design for editing.
VLNV::IPXactType getDocumentType(VLNV const &vlnv) final
QSharedPointer< Document const > getModelReadOnly(VLNV const &vlnv) final
void resetModel()
Inform both models that the content must be reset.
void itemSelected(VLNV const &vlnv)
Signal that the library item specified by vlnv is selected in one of the views.
QList< VLNV > getAllVLNVs() const final
LibraryInterface defines an interface to operate the IP-XACT-library.
virtual bool isValid(VLNV const &vlnv)=0
LibraryItem class is used to create the hierarchical structure of IP library.
The model that contains the LibraryItems to display library hierarchically.
const QRegularExpression URL_VALIDITY_REG_EXP("^[a-z]{3,9}[:][/]{2}[a-z0-9]+([-.][a-z0-9]+)*([/][-a-z0-9_.;,?=&%#~+]*)*$", QRegularExpression::CaseInsensitiveOption)
Regular expression to validate URLs.