Inherited relations

Forum for posting problems using QxOrm library

Inherited relations

Postby BlackSoul » Thu Jul 03, 2014 6:42 am

Hi.
Have a "little" question.
Have code like this

base.h
Code: Select all
class QX_TEST_DLL_EXPORT Base
    {
        QX_REGISTER_FRIEND_CLASS(domain::Base)
    public:
        int getA() const { return m_a;}
        void setA(int a) { m_a = a; }
    protected:
       int m_a;
};
QX_REGISTER_HPP_QX_TEST(Base, qx::trait::no_base_class_defined, 0, base)

base.cpp
Code: Select all
QX_REGISTER_CPP_QX_TEST(domain::Base, base)

namespace qx
{
    template <> void register_class(QxClass<Base>& t)
    {
        t.data(&Base::m_a, "a");
    }
}

derived.h
Code: Select all
class QX_TEST_DLL_EXPORT Derived : public Base
    {
        QX_REGISTER_FRIEND_CLASS(domain::Derived)
    public:
        int getB() const { return m_b;}
        void setB(int a) { m_b = b; }

       void debug();
    protected:
       int m_b;
};
QX_REGISTER_HPP_QX_TEST(Derived, Base, 0, derived)

derived.cpp
Code: Select all
QX_REGISTER_CPP_QX_TEST(domain::Derived, derived)

namespace qx
{
    template <> void register_class(QxClass<Derived>& t)
    {
        t.setName("some_table")
        t.data(&Derived::m_b, "b");
    }
}

void Derived::debug()
{
           for (int i = 0; i < this->qxClass()->getDataMemberX()->count(); ++i)
           {
               qx::IxDataMember* cx = this->qxClass()->getDataMemberX()->get(i);
               qDebug() << cx->getKey() << cx->getName();
           }
}


and when i try in my code to execute Derived::debug() i see only "b", not "a".
Can I someway see "b" and "a" at same time?

Thanks.
BlackSoul
 
Posts: 6
Joined: Tue Dec 17, 2013 6:14 am

Re: Inherited relations

Postby qxorm » Thu Jul 03, 2014 3:46 pm

Hello,

and when i try in my code to execute Derived::debug() i see only "b", not "a".
Can I someway see "b" and "a" at same time?

Yes, it is possible !

Replace : this->qxClass()->getDataMemberX()->count()
By : this->qxClass()->getDataMemberX()->count_WithDaoStrategy()

And replace : this->qxClass()->getDataMemberX()->get(i)
By : this->qxClass()->getDataMemberX()->get_WithDaoStrategy(i)
qxorm
Site Admin
 
Posts: 481
Joined: Mon Apr 12, 2010 7:45 am


Return to QxOrm - Help

Who is online

Users browsing this forum: No registered users and 12 guests