[vtk-developers] vtkMathTextUtilities and otherPrint test

David Lonie david.lonie at kitware.com
Tue Jul 10 15:51:07 EDT 2012


On Tue, Jul 10, 2012 at 3:47 PM, David Cole <david.cole at kitware.com> wrote:
> On Tue, Jul 10, 2012 at 3:39 PM, David Lonie <david.lonie at kitware.com>
> wrote:
>> On Tue, Jul 10, 2012 at 3:25 PM, David Cole <david.cole at kitware.com>
>> wrote:
>> > Why are the static New methods of singleton objects in VTK public?
>> >   static vtkMathTextUtilities *New();
>>
>> That New method just returns the singleton instance after increasing
>> its reference count. Not sure exactly why it was included (the
>> original author of the vtkFreeTypeUtilities pattern may), but I like
>> having it around for use with vtkNew/vtkSmartPointer. I think the VTK
>> user guide also says that all vtkObject subclasses _must_ define it.
>
> Right, but I phrased it strangely. My real question was "does static New
> have to be in the public section of the class"?
>
> (For a singleton that is created via a call to GetInstance, isn't it a good
> idea to make "New" protected or even private?)
>
> Maybe it does need to be public for the wrappers or something, but seems
> like a bad idea to have a public New for a singleton.

It still needs to be public for the smart pointer classes (not a very
compelling reason since singletons don't really need smart pointers,
but it's the best I can come up with).

Dave



More information about the vtk-developers mailing list