mikee47 / ConfigDB

Configuration database for Sming
GNU General Public License v3.0
3 stars 1 forks source link

Move store creation and loading logic into Database instance #9

Closed mikee47 closed 2 months ago

mikee47 commented 2 months ago

This PR removes Store class definitions from the generated code and moves all the Store opening and loading logic into the Database.

Rather than just maintaining a weak_ptr for each store type, the Database keeps a single strong shared_ptr for the most recently opened store. This gets disposed using the task queue so doesn't hang around long, but accommodates the most likely scenario where multiple database accessess occur in succession.

The json schema annotation is now just used as a marker and can be set to anything (typically just true). Applications can create their own Database implementation and customise by overriding the createStore method.

This also allows some simplification to the generator script.