[vtkusers] Cross Delegation with vtkSQLDatabase
David Thompson
dcthomp at sandia.gov
Mon Nov 15 13:35:35 EST 2010
> I'm wanting to do something similar to this. I'm guessing part of the
> reason why I can't is because vtkSQLiteDatabase, vtkMySQLDatabase etc
> etc don't virtually inherit vtkSQLDatabase?
Yes, that's correct; since pretty much everything in VTK inherits
vtkObject, inheriting multiple subclasses of vtkObject leaves a bunch
of methods the compiler cannot unambiguously resolve. I suspect that
virtual inheritance was not supported by all the compilers that VTK
supports (the list changed over the last year so that may no longer be
true), and at least some compilers produce code which adds overhead
otherwise avoided without virtual inheritance. At least for now,
you're probably stuck owning an instance of vtkSQLDatabase instead of
inheriting it.
David
> ----------
> #include "vtkSQLDatabase.h"
> #include "vtkSQLiteDatabase.h"
> #include "vtkMySQLDatabase.h"
>
> class mySQLDatabase : public virtual vtkSQLDatabase
> {
> bool foo()
> {
> //do foo
> return true;
> }
> };
>
> class mySQLiteDatabase : public vtkSQLiteDatabase, public
> mySQLDatabase
> {
> };
>
> class myMySQLDatabase : public vtkMySQLDatabase, public mySQLDatabase
> {
> };
>
> int main()
> {
> mySQLiteDatabase database();
> database.foo();
> }
> ----------
>
> Is this something VTK should try to accommodate? Or is there already a
> way of doing this?
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
More information about the vtkusers
mailing list