[vtk-developers] CanReadFile : various signatures...

Moreland, Kenneth kmorel at sandia.gov
Tue Aug 3 12:16:14 EDT 2010


My vote is static.  The point of CanReadFile is so that you can call a function that will tell you whether a particular reader class can read a particular file.  In this context, static provides two very important features:

1. You can use the static method to determine whether you can use the reader class before you have to instantiate it.

2. Declaring the method static prevents the CanReadFile from using the state of any object instance, which it really really really shouldn't do.

-Ken


On 7/30/10 2:49 PM, "David Gobbi" <david.gobbi at gmail.com> wrote:

I gotta wonder why gcc and msvc don't give warnings about "unusual"
overrides like this.  Ditto for other situations that commonly arise
and cause headaches:

1) when a subclass overrides just a single signature for a methods,
instead of overriding all signatures like it should

2) when a subclass overrides a signature but provides a different return type

Hey, this is another thing that the wrappers could do.  There could be
a tool that parses all header files and give warnings/errors whenever
it finds a suspicious override.

My vote is for virtual, not because it is better, but because it is
more common and there is probably more code out there that expects
this method to be virtual.  But the methods that are already static
should remain static.

   David


On Fri, Jul 30, 2010 at 2:05 PM, David Cole <david.cole at kitware.com> wrote:
> Running the command shown at the bottom of this email reveals that various
> different signatures of CanReadFile are present in VTK.
>
> Is there a preferred one that all readers should aspire to?
>
> Should it be "static" or "virtual"?
>
> In the case of classes that inherit from each other, it should be the same,
> shouldn't it?
>
> The particular case that I have a beef with is
> ./IO/vtkEnSightMasterServerReader.h:  int CanReadFile(const char *fname);
>
> which inherits from:
> ./IO/vtkGenericEnSightReader.h:  static int CanReadFile(const char
> *casefilename);
>
> Because the child class method is not static, I get a "hides parent method"
> warning when building ActiViz .NET.
> Would the owner of this class mind if the method became static...? Or is
> that not advisable for backwards compatibility reasons...?
>
>
> Thanks,
> David C.
>
>
> Details:
>
> $ find . | grep "\.h$" | xargs grep CanReadFile
> ./Hybrid/vtkExodusIIReader.h:  int CanReadFile(const char* fname);
> ./Hybrid/vtkExodusReader.h:  int CanReadFile(const char* fname);
> ./Hybrid/vtkFacetReader.h:  static int CanReadFile(const char *filename);
> ./Hybrid/vtkLSDynaReader.h:  int CanReadFile( const char* fname );
> ./IO/vtkBMPReader.h:  virtual int CanReadFile(const char* fname);
> ./IO/vtkBYUReader.h:  static int CanReadFile(const char *filename);
> ./IO/vtkDICOMImageReader.h:  virtual int CanReadFile(const char* fname);
> ./IO/vtkEnSightMasterServerReader.h:  int CanReadFile(const char *fname);
> ./IO/vtkGenericEnSightReader.h:  static int CanReadFile(const char
> *casefilename);
> ./IO/vtkGESignaReader.h:  virtual int CanReadFile(const char* fname);
> ./IO/vtkImageReader2.h:  virtual int CanReadFile(const char*
> vtkNotUsed(fname))
> ./IO/vtkImageReader2Factory.h:// object given a path name to a file.  It
> calls CanReadFile on all
> ./IO/vtkJPEGReader.h:  int CanReadFile(const char* fname);
> ./IO/vtkMetaImageReader.h:  virtual int CanReadFile(const char* name);
> ./IO/vtkMINCImageReader.h:  virtual int CanReadFile(const char* name);
> ./IO/vtkNetCDFCFReader.h:  static int CanReadFile(const char *filename);
> ./IO/vtkOpenFOAMReader.h:  int CanReadFile(const char *);
> ./IO/vtkPLYReader.h:  static int CanReadFile(const char *filename);
> ./IO/vtkPNGReader.h:  virtual int CanReadFile(const char* fname);
> ./IO/vtkPNMReader.h:  int CanReadFile(const char* fname);
> ./IO/vtkSLACParticleReader.h:  static int CanReadFile(const char *filename);
> ./IO/vtkSLACReader.h:  static int CanReadFile(const char *filename);
> ./IO/vtkSLCReader.h:  int CanReadFile(const char* fname);
> ./IO/vtkTIFFReader.h:  virtual int CanReadFile(const char* fname);
> ./IO/vtkXMLCompositeDataReader.h:  virtual int CanReadFileVersion(int major,
> int vtkNotUsed(minor))
> ./IO/vtkXMLReader.h:  virtual int CanReadFile(const char* name);
> ./IO/vtkXMLReader.h:  virtual int CanReadFileVersion(int major, int minor);
> ./IO/vtkXMLReader.h:  int CanReadFileVersionString(const char* version);
> ./IO/vtkXYZMolReader.h:  virtual int CanReadFile(const char* name);
> ./Parallel/vtkPDataSetReader.h:  int CanReadFile(const char* filename);
> ./Parallel/vtkPNrrdReader.h:  virtual int CanReadFile(const char *filename);
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtk-developers
>
>
>
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtk-developers





   ****      Kenneth Moreland
    ***      Sandia National Laboratories
***********
*** *** ***  email: kmorel at sandia.gov
**  ***  **  phone: (505) 844-8919
    ***      web:   http://www.cs.unm.edu/~kmorel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20100803/2d502f3b/attachment.html>


More information about the vtk-developers mailing list