Skip to content

Commit f1511e1

Browse files
committed
DOC: Improve documentation of migration of factory registration
Add examples to register all or register just selected factories.
1 parent 5ddc558 commit f1511e1

1 file changed

Lines changed: 24 additions & 10 deletions

File tree

Documentation/docs/migration_guides/itk_6_migration_guide.md

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -248,26 +248,40 @@ target_link_libraries(Example ITK::MyModuleModule)
248248

249249
Alternatively, the CMake variable `ITK_INTERFACE_LIBRARIES` can be used to link against all loaded modules.
250250

251-
**Factory Registration with Meta Modules:**
251+
**Factory Registration with Meta-Modules:**
252252

253-
ITK uses factory registration to dynamically load IO formats and other pluggable components at runtime. ITK 6 uses
254-
meta modules that simplify factory registration by grouping related modules together.
253+
ITK uses factory registration to load IO formats and pluggable components at runtime. ITK 6 uses
254+
meta-modules that simplify factory registration by grouping related modules together.
255255

256-
Factory meta modules include:
256+
Factory meta-modules include:
257257
- `ITKImageIO` - All image IO modules (JPEG, PNG, NIFTI, DICOM, etc.)
258258
- `ITKMeshIO` - All mesh IO modules
259259
- `ITKTransformIO` - Transform IO modules
260-
- `ITKIOFFT` - FFT implementations
260+
- `ITKFFTImageFilterInit` - FFT implementations
261261

262-
To use factory registration:
262+
To register all factories:
263263

264264
```cmake
265-
find_package(ITK REQUIRED COMPONENTS ITKCommon ITKIOGDCM TKIONRRD ITKImageIO)
266-
itk_generate_factory_registration()
265+
find_package(ITK REQUIRED COMPONENTS ITKCommon ITKImageIO )
266+
itk_generate_factory_registration( )
267+
...
268+
target_link_libraries(MyTarget ${ITK_INTERFACE_LIBRARIES} ITK::ITKImageIO)
269+
```
270+
271+
The `itk_generate_factory_registration()` macro *must* be called **before** adding executables. It optionally takes the factory types to register. The CMake macro generates registration code for the IO modules and factory-enabled components from the modules loaded in `find_package()`. The meta-module *must* be linked to the target to include and enable the generated registration code.
272+
273+
In the above example, because `ITKImageIO` is provided as a required component, all available ImageIO modules are registered. Note that if no components are requested in `find_package()`, then all components are loaded and registered.
274+
275+
To explicitly register factories:
276+
277+
```cmake
278+
find_package(ITK REQUIRED COMPONENTS ITKCommon ITKIOGDCM ITKIONRRD )
279+
itk_generate_factory_registration( ImageIO )
280+
...
281+
target_link_libraries(MyTarget ${ITK_INTERFACE_LIBRARIES} ITK::ITKImageIO)
267282
```
268283

269-
The `itk_generate_factory_registration()` macro must be called **before** adding executables. It generates registration
270-
code to register loaded IO modules and factory-enabled components from the modules specified in `find_package()`. In this case, only GDCM and NRRD ImageIO are loaded. If no components are specified, then all available factories will be enabled during the registration.
284+
In this example, the GDCM and NRRD ImageIO modules are explicitly loaded. Only the ImageIO factory type is registered and generated.
271285

272286

273287
**Determining Required Modules:**

0 commit comments

Comments
 (0)