diff --git a/Modules/Core/Common/include/itkObjectFactoryBase.h b/Modules/Core/Common/include/itkObjectFactoryBase.h index 5f3f7863c56..3f4332f0f65 100644 --- a/Modules/Core/Common/include/itkObjectFactoryBase.h +++ b/Modules/Core/Common/include/itkObjectFactoryBase.h @@ -219,6 +219,25 @@ class ITKCommon_EXPORT ObjectFactoryBase : public Object CreateObjectFunctionBase::Pointer m_CreateObject; }; + /** Registers the specified internal factory only once, even when `RegisterInternalFactoryOnce()` is called + * multiple times (possibly even by multiple threads) for the very same factory. */ + template + static void + RegisterInternalFactoryOnce() + { + struct FactoryRegistration + {}; + + // Factory registration, made thread-safe by "magic statics" (as introduced with C++11). + static const FactoryRegistration staticFactoryRegistration = [] { + RegisterFactoryInternal(TFactory::New()); + return FactoryRegistration{}; + }(); + + (void)staticFactoryRegistration; + } + + protected: void PrintSelf(std::ostream & os, Indent indent) const override; diff --git a/Modules/IO/BMP/src/itkBMPImageIOFactory.cxx b/Modules/IO/BMP/src/itkBMPImageIOFactory.cxx index 97d7a768b60..d177b746bd7 100644 --- a/Modules/IO/BMP/src/itkBMPImageIOFactory.cxx +++ b/Modules/IO/BMP/src/itkBMPImageIOFactory.cxx @@ -43,17 +43,10 @@ BMPImageIOFactory::GetDescription() const // Undocumented API used to register during static initialization. // DO NOT CALL DIRECTLY. - -static bool BMPImageIOFactoryHasBeenRegistered; - void ITKIOBMP_EXPORT BMPImageIOFactoryRegister__Private() { - if (!BMPImageIOFactoryHasBeenRegistered) - { - BMPImageIOFactoryHasBeenRegistered = true; - BMPImageIOFactory::RegisterOneFactory(); - } + ObjectFactoryBase::RegisterInternalFactoryOnce(); } } // end namespace itk diff --git a/Modules/IO/BioRad/src/itkBioRadImageIOFactory.cxx b/Modules/IO/BioRad/src/itkBioRadImageIOFactory.cxx index 31325924a85..082a88e1bcc 100644 --- a/Modules/IO/BioRad/src/itkBioRadImageIOFactory.cxx +++ b/Modules/IO/BioRad/src/itkBioRadImageIOFactory.cxx @@ -53,17 +53,10 @@ BioRadImageIOFactory::GetDescription() const // Undocumented API used to register during static initialization. // DO NOT CALL DIRECTLY. - -static bool BioRadImageIOFactoryHasBeenRegistered; - void ITKIOBioRad_EXPORT BioRadImageIOFactoryRegister__Private() { - if (!BioRadImageIOFactoryHasBeenRegistered) - { - BioRadImageIOFactoryHasBeenRegistered = true; - BioRadImageIOFactory::RegisterOneFactory(); - } + ObjectFactoryBase::RegisterInternalFactoryOnce(); } } // end namespace itk diff --git a/Modules/IO/Bruker/src/itkBruker2dseqImageIOFactory.cxx b/Modules/IO/Bruker/src/itkBruker2dseqImageIOFactory.cxx index 414dc4e8254..b35a9a0c7dc 100644 --- a/Modules/IO/Bruker/src/itkBruker2dseqImageIOFactory.cxx +++ b/Modules/IO/Bruker/src/itkBruker2dseqImageIOFactory.cxx @@ -56,16 +56,9 @@ Bruker2dseqImageIOFactory::GetDescription() const // Undocumented API used to register during static initialization. // DO NOT CALL DIRECTLY. - -static bool Bruker2dseqImageIOFactoryHasBeenRegistered; - void ITKIOBruker_EXPORT Bruker2dseqImageIOFactoryRegister__Private() { - if (!Bruker2dseqImageIOFactoryHasBeenRegistered) - { - Bruker2dseqImageIOFactoryHasBeenRegistered = true; - Bruker2dseqImageIOFactory::RegisterOneFactory(); - } + ObjectFactoryBase::RegisterInternalFactoryOnce(); } } // end namespace itk diff --git a/Modules/IO/DCMTK/src/itkDCMTKImageIOFactory.cxx b/Modules/IO/DCMTK/src/itkDCMTKImageIOFactory.cxx index 4154deb103d..be4edc94f71 100644 --- a/Modules/IO/DCMTK/src/itkDCMTKImageIOFactory.cxx +++ b/Modules/IO/DCMTK/src/itkDCMTKImageIOFactory.cxx @@ -43,17 +43,10 @@ DCMTKImageIOFactory::GetDescription() const // Undocumented API used to register during static initialization. // DO NOT CALL DIRECTLY. - -static bool DCMTKImageIOFactoryHasBeenRegistered; - void ITKIODCMTK_EXPORT DCMTKImageIOFactoryRegister__Private() { - if (!DCMTKImageIOFactoryHasBeenRegistered) - { - DCMTKImageIOFactoryHasBeenRegistered = true; - DCMTKImageIOFactory::RegisterOneFactory(); - } + ObjectFactoryBase::RegisterInternalFactoryOnce(); } } // end namespace itk diff --git a/Modules/IO/GDCM/src/itkGDCMImageIOFactory.cxx b/Modules/IO/GDCM/src/itkGDCMImageIOFactory.cxx index 5cff5eb502c..7164576cb24 100644 --- a/Modules/IO/GDCM/src/itkGDCMImageIOFactory.cxx +++ b/Modules/IO/GDCM/src/itkGDCMImageIOFactory.cxx @@ -43,17 +43,10 @@ GDCMImageIOFactory::GetDescription() const // Undocumented API used to register during static initialization. // DO NOT CALL DIRECTLY. - -static bool GDCMImageIOFactoryHasBeenRegistered; - void ITKIOGDCM_EXPORT GDCMImageIOFactoryRegister__Private() { - if (!GDCMImageIOFactoryHasBeenRegistered) - { - GDCMImageIOFactoryHasBeenRegistered = true; - GDCMImageIOFactory::RegisterOneFactory(); - } + ObjectFactoryBase::RegisterInternalFactoryOnce(); } } // end namespace itk diff --git a/Modules/IO/GE/src/itkGE4ImageIOFactory.cxx b/Modules/IO/GE/src/itkGE4ImageIOFactory.cxx index d558805f220..db6fc06346b 100644 --- a/Modules/IO/GE/src/itkGE4ImageIOFactory.cxx +++ b/Modules/IO/GE/src/itkGE4ImageIOFactory.cxx @@ -47,17 +47,10 @@ GE4ImageIOFactory::GetDescription() const // Undocumented API used to register during static initialization. // DO NOT CALL DIRECTLY. - -static bool GE4ImageIOFactoryHasBeenRegistered; - void ITKIOGE_EXPORT GE4ImageIOFactoryRegister__Private() { - if (!GE4ImageIOFactoryHasBeenRegistered) - { - GE4ImageIOFactoryHasBeenRegistered = true; - GE4ImageIOFactory::RegisterOneFactory(); - } + ObjectFactoryBase::RegisterInternalFactoryOnce(); } } // end namespace itk diff --git a/Modules/IO/GE/src/itkGE5ImageIOFactory.cxx b/Modules/IO/GE/src/itkGE5ImageIOFactory.cxx index 544a0a9c2ad..0b39ce04310 100644 --- a/Modules/IO/GE/src/itkGE5ImageIOFactory.cxx +++ b/Modules/IO/GE/src/itkGE5ImageIOFactory.cxx @@ -47,17 +47,10 @@ GE5ImageIOFactory::GetDescription() const // Undocumented API used to register during static initialization. // DO NOT CALL DIRECTLY. - -static bool GE5ImageIOFactoryHasBeenRegistered; - void ITKIOGE_EXPORT GE5ImageIOFactoryRegister__Private() { - if (!GE5ImageIOFactoryHasBeenRegistered) - { - GE5ImageIOFactoryHasBeenRegistered = true; - GE5ImageIOFactory::RegisterOneFactory(); - } + ObjectFactoryBase::RegisterInternalFactoryOnce(); } } // end namespace itk diff --git a/Modules/IO/GE/src/itkGEAdwImageIOFactory.cxx b/Modules/IO/GE/src/itkGEAdwImageIOFactory.cxx index 0251f401bec..57680d54cd6 100644 --- a/Modules/IO/GE/src/itkGEAdwImageIOFactory.cxx +++ b/Modules/IO/GE/src/itkGEAdwImageIOFactory.cxx @@ -47,17 +47,10 @@ GEAdwImageIOFactory::GetDescription() const // Undocumented API used to register during static initialization. // DO NOT CALL DIRECTLY. - -static bool GEAdwImageIOFactoryHasBeenRegistered; - void ITKIOGE_EXPORT GEAdwImageIOFactoryRegister__Private() { - if (!GEAdwImageIOFactoryHasBeenRegistered) - { - GEAdwImageIOFactoryHasBeenRegistered = true; - GEAdwImageIOFactory::RegisterOneFactory(); - } + ObjectFactoryBase::RegisterInternalFactoryOnce(); } } // end namespace itk diff --git a/Modules/IO/GIPL/src/itkGiplImageIOFactory.cxx b/Modules/IO/GIPL/src/itkGiplImageIOFactory.cxx index 0d1cd84d55d..119f1b988bf 100644 --- a/Modules/IO/GIPL/src/itkGiplImageIOFactory.cxx +++ b/Modules/IO/GIPL/src/itkGiplImageIOFactory.cxx @@ -43,17 +43,10 @@ GiplImageIOFactory::GetDescription() const // Undocumented API used to register during static initialization. // DO NOT CALL DIRECTLY. - -static bool GiplImageIOFactoryHasBeenRegistered; - void ITKIOGIPL_EXPORT GiplImageIOFactoryRegister__Private() { - if (!GiplImageIOFactoryHasBeenRegistered) - { - GiplImageIOFactoryHasBeenRegistered = true; - GiplImageIOFactory::RegisterOneFactory(); - } + ObjectFactoryBase::RegisterInternalFactoryOnce(); } } // end namespace itk diff --git a/Modules/IO/HDF5/src/itkHDF5ImageIOFactory.cxx b/Modules/IO/HDF5/src/itkHDF5ImageIOFactory.cxx index 24e982bb90e..e5d159a2a92 100644 --- a/Modules/IO/HDF5/src/itkHDF5ImageIOFactory.cxx +++ b/Modules/IO/HDF5/src/itkHDF5ImageIOFactory.cxx @@ -47,17 +47,10 @@ HDF5ImageIOFactory::GetDescription() const // Undocumented API used to register during static initialization. // DO NOT CALL DIRECTLY. - -static bool HDF5ImageIOFactoryHasBeenRegistered; - void ITKIOHDF5_EXPORT HDF5ImageIOFactoryRegister__Private() { - if (!HDF5ImageIOFactoryHasBeenRegistered) - { - HDF5ImageIOFactoryHasBeenRegistered = true; - HDF5ImageIOFactory::RegisterOneFactory(); - } + ObjectFactoryBase::RegisterInternalFactoryOnce(); } } // end namespace itk diff --git a/Modules/IO/JPEG/src/itkJPEGImageIOFactory.cxx b/Modules/IO/JPEG/src/itkJPEGImageIOFactory.cxx index 49744374af7..f2472aecf34 100644 --- a/Modules/IO/JPEG/src/itkJPEGImageIOFactory.cxx +++ b/Modules/IO/JPEG/src/itkJPEGImageIOFactory.cxx @@ -43,17 +43,10 @@ JPEGImageIOFactory::GetDescription() const // Undocumented API used to register during static initialization. // DO NOT CALL DIRECTLY. - -static bool JPEGImageIOFactoryHasBeenRegistered; - void ITKIOJPEG_EXPORT JPEGImageIOFactoryRegister__Private() { - if (!JPEGImageIOFactoryHasBeenRegistered) - { - JPEGImageIOFactoryHasBeenRegistered = true; - JPEGImageIOFactory::RegisterOneFactory(); - } + ObjectFactoryBase::RegisterInternalFactoryOnce(); } } // end namespace itk diff --git a/Modules/IO/JPEG2000/src/itkJPEG2000ImageIOFactory.cxx b/Modules/IO/JPEG2000/src/itkJPEG2000ImageIOFactory.cxx index 7c1ecc40b73..ff2477fb6d4 100644 --- a/Modules/IO/JPEG2000/src/itkJPEG2000ImageIOFactory.cxx +++ b/Modules/IO/JPEG2000/src/itkJPEG2000ImageIOFactory.cxx @@ -44,17 +44,10 @@ JPEG2000ImageIOFactory::GetDescription() const // Undocumented API used to register during static initialization. // DO NOT CALL DIRECTLY. - -static bool JPEG2000ImageIOFactoryHasBeenRegistered; - void ITKIOJPEG2000_EXPORT JPEG2000ImageIOFactoryRegister__Private() { - if (!JPEG2000ImageIOFactoryHasBeenRegistered) - { - JPEG2000ImageIOFactoryHasBeenRegistered = true; - JPEG2000ImageIOFactory::RegisterOneFactory(); - } + ObjectFactoryBase::RegisterInternalFactoryOnce(); } diff --git a/Modules/IO/LSM/src/itkLSMImageIOFactory.cxx b/Modules/IO/LSM/src/itkLSMImageIOFactory.cxx index 02d539ed48b..bba9dff4442 100644 --- a/Modules/IO/LSM/src/itkLSMImageIOFactory.cxx +++ b/Modules/IO/LSM/src/itkLSMImageIOFactory.cxx @@ -53,17 +53,10 @@ LSMImageIOFactory::GetDescription() const // Undocumented API used to register during static initialization. // DO NOT CALL DIRECTLY. - -static bool LSMImageIOFactoryHasBeenRegistered; - void ITKIOLSM_EXPORT LSMImageIOFactoryRegister__Private() { - if (!LSMImageIOFactoryHasBeenRegistered) - { - LSMImageIOFactoryHasBeenRegistered = true; - LSMImageIOFactory::RegisterOneFactory(); - } + ObjectFactoryBase::RegisterInternalFactoryOnce(); } } // end namespace itk diff --git a/Modules/IO/MINC/src/itkMINCImageIOFactory.cxx b/Modules/IO/MINC/src/itkMINCImageIOFactory.cxx index 2870ec81756..c5dc19e6c7a 100644 --- a/Modules/IO/MINC/src/itkMINCImageIOFactory.cxx +++ b/Modules/IO/MINC/src/itkMINCImageIOFactory.cxx @@ -43,17 +43,10 @@ MINCImageIOFactory::GetDescription() const // Undocumented API used to register during static initialization. // DO NOT CALL DIRECTLY. - -static bool MINCImageIOFactoryHasBeenRegistered; - void ITKIOMINC_EXPORT MINCImageIOFactoryRegister__Private() { - if (!MINCImageIOFactoryHasBeenRegistered) - { - MINCImageIOFactoryHasBeenRegistered = true; - MINCImageIOFactory::RegisterOneFactory(); - } + ObjectFactoryBase::RegisterInternalFactoryOnce(); } } // end namespace itk diff --git a/Modules/IO/MRC/src/itkMRCImageIOFactory.cxx b/Modules/IO/MRC/src/itkMRCImageIOFactory.cxx index 80ba9f1814a..980b1ead426 100644 --- a/Modules/IO/MRC/src/itkMRCImageIOFactory.cxx +++ b/Modules/IO/MRC/src/itkMRCImageIOFactory.cxx @@ -53,17 +53,10 @@ MRCImageIOFactory::GetDescription() const // Undocumented API used to register during static initialization. // DO NOT CALL DIRECTLY. - -static bool MRCImageIOFactoryHasBeenRegistered; - void ITKIOMRC_EXPORT MRCImageIOFactoryRegister__Private() { - if (!MRCImageIOFactoryHasBeenRegistered) - { - MRCImageIOFactoryHasBeenRegistered = true; - MRCImageIOFactory::RegisterOneFactory(); - } + ObjectFactoryBase::RegisterInternalFactoryOnce(); } } // end namespace itk diff --git a/Modules/IO/MeshBYU/src/itkBYUMeshIOFactory.cxx b/Modules/IO/MeshBYU/src/itkBYUMeshIOFactory.cxx index a7b0d5d8019..bc4063ab18c 100644 --- a/Modules/IO/MeshBYU/src/itkBYUMeshIOFactory.cxx +++ b/Modules/IO/MeshBYU/src/itkBYUMeshIOFactory.cxx @@ -52,16 +52,10 @@ BYUMeshIOFactory::GetDescription() const // Undocumented API used to register during static initialization. // DO NOT CALL DIRECTLY. -static bool BYUMeshIOFactoryHasBeenRegistered; - void ITKIOMeshBYU_EXPORT BYUMeshIOFactoryRegister__Private() { - if (!BYUMeshIOFactoryHasBeenRegistered) - { - BYUMeshIOFactoryHasBeenRegistered = true; - BYUMeshIOFactory::RegisterOneFactory(); - } + ObjectFactoryBase::RegisterInternalFactoryOnce(); } } // end namespace itk diff --git a/Modules/IO/MeshFreeSurfer/src/itkFreeSurferAsciiMeshIOFactory.cxx b/Modules/IO/MeshFreeSurfer/src/itkFreeSurferAsciiMeshIOFactory.cxx index 9712e45bb43..38828daae13 100644 --- a/Modules/IO/MeshFreeSurfer/src/itkFreeSurferAsciiMeshIOFactory.cxx +++ b/Modules/IO/MeshFreeSurfer/src/itkFreeSurferAsciiMeshIOFactory.cxx @@ -52,16 +52,10 @@ FreeSurferAsciiMeshIOFactory::GetDescription() const // Undocumented API used to register during static initialization. // DO NOT CALL DIRECTLY. -static bool FreeSurferAsciiMeshIOFactoryHasBeenRegistered; - void ITKIOMeshFreeSurfer_EXPORT FreeSurferAsciiMeshIOFactoryRegister__Private() { - if (!FreeSurferAsciiMeshIOFactoryHasBeenRegistered) - { - FreeSurferAsciiMeshIOFactoryHasBeenRegistered = true; - FreeSurferAsciiMeshIOFactory::RegisterOneFactory(); - } + ObjectFactoryBase::RegisterInternalFactoryOnce(); } } // end namespace itk diff --git a/Modules/IO/MeshFreeSurfer/src/itkFreeSurferBinaryMeshIOFactory.cxx b/Modules/IO/MeshFreeSurfer/src/itkFreeSurferBinaryMeshIOFactory.cxx index 6348210eab1..67850f2e15a 100644 --- a/Modules/IO/MeshFreeSurfer/src/itkFreeSurferBinaryMeshIOFactory.cxx +++ b/Modules/IO/MeshFreeSurfer/src/itkFreeSurferBinaryMeshIOFactory.cxx @@ -52,16 +52,10 @@ FreeSurferBinaryMeshIOFactory::GetDescription() const // Undocumented API used to register during static initialization. // DO NOT CALL DIRECTLY. -static bool FreeSurferBinaryMeshIOFactoryHasBeenRegistered; - void ITKIOMeshFreeSurfer_EXPORT FreeSurferBinaryMeshIOFactoryRegister__Private() { - if (!FreeSurferBinaryMeshIOFactoryHasBeenRegistered) - { - FreeSurferBinaryMeshIOFactoryHasBeenRegistered = true; - FreeSurferBinaryMeshIOFactory::RegisterOneFactory(); - } + ObjectFactoryBase::RegisterInternalFactoryOnce(); } } // end namespace itk diff --git a/Modules/IO/MeshGifti/src/itkGiftiMeshIOFactory.cxx b/Modules/IO/MeshGifti/src/itkGiftiMeshIOFactory.cxx index 0064a835456..533a719efc1 100644 --- a/Modules/IO/MeshGifti/src/itkGiftiMeshIOFactory.cxx +++ b/Modules/IO/MeshGifti/src/itkGiftiMeshIOFactory.cxx @@ -49,16 +49,10 @@ GiftiMeshIOFactory::GetDescription() const // Undocumented API used to register during static initialization. // DO NOT CALL DIRECTLY. -static bool GiftiMeshIOFactoryHasBeenRegistered; - void ITKIOMeshGifti_EXPORT GiftiMeshIOFactoryRegister__Private() { - if (!GiftiMeshIOFactoryHasBeenRegistered) - { - GiftiMeshIOFactoryHasBeenRegistered = true; - GiftiMeshIOFactory::RegisterOneFactory(); - } + ObjectFactoryBase::RegisterInternalFactoryOnce(); } } // end namespace itk diff --git a/Modules/IO/MeshOBJ/src/itkOBJMeshIOFactory.cxx b/Modules/IO/MeshOBJ/src/itkOBJMeshIOFactory.cxx index e2d1d4ff1f5..9fcf0e147bf 100644 --- a/Modules/IO/MeshOBJ/src/itkOBJMeshIOFactory.cxx +++ b/Modules/IO/MeshOBJ/src/itkOBJMeshIOFactory.cxx @@ -48,16 +48,10 @@ OBJMeshIOFactory::GetDescription() const // Undocumented API used to register during static initialization. // DO NOT CALL DIRECTLY. -static bool OBJMeshIOFactoryHasBeenRegistered; - void ITKIOMeshOBJ_EXPORT OBJMeshIOFactoryRegister__Private() { - if (!OBJMeshIOFactoryHasBeenRegistered) - { - OBJMeshIOFactoryHasBeenRegistered = true; - OBJMeshIOFactory::RegisterOneFactory(); - } + ObjectFactoryBase::RegisterInternalFactoryOnce(); } } // end namespace itk diff --git a/Modules/IO/MeshOFF/src/itkOFFMeshIOFactory.cxx b/Modules/IO/MeshOFF/src/itkOFFMeshIOFactory.cxx index 9bf5e167cda..8c6cc7093e8 100644 --- a/Modules/IO/MeshOFF/src/itkOFFMeshIOFactory.cxx +++ b/Modules/IO/MeshOFF/src/itkOFFMeshIOFactory.cxx @@ -48,16 +48,10 @@ OFFMeshIOFactory::GetDescription() const // Undocumented API used to register during static initialization. // DO NOT CALL DIRECTLY. -static bool OFFMeshIOFactoryHasBeenRegistered; - void ITKIOMeshOFF_EXPORT OFFMeshIOFactoryRegister__Private() { - if (!OFFMeshIOFactoryHasBeenRegistered) - { - OFFMeshIOFactoryHasBeenRegistered = true; - OFFMeshIOFactory::RegisterOneFactory(); - } + ObjectFactoryBase::RegisterInternalFactoryOnce(); } } // end namespace itk diff --git a/Modules/IO/MeshVTK/src/itkVTKPolyDataMeshIOFactory.cxx b/Modules/IO/MeshVTK/src/itkVTKPolyDataMeshIOFactory.cxx index 335d41deb9b..cd9a98d2403 100644 --- a/Modules/IO/MeshVTK/src/itkVTKPolyDataMeshIOFactory.cxx +++ b/Modules/IO/MeshVTK/src/itkVTKPolyDataMeshIOFactory.cxx @@ -54,16 +54,10 @@ VTKPolyDataMeshIOFactory::GetDescription() const // Undocumented API used to register during static initialization. // DO NOT CALL DIRECTLY. -static bool VTKPolyDataMeshIOFactoryHasBeenRegistered; - void ITKIOMeshVTK_EXPORT VTKPolyDataMeshIOFactoryRegister__Private() { - if (!VTKPolyDataMeshIOFactoryHasBeenRegistered) - { - VTKPolyDataMeshIOFactoryHasBeenRegistered = true; - VTKPolyDataMeshIOFactory::RegisterOneFactory(); - } + ObjectFactoryBase::RegisterInternalFactoryOnce(); } } // end namespace itk diff --git a/Modules/IO/Meta/src/itkMetaImageIOFactory.cxx b/Modules/IO/Meta/src/itkMetaImageIOFactory.cxx index b636e34f82a..ae53a1385fa 100644 --- a/Modules/IO/Meta/src/itkMetaImageIOFactory.cxx +++ b/Modules/IO/Meta/src/itkMetaImageIOFactory.cxx @@ -43,17 +43,10 @@ MetaImageIOFactory::GetDescription() const // Undocumented API used to register during static initialization. // DO NOT CALL DIRECTLY. - -static bool MetaImageIOFactoryHasBeenRegistered; - void ITKIOMeta_EXPORT MetaImageIOFactoryRegister__Private() { - if (!MetaImageIOFactoryHasBeenRegistered) - { - MetaImageIOFactoryHasBeenRegistered = true; - MetaImageIOFactory::RegisterOneFactory(); - } + ObjectFactoryBase::RegisterInternalFactoryOnce(); } } // end namespace itk diff --git a/Modules/IO/NIFTI/src/itkNiftiImageIOFactory.cxx b/Modules/IO/NIFTI/src/itkNiftiImageIOFactory.cxx index be1ee1a8a51..c7d3dbba1b4 100644 --- a/Modules/IO/NIFTI/src/itkNiftiImageIOFactory.cxx +++ b/Modules/IO/NIFTI/src/itkNiftiImageIOFactory.cxx @@ -47,17 +47,10 @@ NiftiImageIOFactory::GetDescription() const // Undocumented API used to register during static initialization. // DO NOT CALL DIRECTLY. - -static bool NiftiImageIOFactoryHasBeenRegistered; - void ITKIONIFTI_EXPORT NiftiImageIOFactoryRegister__Private() { - if (!NiftiImageIOFactoryHasBeenRegistered) - { - NiftiImageIOFactoryHasBeenRegistered = true; - NiftiImageIOFactory::RegisterOneFactory(); - } + ObjectFactoryBase::RegisterInternalFactoryOnce(); } } // end namespace itk diff --git a/Modules/IO/NRRD/src/itkNrrdImageIOFactory.cxx b/Modules/IO/NRRD/src/itkNrrdImageIOFactory.cxx index 89976a3c82f..cb147f34d2c 100644 --- a/Modules/IO/NRRD/src/itkNrrdImageIOFactory.cxx +++ b/Modules/IO/NRRD/src/itkNrrdImageIOFactory.cxx @@ -43,17 +43,10 @@ NrrdImageIOFactory::GetDescription() const // Undocumented API used to register during static initialization. // DO NOT CALL DIRECTLY. - -static bool NrrdImageIOFactoryHasBeenRegistered; - void ITKIONRRD_EXPORT NrrdImageIOFactoryRegister__Private() { - if (!NrrdImageIOFactoryHasBeenRegistered) - { - NrrdImageIOFactoryHasBeenRegistered = true; - NrrdImageIOFactory::RegisterOneFactory(); - } + ObjectFactoryBase::RegisterInternalFactoryOnce(); } } // end namespace itk diff --git a/Modules/IO/PNG/src/itkPNGImageIOFactory.cxx b/Modules/IO/PNG/src/itkPNGImageIOFactory.cxx index 061ec9b99f2..8b22f1f9895 100644 --- a/Modules/IO/PNG/src/itkPNGImageIOFactory.cxx +++ b/Modules/IO/PNG/src/itkPNGImageIOFactory.cxx @@ -43,17 +43,10 @@ PNGImageIOFactory::GetDescription() const // Undocumented API used to register during static initialization. // DO NOT CALL DIRECTLY. - -static bool PNGImageIOFactoryHasBeenRegistered; - void ITKIOPNG_EXPORT PNGImageIOFactoryRegister__Private() { - if (!PNGImageIOFactoryHasBeenRegistered) - { - PNGImageIOFactoryHasBeenRegistered = true; - PNGImageIOFactory::RegisterOneFactory(); - } + ObjectFactoryBase::RegisterInternalFactoryOnce(); } } // end namespace itk diff --git a/Modules/IO/PhilipsREC/src/itkPhilipsRECImageIOFactory.cxx b/Modules/IO/PhilipsREC/src/itkPhilipsRECImageIOFactory.cxx index aca38b8562b..ecd3719d32b 100644 --- a/Modules/IO/PhilipsREC/src/itkPhilipsRECImageIOFactory.cxx +++ b/Modules/IO/PhilipsREC/src/itkPhilipsRECImageIOFactory.cxx @@ -58,17 +58,10 @@ PhilipsRECImageIOFactory::GetDescription() const // Undocumented API used to register during static initialization. // DO NOT CALL DIRECTLY. - -static bool PhilipsRECImageIOFactoryHasBeenRegistered; - void ITKIOPhilipsREC_EXPORT PhilipsRECImageIOFactoryRegister__Private() { - if (!PhilipsRECImageIOFactoryHasBeenRegistered) - { - PhilipsRECImageIOFactoryHasBeenRegistered = true; - PhilipsRECImageIOFactory::RegisterOneFactory(); - } + ObjectFactoryBase::RegisterInternalFactoryOnce(); } } // end namespace itk diff --git a/Modules/IO/Siemens/src/itkSiemensVisionImageIOFactory.cxx b/Modules/IO/Siemens/src/itkSiemensVisionImageIOFactory.cxx index 76c69003693..591a54eab0e 100644 --- a/Modules/IO/Siemens/src/itkSiemensVisionImageIOFactory.cxx +++ b/Modules/IO/Siemens/src/itkSiemensVisionImageIOFactory.cxx @@ -50,17 +50,10 @@ SiemensVisionImageIOFactory::GetDescription() const // Undocumented API used to register during static initialization. // DO NOT CALL DIRECTLY. - -static bool SiemensVisionImageIOFactoryHasBeenRegistered; - void ITKIOSiemens_EXPORT SiemensVisionImageIOFactoryRegister__Private() { - if (!SiemensVisionImageIOFactoryHasBeenRegistered) - { - SiemensVisionImageIOFactoryHasBeenRegistered = true; - SiemensVisionImageIOFactory::RegisterOneFactory(); - } + ObjectFactoryBase::RegisterInternalFactoryOnce(); } } // end namespace itk diff --git a/Modules/IO/Stimulate/src/itkStimulateImageIOFactory.cxx b/Modules/IO/Stimulate/src/itkStimulateImageIOFactory.cxx index 70118ebcda5..2140c8c3bbe 100644 --- a/Modules/IO/Stimulate/src/itkStimulateImageIOFactory.cxx +++ b/Modules/IO/Stimulate/src/itkStimulateImageIOFactory.cxx @@ -53,17 +53,10 @@ StimulateImageIOFactory::GetDescription() const // Undocumented API used to register during static initialization. // DO NOT CALL DIRECTLY. - -static bool StimulateImageIOFactoryHasBeenRegistered; - void ITKIOStimulate_EXPORT StimulateImageIOFactoryRegister__Private() { - if (!StimulateImageIOFactoryHasBeenRegistered) - { - StimulateImageIOFactoryHasBeenRegistered = true; - StimulateImageIOFactory::RegisterOneFactory(); - } + ObjectFactoryBase::RegisterInternalFactoryOnce(); } } // end namespace itk diff --git a/Modules/IO/TIFF/src/itkTIFFImageIOFactory.cxx b/Modules/IO/TIFF/src/itkTIFFImageIOFactory.cxx index 83f759e18aa..7d9fa322501 100644 --- a/Modules/IO/TIFF/src/itkTIFFImageIOFactory.cxx +++ b/Modules/IO/TIFF/src/itkTIFFImageIOFactory.cxx @@ -43,17 +43,10 @@ TIFFImageIOFactory::GetDescription() const // Undocumented API used to register during static initialization. // DO NOT CALL DIRECTLY. - -static bool TIFFImageIOFactoryHasBeenRegistered; - void ITKIOTIFF_EXPORT TIFFImageIOFactoryRegister__Private() { - if (!TIFFImageIOFactoryHasBeenRegistered) - { - TIFFImageIOFactoryHasBeenRegistered = true; - TIFFImageIOFactory::RegisterOneFactory(); - } + ObjectFactoryBase::RegisterInternalFactoryOnce(); } } // end namespace itk diff --git a/Modules/IO/TransformHDF5/src/itkHDF5TransformIOFactory.cxx b/Modules/IO/TransformHDF5/src/itkHDF5TransformIOFactory.cxx index 45eead1d66f..68e9d236b21 100644 --- a/Modules/IO/TransformHDF5/src/itkHDF5TransformIOFactory.cxx +++ b/Modules/IO/TransformHDF5/src/itkHDF5TransformIOFactory.cxx @@ -58,15 +58,9 @@ HDF5TransformIOFactory::GetDescription() const // Undocumented API used to register during static initialization. // DO NOT CALL DIRECTLY. -static bool HDF5TransformIOFactoryHasBeenRegistered; - void ITKIOTransformHDF5_EXPORT HDF5TransformIOFactoryRegister__Private() { - if (!HDF5TransformIOFactoryHasBeenRegistered) - { - HDF5TransformIOFactoryHasBeenRegistered = true; - HDF5TransformIOFactory::RegisterOneFactory(); - } + ObjectFactoryBase::RegisterInternalFactoryOnce(); } } // end namespace itk diff --git a/Modules/IO/TransformInsightLegacy/src/itkTxtTransformIOFactory.cxx b/Modules/IO/TransformInsightLegacy/src/itkTxtTransformIOFactory.cxx index 50e5e5bbbb2..55a630d95ba 100644 --- a/Modules/IO/TransformInsightLegacy/src/itkTxtTransformIOFactory.cxx +++ b/Modules/IO/TransformInsightLegacy/src/itkTxtTransformIOFactory.cxx @@ -57,15 +57,9 @@ TxtTransformIOFactory::GetDescription() const // Undocumented API used to register during static initialization. // DO NOT CALL DIRECTLY. -static bool TxtTransformIOFactoryHasBeenRegistered; - void ITKIOTransformInsightLegacy_EXPORT TxtTransformIOFactoryRegister__Private() { - if (!TxtTransformIOFactoryHasBeenRegistered) - { - TxtTransformIOFactoryHasBeenRegistered = true; - TxtTransformIOFactory::RegisterOneFactory(); - } + ObjectFactoryBase::RegisterInternalFactoryOnce(); } } // end namespace itk diff --git a/Modules/IO/TransformMINC/src/itkMINCTransformIOFactory.cxx b/Modules/IO/TransformMINC/src/itkMINCTransformIOFactory.cxx index dea21d233e2..a0b3817bebc 100644 --- a/Modules/IO/TransformMINC/src/itkMINCTransformIOFactory.cxx +++ b/Modules/IO/TransformMINC/src/itkMINCTransformIOFactory.cxx @@ -60,19 +60,13 @@ MINCTransformIOFactory::GetDescription() const // Undocumented API used to register during static initialization. // DO NOT CALL DIRECTLY. -static bool MINCTransformIOFactoryHasBeenRegistered; - void ITKIOTransformMINC_EXPORT MINCTransformIOFactoryRegister__Private() { - if (!MINCTransformIOFactoryHasBeenRegistered) - { - MINCTransformIOFactoryHasBeenRegistered = true; - MINCTransformIOFactory::RegisterOneFactory(); + ObjectFactoryBase::RegisterInternalFactoryOnce(); - // TransformFactory< DisplacementFieldTransform >::RegisterTransform (); - // register additional transform type - } + // TransformFactory< DisplacementFieldTransform >::RegisterTransform (); + // register additional transform type } } // end namespace itk diff --git a/Modules/IO/TransformMatlab/src/itkMatlabTransformIOFactory.cxx b/Modules/IO/TransformMatlab/src/itkMatlabTransformIOFactory.cxx index f632b2572c5..209574d5844 100644 --- a/Modules/IO/TransformMatlab/src/itkMatlabTransformIOFactory.cxx +++ b/Modules/IO/TransformMatlab/src/itkMatlabTransformIOFactory.cxx @@ -57,15 +57,9 @@ MatlabTransformIOFactory::GetDescription() const // Undocumented API used to register during static initialization. // DO NOT CALL DIRECTLY. -static bool MatlabTransformIOFactoryHasBeenRegistered; - void ITKIOTransformMatlab_EXPORT MatlabTransformIOFactoryRegister__Private() { - if (!MatlabTransformIOFactoryHasBeenRegistered) - { - MatlabTransformIOFactoryHasBeenRegistered = true; - MatlabTransformIOFactory::RegisterOneFactory(); - } + ObjectFactoryBase::RegisterInternalFactoryOnce(); } } // end namespace itk diff --git a/Modules/IO/VTK/src/itkVTKImageIOFactory.cxx b/Modules/IO/VTK/src/itkVTKImageIOFactory.cxx index 2c77d6ae4d3..3747d8860de 100644 --- a/Modules/IO/VTK/src/itkVTKImageIOFactory.cxx +++ b/Modules/IO/VTK/src/itkVTKImageIOFactory.cxx @@ -53,17 +53,10 @@ VTKImageIOFactory::GetDescription() const // Undocumented API used to register during static initialization. // DO NOT CALL DIRECTLY. - -static bool VTKImageIOFactoryHasBeenRegistered; - void ITKIOVTK_EXPORT VTKImageIOFactoryRegister__Private() { - if (!VTKImageIOFactoryHasBeenRegistered) - { - VTKImageIOFactoryHasBeenRegistered = true; - VTKImageIOFactory::RegisterOneFactory(); - } + ObjectFactoryBase::RegisterInternalFactoryOnce(); } } // end namespace itk diff --git a/Modules/Video/BridgeOpenCV/src/itkOpenCVVideoIOFactory.cxx b/Modules/Video/BridgeOpenCV/src/itkOpenCVVideoIOFactory.cxx index 0a35ed5d50f..8f7714459cd 100644 --- a/Modules/Video/BridgeOpenCV/src/itkOpenCVVideoIOFactory.cxx +++ b/Modules/Video/BridgeOpenCV/src/itkOpenCVVideoIOFactory.cxx @@ -43,17 +43,10 @@ OpenCVVideoIOFactory::GetDescription() const // Undocumented API used to register during static initialization. // DO NOT CALL DIRECTLY. - -static bool OpenCVVideoIOFactoryHasBeenRegistered; - void OpenCVVideoIOFactoryRegister__Private() { - if (!OpenCVVideoIOFactoryHasBeenRegistered) - { - OpenCVVideoIOFactoryHasBeenRegistered = true; - OpenCVVideoIOFactory::RegisterOneFactory(); - } + ObjectFactoryBase::RegisterInternalFactoryOnce(); } } // end namespace itk diff --git a/Modules/Video/BridgeVXL/src/itkVXLVideoIOFactory.cxx b/Modules/Video/BridgeVXL/src/itkVXLVideoIOFactory.cxx index d932b412719..ff23e863083 100644 --- a/Modules/Video/BridgeVXL/src/itkVXLVideoIOFactory.cxx +++ b/Modules/Video/BridgeVXL/src/itkVXLVideoIOFactory.cxx @@ -42,17 +42,10 @@ VXLVideoIOFactory::GetDescription() const // Undocumented API used to register during static initialization. // DO NOT CALL DIRECTLY. - -static bool VXLVideoIOFactoryHasBeenRegistered; - void VXLVideoIOFactoryRegister__Private() { - if (!VXLVideoIOFactoryHasBeenRegistered) - { - VXLVideoIOFactoryHasBeenRegistered = true; - VXLVideoIOFactory::RegisterOneFactory(); - } + ObjectFactoryBase::RegisterInternalFactoryOnce(); } } // end namespace itk diff --git a/Modules/Video/IO/src/itkFileListVideoIOFactory.cxx b/Modules/Video/IO/src/itkFileListVideoIOFactory.cxx index 5207ac3b67f..a27d4a017a6 100644 --- a/Modules/Video/IO/src/itkFileListVideoIOFactory.cxx +++ b/Modules/Video/IO/src/itkFileListVideoIOFactory.cxx @@ -43,17 +43,10 @@ FileListVideoIOFactory::GetDescription() const // Undocumented API used to register during static initialization. // DO NOT CALL DIRECTLY. - -static bool FileListVideoIOFactoryHasBeenRegistered; - void FileListVideoIOFactoryRegister__Private() { - if (!FileListVideoIOFactoryHasBeenRegistered) - { - FileListVideoIOFactoryHasBeenRegistered = true; - FileListVideoIOFactory::RegisterOneFactory(); - } + ObjectFactoryBase::RegisterInternalFactoryOnce(); } } // end namespace itk