Loading...
Searching...
No Matches
Manifest.h
Go to the documentation of this file.
1// Copyright (c) 2025 Dave R. Smith. All rights reserved.
2// Malena Framework — Proprietary Software. See LICENSE for terms.
3
4#ifndef MALENA_MANIFEST_H
5#define MALENA_MANIFEST_H
6
7#pragma once
8
10#include <unordered_map>
11#include <memory>
12#include <string>
13#include <type_traits>
16
17namespace ml
18{
51 {
52 public:
53 // ── Retrieval ─────────────────────────────────────────────────────────
54
55 template<typename Asset>
56 static const std::string& getFilepath(const Asset& asset);
57
58 template<typename ConfigType, typename ValueType>
59 static const ValueType& getConfig(ConfigType config);
60
68 template<typename EnumType>
69 static const ThemeTag& getTheme(EnumType key);
70
71 protected:
72 // ── Registration ──────────────────────────────────────────────────────
73
75 template<typename EnumType>
76 static void set(EnumType key, const char* filepath);
77
79 template<typename EnumType>
80 static void set(EnumType key, std::string value);
81
88 template<typename EnumType, typename ValueType>
89 static std::enable_if_t<
90 !std::is_same_v<std::decay_t<ValueType>, const char*> &&
91 !std::is_same_v<std::decay_t<ValueType>, std::string> &&
92 !std::is_base_of_v<ThemeTag, std::decay_t<ValueType>>
93 >
94 set(EnumType key, ValueType&& value);
95
102 template<typename EnumType, typename T>
103 static std::enable_if_t<std::is_base_of_v<ThemeTag, std::decay_t<T>>>
104 set(EnumType key, T&& value);
105
107 template<typename E, typename V, typename... Args>
108 static void set(E key, V&& value, Args&&... args);
109
110 private:
111 template<typename Asset>
112 static std::unordered_map<Asset, std::string, EnumClassHash>& getFilePaths();
113
114 template<typename ConfigType, typename ValueType>
115 static auto& getConfigs();
116
117 template<typename EnumType>
118 static auto& getThemes();
119 };
120
121} // namespace ml
122
123#include "../../../src/Manifests/Manifest.tpp"
124#endif // MALENA_MANIFEST_H
Base class for all Malena manifests.
Definition Manifest.h:51
static std::enable_if_t< std::is_base_of_v< ThemeTag, std::decay_t< T > > > set(EnumType key, T &&value)
Register a Theme-derived value.
static const ValueType & getConfig(ConfigType config)
static const ThemeTag & getTheme(EnumType key)
Retrieve a theme stored via set(key, ThemeDerived{}).
static void set(EnumType key, std::string value)
Register a string configuration value.
static std::enable_if_t< !std::is_same_v< std::decay_t< ValueType >, const char * > &&!std::is_same_v< std::decay_t< ValueType >, std::string > &&!std::is_base_of_v< ThemeTag, std::decay_t< ValueType > > > set(EnumType key, ValueType &&value)
Register a typed configuration value (int, float, struct, etc.).
static const std::string & getFilepath(const Asset &asset)
static void set(E key, V &&value, Args &&... args)
Register multiple key-value pairs in one call.
static void set(EnumType key, const char *filepath)
Register an asset file path.
#define MALENA_API
Definition Component.h:22
Lightweight polymorphic base for all Theme structs.
Definition ThemeTag.h:27