blob: bce58c2cce8519942f7dc9c7fec41653c2c8afd8 (
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
#pragma once
#include "Model/Items.hpp"
#include "Model/Template/Template.hpp"
#include "Model/TransactionsModel.hpp"
#include "Model/Workflow/Workflow.hpp"
#include <json/forwards.h>
#include <tsl/array_map.h>
#include <filesystem>
#include <string>
#include <string_view>
class Project
{
public:
ItemList<ProductItem> Products;
ItemList<FactoryItem> Factories;
ItemList<CustomerItem> Customers;
private:
tsl::array_map<char, WorkflowInfo> mWorkflows;
tsl::array_map<char, TemplateInfo> mTemplates;
std::filesystem::path mRootPath;
std::string mRootPathString;
std::string mName;
// This is put after the private fields, so that when TransactionModel's constructor runs, all of them will be initialized
public:
TransactionModel Database;
public:
/// Load the project from a directory containing the cplt_project.json file.
Project(std::filesystem::path rootPath);
/// 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.
Project(std::filesystem::path rootPath, std::string name);
/// Path to a *directory* that contains the project file.
const std::filesystem::path& GetPath() const;
const std::string& GetPathString() const;
std::filesystem::path GetDatabasesDirectory() const;
std::filesystem::path GetItemsDirectory() const;
std::filesystem::path GetWorkflowsDirectory() const;
std::filesystem::path GetWorkflowPath(std::string_view name) const;
std::filesystem::path GetTemplatesDirectory() const;
std::filesystem::path GetTemplatePath(std::string_view name) const;
const std::string& GetName() const;
void SetName(std::string name);
const tsl::array_map<char, WorkflowInfo>& GetWorkflows() const;
std::unique_ptr<Workflow> LoadWorkflow(std::string_view name);
std::unique_ptr<Workflow> CreateWorkflow(std::string_view name);
bool RemoveWorkflow(std::string_view name);
bool RenameWorkflow(std::string_view oldName, std::string_view newName);
const tsl::array_map<char, TemplateInfo>& GetTemplates() const;
std::unique_ptr<Template> LoadTemplate(std::string_view name);
bool InsertTemplate(std::string_view name, TemplateInfo info);
bool RemoveTemplate(std::string_view name);
bool RenameTemplate(std::string_view oldName, std::string_view newName);
Json::Value Serialize();
void WriteToDisk();
};
|