diff options
author | Shea Levy <shea@shealevy.com> | 2018-02-13 14:43:32 -0500 |
---|---|---|
committer | Shea Levy <shea@shealevy.com> | 2018-02-13 14:43:32 -0500 |
commit | de4934ab3b26aa851b7044e9884102cc054dc092 (patch) | |
tree | 94e333d35b7d48d93bfb70f132023d6b8d3d5752 /src/libstore/globals.cc | |
parent | 3fe9767dd33499c2560d209dc13a01f5fcead1f0 (diff) |
Allow plugins to define new settings.
Diffstat (limited to 'src/libstore/globals.cc')
-rw-r--r-- | src/libstore/globals.cc | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/libstore/globals.cc b/src/libstore/globals.cc index c6b508cbe..c5a4536ef 100644 --- a/src/libstore/globals.cc +++ b/src/libstore/globals.cc @@ -161,6 +161,22 @@ void initPlugins() throw Error("could not dynamically open plugin file '%s%': %s%", file, dlerror()); } } + /* We handle settings registrations here, since plugins can add settings */ + if (RegisterSetting::settingRegistrations) { + for (auto & registration : *RegisterSetting::settingRegistrations) + settings.addSetting(registration); + delete RegisterSetting::settingRegistrations; + } + settings.handleUnknownSettings(); +} + +RegisterSetting::SettingRegistrations * RegisterSetting::settingRegistrations; + +RegisterSetting::RegisterSetting(AbstractSetting * s) +{ + if (!settingRegistrations) + settingRegistrations = new SettingRegistrations; + settingRegistrations->emplace_back(s); } |