diff options
Diffstat (limited to 'app/source/Cplt/Model/Project.hpp')
-rw-r--r-- | app/source/Cplt/Model/Project.hpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/app/source/Cplt/Model/Project.hpp b/app/source/Cplt/Model/Project.hpp new file mode 100644 index 0000000..8119a97 --- /dev/null +++ b/app/source/Cplt/Model/Project.hpp @@ -0,0 +1,57 @@ +#pragma once + +#include <Cplt/Model/Assets.hpp> +#include <Cplt/Model/Database.hpp> +#include <Cplt/Model/Items.hpp> +#include <Cplt/Model/Template/Template.hpp> +#include <Cplt/Model/Workflow/Workflow.hpp> + +#include <json/forwards.h> +#include <tsl/array_map.h> +#include <filesystem> +#include <string> +#include <string_view> + +class Project +{ +private: + std::filesystem::path mRootPath; + std::string mRootPathString; + std::string mName; + + // (Exception to style guidelines) + // This is put after the private fields, so that when XxxDatabase's constructor runs, all of them will be initialized +public: + WorkflowAssetList Workflows; + TemplateAssetList Templates; + ItemList<ProductItem> Products; + ItemList<FactoryItem> Factories; + ItemList<CustomerItem> Customers; + MainDatabase Database; + +public: + /// Load the project from a directory containing the cplt_project.json file. + /// This only loads the main project file, the caller needs to + 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); + + Json::Value Serialize(); + void WriteToDisk(); +}; |