Hello to be make it easy to read a table from a database
and save the result with boost serialization (and to write back back to
the database)
I have devised a scheme to achieve C++ reflections
that allows me to set a field value and get a field
value using a string data member name.
I am using the fact that in C++ functions can take
a reference to a class instance and operate on the
class data members, where the functions have
hardcoded the datamember names.
Since those functions can be declared as static,
I simply remember the pointer to my getters and setters
in static maps associated with every class instance
So when a class instance gets created -- it updates
the static maps of getters and setters.
I do not like the fact that I have to use a mutex on the
function maps.
ANd in general wanted to ask if such approach has been implemented
in one of the boost libraries or if not ... why not
I am attaching a 'brief' of the mechanism. Thank you in advance
for any feedback.
Vlad
-------------------------------------------------------------
struct tField
{
string name;
//other DB-related attributes
//order of declaration, isnullable, otltype
}
struct reflectable
{
//returns a string name of the field
char* (*tF_get_field_name)(void),
//assign a value to the field. The value is obtained from functor
//that's why we call it 'set'
typedef void (*tFset__field)(reflecatble& , CFFunctorAssignVal&) ;
//send the field value (const) to somewhere
//that's why we call it 'get'
typedef void (*tFget__field)(const reflectable&,CFFunctorReceiveVal&)
;
typedef map