Major refactor

This commit is contained in:
j
2025-12-30 08:43:06 +13:00
parent a9ccdedf89
commit b0d11eb08c
10 changed files with 84 additions and 177 deletions

View File

@@ -20,14 +20,14 @@ typedef enum template_source_type {
class template_info {
public:
template_info() : mIsSet(false) {}
template_info(const std::string& template_name, const std::string& location_id, const std::filesystem::path& local_template_path, bool fast);
template_info(const std::string& template_name, const std::string& location_id, const std::filesystem::path& local_template_path, bool skip_update);
virtual ~template_info() {}
bool is_set() const { return mIsSet; }
std::string name() const { return mTemplateName; }
std::string locationID() const { return mLocationID; }
std::filesystem::path local_template_path() const { return mTemplateLocalPath; }
std::filesystem::path local_template_info_env_path();
bool template_valid() const { return mTemplateValid; }
std::string hash() const { return mHash; }
private:
std::string mTemplateName;
@@ -35,7 +35,6 @@ class template_info {
std::filesystem::path mTemplateLocalPath; // source or cache.
bool mTemplateValid;
bool mIsSet;
std::string mHash;
};
class template_source_interface {
@@ -43,7 +42,7 @@ class template_source_interface {
virtual ~template_source_interface() {}
virtual std::set<std::string> get_template_list() = 0;
virtual bool has_template(const std::string& template_name) = 0;
virtual template_info get_template_info(const std::string& template_name, bool fast=false) = 0;
virtual template_info get_template_info(const std::string& template_name, bool skip_update=false) = 0;
virtual bool template_command_exists(const std::string& template_name,const std::string& command) = 0;
virtual std::string get_description() = 0;
@@ -57,7 +56,7 @@ class template_source_registry : public template_source_interface {
std::set<std::string> get_template_list();
bool has_template(const std::string& template_name);
template_info get_template_info(const std::string& template_name, bool fast=false);
template_info get_template_info(const std::string& template_name, bool skip_update=false);
bool template_command_exists(const std::string& template_name,const std::string& command);
std::string get_description() { return "Registry: " + mRegistry.name + " (" + mRegistry.url + ")"; }
@@ -74,7 +73,7 @@ class template_source_local : public template_source_interface {
~template_source_local() {}
std::set<std::string> get_template_list();
bool has_template(const std::string& template_name);
template_info get_template_info(const std::string& template_name, bool fast=false);
template_info get_template_info(const std::string& template_name, bool skip_update=false);
bool template_command_exists(const std::string& template_name,const std::string& command);
std::string get_description() { return "Local: " + mLocalPath.string(); }
@@ -89,7 +88,7 @@ class template_manager {
std::set<std::string> get_template_list() const;
bool has_template(const std::string& template_name) const;
template_info get_template_info(const std::string& template_name, bool fast=false) const; // fast = don't check for updates.
template_info get_template_info(const std::string& template_name, bool skip_update=false) const; // skip_update = don't check for updates.
bool template_command_exists(const std::string& template_name,const std::string& command) const;
bool create_template(const std::string& template_name) const;