[odb-users] Pimpl idiom and index definition pragma

Boris Kolpackov boris at codesynthesis.com
Thu Jun 25 07:52:20 EDT 2015


Hi Dieter,

dieter.govaerts at bricsys.com <dieter.govaerts at bricsys.com> writes:

> #pragma db object transient
> class CustomProperty
> {
>
>     ...
>
>     #pragma db id auto
>     #pragma db member(id) virtual(unsigned int) get(this.impl().m_id) set(this.impl().m_id)
>     #pragma db member(name) virtual(String) access(this.impl().m_name)
>     #pragma db member(object_type) virtual(ObjectType) get(this.impl().m_object_type) set(const_cast< bim_lib::ObjectType & >(this.impl().m_object_type))
>     #pragma db index("object_type_name_i") member(impl_.m_object_type) member(impl_.m_name) unique
> 
> private:
>     Impl * const impl_;
> };
> 
> No mater what I try to put between the member clauses for the 
> object_type_name_i index, it always fails with the error: 
> 
> bim_lib_custom_props.h:48:44: error: data member 'impl_' specified
> in db pragma member is not composite

Your impl_ member is transient. Indexes can only be based on the
persistent members. In your case, you should just use the virtual
members:

#pragma db index("object_type_name_i") members(object_type, name) unique

Nice and simple.

Boris



More information about the odb-users mailing list