[odb-users] Object loading view defined in a separate file: object_statements is not being instantiated

Aarón Bueno Villares abv150ci at gmail.com
Thu Apr 28 23:50:48 EDT 2016


I have a persistent class called wamo::model_db (wamo is a namespace),
defined in a file called metamodel-db.hpp (model-db.{h,c,i}pp are the names
of the generated files, without the `meta` prefix). Each meta* file has
some object loading views defined inside. Every thing works fine.

I have also another persistent class called wamo::colormodel_db, which has
a shared_ptr<model_db> member (with its corresponding relantionship defined
in the database). So, the metacolormodel-db.hpp file includes the file of
model-db, and also it contains its own object loading views. Finally, we
have wamo::resourcemodel_db, defined in metaresourdemodel-db.hpp, with same
features. Everything works fine here as well.

The thing is that I want to add I new object loading view in a separated
file, called metamodel-searcher-db.hpp, which relates (with join clauses
and so on), model, colormodel and resourdemodel. Every dependence is
included. The error the compiler throws to me when compiling the generated
file is:

/usr/local/include/odb/mysql/statement-cache.txx:33:57: error: invalid
static_cast from type ‘odb::mysql::statements_base’ to type
‘statements_type& {aka odb::mysql::object_statements<wamo::model_db>&}’
         return static_cast<statements_type&> (*i->second);
                                                         ^
/usr/local/include/odb/mysql/statement-cache.txx:36:54: error: invalid use
of incomplete type ‘statements_type {aka class
odb::mysql::object_statements<wamo::model_db>}’
         new (details::shared) statements_type (conn_));
                                                      ^
In file included from blablabla, blablabla, blablabla from
model-searcher-db.cpp:7:
/usr/local/include/odb/mysql/forward.hxx:54:11: error: declaration of
‘statements_type {aka class odb::mysql::object_statements<wamo::model_db>}’
     class object_statements;

So, the `object_statements` template is not being instantiated.

The problem is not related to this exact relationship, because if, instead
of putting that view in a separated file, I move it to any other file
(provide it includes directly or indirectly all the required
`object(...)`s), it compiles without problems.

The only difference between that file and the other ones (for example, if I
define that view within colormodel-db.hpp), is that that separeted file has
no "persistent classes" defined in the same file, and I think that is
somehow making that that template is not being instantiated.

What can I do to make it work? I need it is in a separated file for other
reasons out of scope in that post.

Best regards,
Peregring-lk.


More information about the odb-users mailing list