Sélectionner une révision Git
VivyDocumentStore.hh
VivyDocumentStore.hh 1,40 Kio
#ifndef VIVY_DOCUMENTSTORE_H
#define VIVY_DOCUMENTSTORE_H
#include "VivyDocument.hh"
#include <QMap>
#include <QString>
#include <memory>
class VivyDocumentStore final {
public:
explicit VivyDocumentStore() noexcept = default;
~VivyDocumentStore() noexcept = default;
/* Don't move this object around */
VivyDocumentStore(const VivyDocumentStore &) = delete; // Copy
VivyDocumentStore(VivyDocumentStore &&) = delete; // Move
VivyDocumentStore &operator=(const VivyDocumentStore &) = delete; // Copy assign
VivyDocumentStore &operator=(VivyDocumentStore &&) = delete; // Move assign
/* Create/load documents */
std::weak_ptr<VivyDocument> loadDocument(const QString &file);
std::weak_ptr<VivyDocument> newDocument();
/* Get to see if a document is already present or not */
[[nodiscard("handle-it")]] bool isDocumentPresent(const QString &name) noexcept;
/* Close a document, please be sure to not used any of the dangling
* references to the closed document... */
void closeDocument(const QString &name) noexcept;
/* Get stored documents */
std::weak_ptr<VivyDocument> getDocument(const QString &name) const;
private:
QMap<QString, std::shared_ptr<VivyDocument>> documents;
uint newDocumentNumber{1};
static inline const QString newDocumentBaseName = "Untitled ";
};
#endif // VIVY_DOCUMENTSTORE_H