<HTML>
<HEAD>
<TITLE>Re: [vtk-developers] CanReadFile : various signatures...</TITLE>
</HEAD>
<BODY>
<FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'>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:<BR>
<BR>
1. You can use the static method to determine whether you can use the reader class <I>before</I> you have to instantiate it.<BR>
<BR>
2. Declaring the method static prevents the CanReadFile from using the state of any object instance, which it really really really shouldn’t do.<BR>
<BR>
-Ken<BR>
<BR>
<BR>
On 7/30/10 2:49 PM, "David Gobbi" <<a href="david.gobbi@gmail.com">david.gobbi@gmail.com</a>> wrote:<BR>
<BR>
</SPAN></FONT><BLOCKQUOTE><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'>I gotta wonder why gcc and msvc don't give warnings about "unusual"<BR>
overrides like this. Ditto for other situations that commonly arise<BR>
and cause headaches:<BR>
<BR>
1) when a subclass overrides just a single signature for a methods,<BR>
instead of overriding all signatures like it should<BR>
<BR>
2) when a subclass overrides a signature but provides a different return type<BR>
<BR>
Hey, this is another thing that the wrappers could do. There could be<BR>
a tool that parses all header files and give warnings/errors whenever<BR>
it finds a suspicious override.<BR>
<BR>
My vote is for virtual, not because it is better, but because it is<BR>
more common and there is probably more code out there that expects<BR>
this method to be virtual. But the methods that are already static<BR>
should remain static.<BR>
<BR>
David<BR>
<BR>
<BR>
On Fri, Jul 30, 2010 at 2:05 PM, David Cole <<a href="david.cole@kitware.com">david.cole@kitware.com</a>> wrote:<BR>
> Running the command shown at the bottom of this email reveals that various<BR>
> different signatures of CanReadFile are present in VTK.<BR>
><BR>
> Is there a preferred one that all readers should aspire to?<BR>
><BR>
> Should it be "static" or "virtual"?<BR>
><BR>
> In the case of classes that inherit from each other, it should be the same,<BR>
> shouldn't it?<BR>
><BR>
> The particular case that I have a beef with is<BR>
> ./IO/vtkEnSightMasterServerReader.h: int CanReadFile(const char *fname);<BR>
><BR>
> which inherits from:<BR>
> ./IO/vtkGenericEnSightReader.h: static int CanReadFile(const char<BR>
> *casefilename);<BR>
><BR>
> Because the child class method is not static, I get a "hides parent method"<BR>
> warning when building ActiViz .NET.<BR>
> Would the owner of this class mind if the method became static...? Or is<BR>
> that not advisable for backwards compatibility reasons...?<BR>
><BR>
><BR>
> Thanks,<BR>
> David C.<BR>
><BR>
><BR>
> Details:<BR>
><BR>
> $ find . | grep "\.h$" | xargs grep CanReadFile<BR>
> ./Hybrid/vtkExodusIIReader.h: int CanReadFile(const char* fname);<BR>
> ./Hybrid/vtkExodusReader.h: int CanReadFile(const char* fname);<BR>
> ./Hybrid/vtkFacetReader.h: static int CanReadFile(const char *filename);<BR>
> ./Hybrid/vtkLSDynaReader.h: int CanReadFile( const char* fname );<BR>
> ./IO/vtkBMPReader.h: virtual int CanReadFile(const char* fname);<BR>
> ./IO/vtkBYUReader.h: static int CanReadFile(const char *filename);<BR>
> ./IO/vtkDICOMImageReader.h: virtual int CanReadFile(const char* fname);<BR>
> ./IO/vtkEnSightMasterServerReader.h: int CanReadFile(const char *fname);<BR>
> ./IO/vtkGenericEnSightReader.h: static int CanReadFile(const char<BR>
> *casefilename);<BR>
> ./IO/vtkGESignaReader.h: virtual int CanReadFile(const char* fname);<BR>
> ./IO/vtkImageReader2.h: virtual int CanReadFile(const char*<BR>
> vtkNotUsed(fname))<BR>
> ./IO/vtkImageReader2Factory.h:// object given a path name to a file. It<BR>
> calls CanReadFile on all<BR>
> ./IO/vtkJPEGReader.h: int CanReadFile(const char* fname);<BR>
> ./IO/vtkMetaImageReader.h: virtual int CanReadFile(const char* name);<BR>
> ./IO/vtkMINCImageReader.h: virtual int CanReadFile(const char* name);<BR>
> ./IO/vtkNetCDFCFReader.h: static int CanReadFile(const char *filename);<BR>
> ./IO/vtkOpenFOAMReader.h: int CanReadFile(const char *);<BR>
> ./IO/vtkPLYReader.h: static int CanReadFile(const char *filename);<BR>
> ./IO/vtkPNGReader.h: virtual int CanReadFile(const char* fname);<BR>
> ./IO/vtkPNMReader.h: int CanReadFile(const char* fname);<BR>
> ./IO/vtkSLACParticleReader.h: static int CanReadFile(const char *filename);<BR>
> ./IO/vtkSLACReader.h: static int CanReadFile(const char *filename);<BR>
> ./IO/vtkSLCReader.h: int CanReadFile(const char* fname);<BR>
> ./IO/vtkTIFFReader.h: virtual int CanReadFile(const char* fname);<BR>
> ./IO/vtkXMLCompositeDataReader.h: virtual int CanReadFileVersion(int major,<BR>
> int vtkNotUsed(minor))<BR>
> ./IO/vtkXMLReader.h: virtual int CanReadFile(const char* name);<BR>
> ./IO/vtkXMLReader.h: virtual int CanReadFileVersion(int major, int minor);<BR>
> ./IO/vtkXMLReader.h: int CanReadFileVersionString(const char* version);<BR>
> ./IO/vtkXYZMolReader.h: virtual int CanReadFile(const char* name);<BR>
> ./Parallel/vtkPDataSetReader.h: int CanReadFile(const char* filename);<BR>
> ./Parallel/vtkPNrrdReader.h: virtual int CanReadFile(const char *filename);<BR>
><BR>
><BR>
> _______________________________________________<BR>
> Powered by www.kitware.com<BR>
><BR>
> Visit other Kitware open-source projects at<BR>
> <a href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><BR>
><BR>
> Follow this link to subscribe/unsubscribe:<BR>
> <a href="http://www.vtk.org/mailman/listinfo/vtk-developers">http://www.vtk.org/mailman/listinfo/vtk-developers</a><BR>
><BR>
><BR>
><BR>
_______________________________________________<BR>
Powered by www.kitware.com<BR>
<BR>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><BR>
<BR>
Follow this link to subscribe/unsubscribe:<BR>
<a href="http://www.vtk.org/mailman/listinfo/vtk-developers">http://www.vtk.org/mailman/listinfo/vtk-developers</a><BR>
<BR>
<BR>
<BR>
</SPAN></FONT></BLOCKQUOTE><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'><BR>
</SPAN></FONT><FONT SIZE="2"><FONT FACE="Consolas, Courier New, Courier"><SPAN STYLE='font-size:10pt'><BR>
**** Kenneth Moreland<BR>
*** Sandia National Laboratories<BR>
*********** <BR>
*** *** *** email: <a href="kmorel@sandia.gov">kmorel@sandia.gov</a><BR>
** *** ** phone: (505) 844-8919<BR>
*** web: <a href="http://www.cs.unm.edu/~kmorel">http://www.cs.unm.edu/~kmorel</a><BR>
</SPAN></FONT></FONT><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'><BR>
</SPAN></FONT>
</BODY>
</HTML>