[odb-users] Enum encapsulation + getters / setters + query

Andreas Pasternak a.pasternak at mt-robot.com
Thu Feb 11 03:32:21 EST 2016


Hello Boris,

Thank you for your fast and precise answer!

It would be great if I could test a pre-release version.

Best regards,

Andreas

On 09.02.2016 15:00, Boris Kolpackov wrote:
> Hi Andreas,
>
> Andreas Pasternak <a.pasternak at mt-robot.com> writes:
>
>> typedef safe_enum<SomeEnum_impl> Some_Enum;
>> Some_Enum  event_type;
>>
>> #pragma db value(Some_Enum) definition
>> #pragma db member(Some_Enum::val) get(underlying) set(set)
>>
>> /../odb_query.h:370:23: error: no match for ‘operator==’ [...]
> You have mapped it as a composite type and ODB doesn't support
> comparing composite types to anything but themselves in queries
> (which is what you normally want).
>
> This mapping is also conceptually not quite correct (Some_Enum
> "is a" SomeEnum_impl, not "has a" SomeEnum_impl).
>
> In the upcoming version this will be pretty easy to implement
> using the type mapping pragma:
>
> #pragma db map type(Some_Enum) as(SomeEnum_impl)  \
>      to((?).underlying ()) from(Some_Enum (?))
>
> In the current version the only way to achieve the same is either
> by using virtual data members (but then you will have to repeat
> the same thing for each data member) or by providing a value_traits
> specialization. Neither option is particularly appealing, so maybe
> a pre-release is the answer? I can package one if you would like.
>
> Boris



More information about the odb-users mailing list