[odb-users] Pimpl idiom and index definition pragma

dieter.govaerts at bricsys.com dieter.govaerts at bricsys.com
Thu Jun 25 03:49:23 EDT 2015


Hello everyone,

I'm using the pimpl idiom for my classes but I can't get to define a unique index over multiple columns with it.

enum ObjectType {
    //...
};

#pragma db object transient
class CustomProperty
    : public std::enable_shared_from_this<CustomProperty>
{
public:
    unsigned int id() const;

    String const & name() const;
    void name(String const & value);

    ObjectType object_type() const;

private:
    #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

    friend class odb::access;

public:
    ~CustomProperty();

protected:
    class Impl;
    CustomProperty();
    CustomProperty(Impl *);

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

How can I solve this?

Thanks in advance.

Dieter Govaerts




More information about the odb-users mailing list