Mirror reflection library 0.5.13

Writing an SQL-based factory generator plugin from scratch

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


Copyright © 2006-2011 Matus Chochlik, University of Zilina, Zilina, Slovakia.
<matus.chochlik -at- fri.uniza.sk>
<chochlik -at -gmail.com>
Documentation generated on Fri Dec 16 2011 by Doxygen (version 1.7.3).
Important note: Although the 'boostified' version of Mirror uses the Boost C++ libraries Coding Guidelines and is implemented inside of the boost namespace, it IS NOT an officially reviewed and accepted Boost library. Mirror is being developed with the intention to be submitted for review for inclusion to the Boost C++ libraries.