Subject: Re: [boost] Thoughts for a GUI (Primitives) Library
From: Gottlob Frege (gottlobfrege_at_[hidden])
Date: 2010-09-12 01:06:20


On Wed, Sep 8, 2010 at 8:31 AM, Alec Chapman <archapm_at_[hidden]> wrote:
>
> struct Employee {
>    int id,
>    string name
> };
>
> Then defining a default view might go something like this:
>
> template<>
> View default_view(Employee& e)
> {
>    View v;
>    v.set_layout(vertical_list); //accepts certain predefined layouts or an
> arbitrary function
>    v << employee.id; //add the first subview;  this calls default_view<int>
>    v.add_sub_view(default_view(employee.name)); //the previous line could
> equivalently be written like this
>    return v;
> }
>
>
> // declare the class
> typedef
>    property<employee_id_t, int,
>    property<employee_name_t, string,
>> > Employee;
>
> // create and populate
> Employee employee;
> put(employee_id, employee, 999);
> employee[employee_name] = "Joe Smith"; //alternate syntax
>

Maybe use Boost.Fusion? It can create parallel descriptions of structs.
But note also that you need more Model information - both per-field
info (min/max/default on some ints, etc), as well as relationships
between types (this is invalid when that is 0, etc).

Tony