Mirror reflection library 0.5.13
|
The aim of this tutorial is to show how to write a plugin for the factory generator utility, that will allow to generate factories using a database dataset as the source of data for instance construction.
More specifically the factory generator together with this plugin will allow to instantiate factory classes for various Product
types. These factories will be able to create instances of a Product
by taking a valid and open dataset resulting from an SQL query on a database, checking the available data, comparing them with the constructor signatures of the Product
type, choosing the most appropriate constructor and using it to create and return an instance. If the dataset contains multiple rows, then multiple instances can be created by the same factory, by externally traversing the dataset.
The basic principles of the factory generator, necessary for the understanding of this tutorial can be found in Factory generator utility, more information about factories generally and factories generated by the factory generator utility can be found in Factories and factory generators in-depth.
The whole working source explained by this tutorial can be found in the files included by the utils/sql_factory.hpp
header in Mirror's source directory. The SOCI and libpq-based factory generator plugins, that are included with Mirror in the utils
subdirectory are derived from this general SQL-factory plugin.
TODO: finish this