[odb-users] private data members, accessors, and transient
Boris Kolpackov
boris at codesynthesis.com
Fri May 30 11:38:15 EDT 2014
Hi,
MM <finjulhich at gmail.com> writes:
> class C {
> ... m1() const;
> void m1(...); /// with the right signatures
>
> ... m2() const;
> void m2(...); /// with the right signatures
> private:
> ...
> };
>
> // non instrusive
> #pragma db value(C) definition transient
> #pragma db member(C::m1)
> #pragma db member(C::m2)
>
> This will make all the internal data members transient, but will store m1
> and m2 in the database when C is persisted?
No, if you mark an object of composite value transient, then this is
equivalent to marking all real (that is, no-virtual) data members as
transient. And none of them will be stored in the database. Only
virtual data members will be stored. This feature is primarily useful
for supporting things like the pimpl idiom (see the 'pimpl' example
in the odb-examples package).
You seem to be over-thinking things. In your case, normally, all you
need to do is this:
#pragma db value(C)
The ODB compiler will then discover and use the m1() and m2() accessors
and modifiers to store the data members.
Boris
More information about the odb-users
mailing list