Boost logo

Boost :

From: Alexander Nasonov (alnsn-mycop_at_[hidden])
Date: 2003-07-09 08:03:08


Alexander Nasonov wrote:
> class base_node // represent a base of a concrete class
> {
> // ...
>
> //
> virtual void* derived_to_base(void* base_ptr) const = 0;
> };

Oops, I made a little naming mistake: base_ptr should be derived_ptr.

BTW, compile-time retrospection could be used to find library-specific
constructor. For example, Driver could have it:

class Driver : public Person
{
    std::string licence_id;
    Date licence_issue_date;

  public:

    Driver(const raw_object& raw)
      : Person(raw)
      , licence_id(raw.get(&Driver::licence_id))
      , licence_issue_date(raw.get(&Driver::licence_issue_date))
    {
    }

    // ..
};

If this information isn't available at compile-time you have to tell the
framework about the constructor:

void describe_Driver(descriptor<Driver>& class_)
{
    class_("Driver").derived_from<Person>()
    [
        constructor<const raw_object&>(), // here
        member(&Driver::licence_id, "licence_id"),
        member(&Driver::licence_issue_date, "licence_issue_date")
    ];
}

-- 
Alexander Nasonov
Remove minus and all between minus and at from my e-mail for timely response

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk