mirror of
https://github.com/sebastiandine/Card-Collection-Manager-3.git
synced 2026-08-31 01:48:50 +00:00
major: initial release
* initial development * pipeline * pipeline * pipeline * pipeline * pipeline * pipeline * pipeline * pipeline * pipeline * pipeline * pipeline * pipeline * pipeline * pipeline * ci/cd * ci/cd * ci/cd * ci/cd * ci/cd * ci/cd * ci/cd * pokemon * pokemon * pokemon * pokemon * pokemon * pokemon * improvements * improvements * ci/cd * ci/cd * improvements * improvements * improvements * improvements * improvements * improvements * improvements * improvements * improvements --------- Co-authored-by: sdine <sdine@sdine.com>
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
#pragma once
|
||||
|
||||
// ConfigService: owns the live `Configuration`, persists it to `config.json`
|
||||
// next to the executable. Mirrors `util/config.rs` behavior - a missing file
|
||||
// is auto-created with sensible defaults on first launch.
|
||||
|
||||
#include "ccm/domain/Configuration.hpp"
|
||||
#include "ccm/ports/IFileSystem.hpp"
|
||||
#include "ccm/util/Result.hpp"
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
namespace ccm {
|
||||
|
||||
class ConfigService {
|
||||
public:
|
||||
// `configFilePath` is the absolute path to `config.json`. The defaults
|
||||
// applied to a freshly created config use `defaultDataStorage` for the
|
||||
// dataStorage field.
|
||||
ConfigService(IFileSystem& fs,
|
||||
std::filesystem::path configFilePath,
|
||||
std::filesystem::path defaultDataStorage);
|
||||
|
||||
// Load (or create) the configuration. Must be called once at startup.
|
||||
Result<void> initialize();
|
||||
|
||||
[[nodiscard]] const Configuration& current() const noexcept { return current_; }
|
||||
|
||||
// Replace the live configuration and persist immediately.
|
||||
Result<void> store(Configuration cfg);
|
||||
|
||||
private:
|
||||
IFileSystem& fs_;
|
||||
std::filesystem::path path_;
|
||||
std::filesystem::path defaultDataStorage_;
|
||||
Configuration current_{};
|
||||
|
||||
[[nodiscard]] Configuration makeDefault() const;
|
||||
};
|
||||
|
||||
} // namespace ccm
|
||||
Reference in New Issue
Block a user