20 #include "pedigree/kernel/config/ConfigurationManager.h" 21 #include "pedigree/kernel/config/ConfigurationBackend.h" 22 #include "pedigree/kernel/processor/types.h" 23 #include "pedigree/kernel/utilities/Result.h" 24 #include "pedigree/kernel/utilities/new" 28 ConfigurationManager::ConfigurationManager() : m_Backends()
32 ConfigurationManager::~ConfigurationManager()
41 size_t ConfigurationManager::createTable(
46 m_Backends.
lookup(configStore);
47 if (!result.hasValue())
49 return result.value()->createTable(table);
58 m_Backends.
lookup(configStore);
59 if (!result.hasValue())
61 return result.value()->
insert(table, key, value);
71 m_Backends.
lookup(configStore);
72 if (!result.hasValue())
74 return result.value()->select(table, key);
79 ConfigurationWatcher watcher)
83 m_Backends.
lookup(configStore);
84 if (!result.hasValue())
86 return result.value()->watch(table, key, watcher);
91 ConfigurationWatcher watcher)
95 m_Backends.
lookup(configStore);
96 if (!result.hasValue())
98 return result.value()->unwatch(table, key, watcher);
101 bool ConfigurationManager::installBackend(
109 const String &realConfigStore =
110 configStore.length() ? configStore : pBackend->getConfigStore();
113 if (!backendExists(realConfigStore))
115 m_Backends.insert(realConfigStore, pBackend);
122 void ConfigurationManager::removeBackend(
const String &configStore)
126 m_Backends.
lookup(configStore);
127 if (!result.hasValue())
131 m_Backends.remove(configStore);
132 delete result.value();
135 bool ConfigurationManager::backendExists(
const String &configStore)
137 return m_Backends.lookup(configStore).hasValue();
void insert(const String &configStore, const String &table, const String &key, const ConfigValue &value)
A key/value dictionary for string keys.
void watch(const String &configStore, const String &table, const String &key, ConfigurationWatcher watcher)
void insert(const String &key, const T &value)
Result< T, bool > lookup(const String &key) const
void unwatch(const String &configStore, const String &table, const String &key, ConfigurationWatcher watcher)
ConfigValue & select(const String &configStore, const String &table, const String &key)