pgLab/pglab/querytool/SqlDocumentRegistry.h

28 lines
736 B
C
Raw Normal View History

#ifndef SQLDOCUMENTREGISTRY_H
#define SQLDOCUMENTREGISTRY_H
#include <QList>
#include <memory>
#include <vector>
class SqlDocument;
/** Keeps track of all SQL documents that are still in use, without
* extending their lifetime. A document lives as long as at least one
* query tool holds a shared pointer to it.
*/
class SqlDocumentRegistry {
public:
void add(const std::shared_ptr<SqlDocument> &document);
/// All documents that are still alive.
QList<std::shared_ptr<SqlDocument>> documents() const;
/// All documents that are alive and have unsaved changes.
QList<std::shared_ptr<SqlDocument>> modifiedDocuments() const;
private:
std::vector<std::weak_ptr<SqlDocument>> m_documents;
};
#endif // SQLDOCUMENTREGISTRY_H