Ember
Loading...
Searching...
No Matches
ConfigManager.h
Go to the documentation of this file.
1#pragma once
2
4#include "Types/Types.h"
5#include <map>
6#include <memory>
7#include <mutex>
8#include <vector>
9
10namespace EmberCore {
11
19 public:
20 // Singleton access
21 static ConfigManager &GetInstance();
22
23 // Prevent copying
24 ConfigManager(const ConfigManager &) = delete;
26
27 // Profile management
28 bool LoadProfiles();
29 bool SaveProfiles();
30 bool SaveProfile(const String &profile_name);
31
32 // Add/Remove profiles
33 bool AddProfile(std::shared_ptr<ParserProfile> profile);
34 bool RemoveProfile(const String &profile_name);
35 bool RenameProfile(const String &old_name, const String &new_name);
36
37 // Profile access
38 std::shared_ptr<ParserProfile> GetProfile(const String &profile_name) const;
39 std::shared_ptr<ParserProfile> GetActiveProfile() const;
40 std::vector<String> GetProfileNames() const;
41 bool HasProfile(const String &profile_name) const;
42
43 // Active profile management
44 bool SetActiveProfile(const String &profile_name);
46
47 // Import/Export individual profiles
48 bool ExportProfile(const String &profile_name, const String &filepath);
49 bool ImportProfile(const String &filepath, bool make_active = false);
50
51 // Utility
54 void ResetToDefaults();
55
56 // Profile count
57 size_t GetProfileCount() const { return profiles_.size(); }
58
59 private:
61 ~ConfigManager() = default;
62
63 // Initialize default profiles if none exist
65
66 // Config file operations
67 bool LoadConfigFile();
68 bool SaveConfigFile();
69
70 // Get profile file path
71 String GetProfileFilePath(const String &profile_name) const;
72
73 // Load a single profile from file
74 std::shared_ptr<ParserProfile> LoadProfileFromFile(const String &filepath);
75
76 // Internal helper methods (caller must hold mutex_)
77 std::shared_ptr<ParserProfile> GetProfileInternal(const String &profile_name) const;
78 bool HasProfileInternal(const String &profile_name) const;
81
82 // Thread safety
83 mutable std::mutex mutex_;
84
85 // Data members
86 std::map<String, std::shared_ptr<ParserProfile>> profiles_;
89 String config_file_; // Main config file (stores active profile and other settings)
90
91 // Default profile names
94};
95
96} // namespace EmberCore
String GetProfileFilePath(const String &profile_name) const
std::shared_ptr< ParserProfile > GetActiveProfile() const
std::shared_ptr< ParserProfile > LoadProfileFromFile(const String &filepath)
String GetProfilesDirectory() const
bool SaveProfile(const String &profile_name)
bool SetActiveProfile(const String &profile_name)
static const String GENERIC_PROFILE_NAME
ConfigManager & operator=(const ConfigManager &)=delete
std::vector< String > GetProfileNames() const
std::shared_ptr< ParserProfile > GetProfileInternal(const String &profile_name) const
bool RemoveProfile(const String &profile_name)
bool ImportProfile(const String &filepath, bool make_active=false)
std::shared_ptr< ParserProfile > GetProfile(const String &profile_name) const
bool RenameProfile(const String &old_name, const String &new_name)
bool HasProfileInternal(const String &profile_name) const
bool AddProfile(std::shared_ptr< ParserProfile > profile)
static const String DEFAULT_PROFILE_NAME
std::map< String, std::shared_ptr< ParserProfile > > profiles_
bool HasProfile(const String &profile_name) const
size_t GetProfileCount() const
ConfigManager(const ConfigManager &)=delete
bool ExportProfile(const String &profile_name, const String &filepath)
String GetActiveProfileName() const
static ConfigManager & GetInstance()
Main types header for EmberCore.
std::string String
Framework-agnostic string type.
Definition String.h:14