summaryrefslogtreecommitdiff
path: root/core/src/Model/Project.hpp
blob: 280eaf334790df9c508bf89c0d5d6f9c39bb5aef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#pragma once

#include "Model/Items.hpp"

#include <filesystem>
#include <string>
#include <json/forwards.h>

class Project {
public:
	ItemList<ProductItem> Products;
	ItemList<FactoryItem> Factories;
	ItemList<CustomerItem> Customers;

private:
	std::filesystem::path mRootPath;
	std::string mRootPathString;
	std::string mName;

public:
	/// Load the project from a cplt_project.json file.
	static Project Load(const std::filesystem::path& projectFilePath);
	/// Load the project from the directory containing the cplt_project.json file.
	static Project LoadDir(const std::filesystem::path& projectPath);
	/// Create a project with the given name in the given path. Note that the path should be a directory that will contain the project files once created.
	/// This function assumes the given directory will exist and is empty.
	static Project Create(std::string name, const std::filesystem::path& path);

	/// Path to a *directory* that contains the project file.
	const std::filesystem::path& GetPath() const;
	const std::string& GetPathString() const;

	const std::string& GetName() const;
	void SetName(std::string name);

	Json::Value Serialize();
	void WriteToDisk();

private:
	Project() = default;
};