[odb-users] Re: Handling pimpl idiom in ODB
Uwe Kindler
uwe_kindler at web.de
Wed Aug 17 13:28:16 EDT 2011
Hi Boris,
I think your first approach, making only the 'impl' class an ODB object
will not work. Because then I cannot use the public interface class in a
relation because ODB does not know anything about the interface class.
That means I cannot have another persistent class that has a one to many
or one to one relation to my COdbPimplTest interface class. Exactly this
was the reason I made the private impl class as well as the public
interface class ODB objects.
When I first thought about this problem, I tried to solve it with a
composite value type. That means I thought of the private impl class as
a composite value type. But it was not possible to use a pointer to a
composite value type so I decided to go the persistent object way.
Regarding the second approach I have a question. The keyword virtual
does not mean, that it will be a virtual method, or does it? If it would
be a virtual method then it would not work because virtual methods also
break binary compatibility. So I assume the keyword virtual simply
identifies virtual ODB members.
As long as the accessor and modifier expressions are non virtual private
or protected C++ methods, I don't see any issues at the moment. The
problem with the second approach is, that it would cause a lot of
pragmas for the accessors and modifiers. At the moment one big plus for
ODB is that I can make a class persistent with a minimum number of changes:
Often
#pragma db object
#pragma db id auto
friend class odb::access;
are the only thing you need to make a class persistent. An then I would
need to write a pragma for each member. This won't make the more
beautiful ;O). But if it works, I think it would be o.k.
What do you think about the composite value approach. Would it be
possible to implement pointers to composite values?
Kind Regards,
Uwe
More information about the odb-users
mailing list