summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--project2/common/optionsSource.cpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/project2/common/optionsSource.cpp b/project2/common/optionsSource.cpp
index 2461c58..d37a6c6 100644
--- a/project2/common/optionsSource.cpp
+++ b/project2/common/optionsSource.cpp
@@ -23,17 +23,28 @@ class DefaultConfigConsumer : public ConfigConsumer {
boost::posix_time::ptime OptionsSource::loadedTime = boost::posix_time::special_values::neg_infin;
+template <typename X>
+std::set<X *>
+raw(const std::set<boost::shared_ptr<X>> & xs)
+{
+ std::set<X *> y;
+ for (const auto & x : xs) {
+ y.insert(x.get());
+ }
+ return y;
+}
+
void
OptionsSource::resetOptions()
{
- auto options = AdHoc::PluginManager::getDefault()->getAll<Options>();
+ auto options = raw(AdHoc::PluginManager::getDefault()->getAll<Options>());
decltype(options) resetConfigs;
while (options != resetConfigs) {
for (auto opts : options) {
if (resetConfigs.find(opts) == resetConfigs.end()) {
opts->implementation()->reset();
resetConfigs.insert(opts);
- auto newOptions = AdHoc::PluginManager::getDefault()->getAll<Options>();
+ auto newOptions = raw(AdHoc::PluginManager::getDefault()->getAll<Options>());
if (newOptions != options) {
options = newOptions;
break;
@@ -46,8 +57,8 @@ OptionsSource::resetOptions()
void
OptionsSource::loadSources(const Options::CurrentPlatform & platform)
{
- auto configs = AdHoc::PluginManager::getDefault()->getAll<OptionsSource>();
- if (std::find_if(configs.begin(), configs.end(), [](boost::shared_ptr<const AdHoc::PluginOf<OptionsSource>> c) { return c->implementation()->modifiedTime() > loadedTime; }) != configs.end()) {
+ auto configs = raw(AdHoc::PluginManager::getDefault()->getAll<OptionsSource>());
+ if (std::find_if(configs.begin(), configs.end(), [](const AdHoc::PluginOf<OptionsSource> * c) { return c->implementation()->modifiedTime() > loadedTime; }) != configs.end()) {
resetOptions();
DefaultConfigConsumer dcc;
@@ -57,7 +68,7 @@ OptionsSource::loadSources(const Options::CurrentPlatform & platform)
if (loadedConfigs.find(c) == loadedConfigs.end()) {
c->implementation()->loadInto(dcc, platform);
loadedConfigs.insert(c);
- auto newConfigs = AdHoc::PluginManager::getDefault()->getAll<OptionsSource>();
+ auto newConfigs = raw(AdHoc::PluginManager::getDefault()->getAll<OptionsSource>());
if (newConfigs != configs) {
configs = newConfigs;
break;