Skip to content
Hans Kirchner edited this page Nov 29, 2015 · 5 revisions

The config monitor is a framework feature that monitors all *.lconf and *.xml files and reloads all if any of them changes.

Enable the config monitor

The config monitor is enabled by default.

Behavior

Since configs are lms::ModuleConfig objects that are stored as data channels in the DataManager they can be updated any time. The configsChanged() will be invoked on all modules in case of config changes.

ConfigObserver

The lms::ConfigObserver informs modules of changes to specified keys.

class MyModule : public lms::Module {
private:
  lms::ConfigObserver observer;
public:
  bool initialize() override {
    // give the observer the config handle
    observer.init(&config());

    // set all keys that should be observed
    observer.keys({"width", "height"});

    // listener function that gets called
    // whenever one of keys changed
    observer.listener([this](const std::string &key) {
      logger.log("keyChanged") << key;
    });
    return true;
  }

  void configsChanged() override {
    // inform the observer
    observer.changed();
  }
}