mason/src/project.h

65 lines
1.7 KiB
C++

#pragma once
#include <filesystem>
#include <string>
#include <fstream>
#include <list>
#include <map>
#include <stdint.h>
#include <nlohmann/json.hpp>
#include <curl/curl.h>
#include "dependency.h"
#include "loggger.h"
class Project {
public:
enum class State {
unknown,
read,
discovering,
error
};
Project(const std::filesystem::path& location, const std::filesystem::path& destination);
~Project();
bool read();
void discover();
State getStatus() const;
std::string getName() const;
uint32_t dependenciesCount() const;
static void log(Logger::Severity severity, const std::string& message);
static void debug(const std::string& message);
static void info(const std::string& message);
static void minor(const std::string& message);
static void major(const std::string& message);
static void warn(const std::string& message);
static void error(const std::string& message);
static void fatal(const std::string& message);
static void printLog();
static void addProject(const std::filesystem::path& location, const std::filesystem::path& destination);
private:
Project(const std::filesystem::path& location, const std::filesystem::path& destination, Project* parent);
void parse(const nlohmann::json& json);
void createDepencencyFromString(const std::string& entry);
void createDepencencyFromObject(const nlohmann::json& entry);
private:
Project* parent;
std::filesystem::path location;
std::filesystem::path destination;
State state;
std::string name;
std::map<std::string, Dependency> dependencies;
const bool root;
static Logger* logger;
};