scummvm/scummvm — pull request #371 by lordhoto (2013-08-08 03:30:07+00:00)
Title: Proof-of-Concept: Config manager notifications

As the title suggest this implements notifications support in ConfigManager.

The idea behind this is as follows: Client code might want to know whenever a specific config value is changed. An example for this might be the backend looking to see whether gfx_mode is changed while the options menu is open, in case it sees a change this could automatically switch the mode without our GUI code pushing this change to the backend on its own. As you can see currently, such client code would need to poll for such changes (or hope that someone third-party is calling the client code when it *might* have changed, as in case of the GUI). In general, I think this can be useful when we want to turn our GUI into a proper view/controller of the configuration without it needing special handling for applying various config options.

The implementation itself currently only notifies about "global" changes, i.e. whenever a value for a certain key is changed on the level of ConfMan.get(key). Individual domain changes are not yet notified. (I am not sure whether we actually need the latter anyway...). I think the implementation is rather hacky, but it seems our ConfigManager in general is a bit... well... not so nice. Thus, I consider this a proof-of-concept. (It's also only roughly tested with the horrible hacky commit (c9964f676f82f41ebe6cf80f1124495badce928a) I added which makes some simply output functions watch gfx_mode and mute)

Possible things to wonder about are:

* Do we want more fine grained notifications?

* How can we make this whole code cleaner? (i.e. this Domain::_owner is rather annoying, but I don't see too much of an option around it right now)

* Is this actually an improvement? (At least I think it makes sense, it was a "todo" in the class' docs and fuzzie seemed to like it too).