Project

General

Profile

Base classes and DBO.

Added by Plug Gulp over 1 year ago

Is there a way to use base classes in Dbo::ptr and then use that for defining relationships between derived entities? For example:

class base_a
{
    public:
      void persist()
      {
         relation(b_ptr); // some relation with B
      }

      void set_b(Dbo::ptr<base_b> p)
      {
         b_ptr = p;
      }

    private:
      Dbo::ptr<base_b> b_ptr;
};

class base_b
{
    public:
      void persist()
      {
         relation(a_ptr); // some relation with A
      }

      void set_a(Dbo::ptr<base_a> p)
      {
         a_ptr = p;
      }

    private:
      Dbo::ptr<base_a> a_ptr;
};

class derived_a : public base_a
{
  // extend A
};

class derived_b : public base_b
{
  // extend B
};

base_a a_ptr = new derived_a;
base_b b_ptr = new derived_b;

a_ptr->set_b(b_ptr);
b_ptr->set_a(a_ptr);

Is this type of design possible with DBO? If not, then what are the alternatives to design a hierarchy of DBO classes?