[vtk-developers] change VTK Namespace?

Jean-Christophe Fillion-Robin jchris.fillionr at kitware.com
Fri May 13 17:04:15 EDT 2011


Using an approach similar to what's done in Qt could work. not only the VTk
classes would have to be contained in that namespace but also the third
party library statically built.

In both header and cpp files, the following could be added. For example


#include <.vtkObject.h>

VTK_BEGIN_NAMESPACE

class vtkFoo : ...
{
};

VTK_END_NAMESPACE


You could look at line 69 of qglobal.h

Creating a patch and associated test case to validate it would represent
quite some work.

Hth
Jc

On Sat, Apr 16, 2011 at 9:54 AM, Martin Waitzbauer <mazzok at gmx.at> wrote:

> HI Jean
>
> Thank you for your reply!
> My intention is to build VTK from source with this new namespace because i
> need to link the libraries with a software that already uses a static
> version of VTK on Mac Since i would get symbol entries doubled if im using
> the same namespoace, i need my verison of VTK to be in another namespace
>
> at least i thought this would help, ive seen it with ITK and there it
> worked
>
> So, in your opiinion
> adding a namespace mynamespace{...} before eah VTK class and asasuring that
> all classes being called within Vtk classes are also assigned to that NS
> would result in a VTK version that resides in the mynamespace ns?
> and instantiating would go like
> mynamespace::vtkImageData * data = mynamewspace::vtkImageData::New()
> for example??
>
> Thank you!
> -------- Original-Nachricht --------
> > Datum: Fri, 15 Apr 2011 11:37:47 -0400
> > Von: Jean-Christophe Fillion-Robin <jchris.fillionr at kitware.com>
> > An: Martin Waitzbauer <mazzok at gmx.at>
> > CC: vtk-developers at vtk.org
> > Betreff: Re: [vtk-developers] change VTK Namespace?
>
> > Hi Martin,
> >
> > Within VTK all class names starts with the prefix "vtk", that's how all
> > potential clashes with other toolkit or library is ensured.
> >
> > Changing all VTK classes from:
> >
> > class vtkMyClass{
> > };
> >
> > to
> >
> > namespace vtk {
> > class MyClass{
> > };
> > }
> >
> > would be possible.
> >
> > Nevertheless, doing so will seriously break backward compatibility.
> > Indeed,
> > all projects using VTK will have to undergo some serious update.
> >
> > A an other possibility could be the following, where the namespace is
> > optional:
> >
> > #ifdef VTK_USE_NAMESPACE
> > namespace vtk {
> > #endif
> > class vtkMyClass{
> > };
> > #ifdef VTK_USE_NAMESPACE
> > }
> > #endif
> >
> > but I dont really see the advantages of doing so.
> >
> > Thanks
> > Jc
> >
> >
> >
> > On Fri, Apr 15, 2011 at 6:43 AM, Martin Waitzbauer <mazzok at gmx.at>
> wrote:
> >
> > > Hello,
> > >
> > >
> > > I would like to know if it is possible to compile VTK with a specific
> > > Namespace like in ITK, where the namespace is itk::
> > >
> > > so would osmetihing like
> > >
> > > namespace mynamespace{
> > > class VTK_INFOVIS_EXPORT vtkAppendPoints : public vtkPolyDataAlgorithm
> > > {
> > >
> > > }
> > > } //end namespace mynamespace
> > >
> > >
> > > so would this work if i made a script that added all the vtk classes to
> > > this NS?
> > >
> > >
> > > Thanks alot!
> > > M
> > > --
> > > GMX DSL Doppel-Flat ab 19,99 Euro/mtl.! Jetzt mit
> > > gratis Handy-Flat! http://portal.gmx.net/de/go/dsl
> > > _______________________________________________
> > > 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
> > >
> > >
> >
> >
> > --
> > +1 919 869 8849
>
> --
> NEU: FreePhone - kostenlos mobil telefonieren und surfen!
> Jetzt informieren: http://www.gmx.net/de/go/freephone
>



-- 
+1 919 869 8849
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20110513/a34812cf/attachment.html>


More information about the vtk-developers mailing list