[vtkusers] Too many virtual declaration in vtkCallbackCommand version 1.7.

derong derong at lycos.co.uk
Fri Jan 6 20:13:53 EST 2006


I got some points. From my understanding, vtkCallbackCommand is a kind of
final implementation of vtkComand. A client program can subclass its
SuperClass(vtkCommand) to have it's own Command implementation. Too many
virtual declaration will cause more virtual tables in instance to consume
memory.
Also it will change memory layout of this class to cause migrating
difficult. (currently I sticked to use VTK4.2.1, occasionally I checked out
new vtk to compile against my current application project, it was failure to
link after this change, I guess that  I have to rebuild all....)
 
>From my experiences with using VTK, I like to use vtkCallbackCommand for
event handling. It's good enough. No need to derive from it to create
another subclass. 

Previously, I also made some classes that were derived from vtkCommand.
Although it works,  I never use it again after I know how to use
vtkCallbackCommand. Also I think it's not good to create a deep level
subclass. That is my point.

Thx.


Dennis

  

-----Original Message-----
From: David Cole [mailto:david.cole at kitware.com] 
Sent: Thursday, January 05, 2006 12:11 PM
To: derong
Cc: vtkusers at vtk.org
Subject: Re: [vtkusers] Too many virtual declaration in vtkCallbackCommand
version 1.7.

Other virtual declarations are not meaningless... They allow for a client
program to subclass this object and override the behavior of those methods.
Personally, I'd rather see a C++ library like VTK (meant for further
subclassing and use by other programmers) err on the side of providing
slightly too many virtual methods than not quite enough. I absolutely hate
it when I go to override a method in a library class and discover that it's
not declared virtual.

Did this change to vtkCallbackCommand actually cause a problem for you? 
If you have a valid reason for not having virtual methods in that class, you
could always write your own version of it based on a prior revision of
vtkCallbackCommand... Fortunately, there's not that much code in that class.

Just my two cents,
David

derong wrote:

> Does anyone take a look at the recent change of vtkCallbackCommand?
> From my point of view, only Execute(...) needs virtual(comes from 
> superclass), other virtual declarations are meaningless and not good.
>  
>  
> Dennis
>  
>  
>
>-----------------------------------------------------------------------
>-
>
>_______________________________________________
>This is the private VTK discussion list. 
>Please keep messages on-topic. Check the 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