src/librarycollection.h

changeset 1209
c2723022b173
child 1210
0b3b35f560f2
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/librarycollection.h	Thu Mar 09 12:50:14 2017 +0200
@@ -0,0 +1,46 @@
+#pragma once
+#include <QDir>
+#include "main.h"
+
+/*
+ * Models a collection of libraries. A library is a folder containing directories named "p" and
+ * "parts" that contains part and subpart files.
+ */
+class LibraryCollection
+{
+public:
+	enum FileType
+	{
+		Part,
+		Subpart,
+		Primitive,
+		HighResolutionPrimitive,
+		LowResolutionPrimitive,
+	};
+
+	struct FileSpec
+	{
+		QString name;
+		FileType type;
+	};
+
+	QString find(QString relativePath) const;
+	QString find(const QString& name, FileType type) const;
+	QString find(const FileSpec& spec) const;
+
+	static const QStringList directoryNames;
+
+private:
+	class SubdirectoryNotFoundError : public std::exception {};
+
+	struct Library
+	{
+		QDir path;
+		QString name;
+
+		QDir subdirectory(FileType type) const;
+		static QString subdirectoryName(FileType type);
+	};
+
+	QVector<Library> m_libraries;
+};

mercurial