Skip to content

Commit

Permalink
STYLE: Remove private ObjectFactoryBase member RegisterInternal()
Browse files Browse the repository at this point in the history
`ObjectFactoryBase::RegisterInternal()` was only called by `Initialize()`
anyway.

Avoided a redundant `itkInitGlobalsMacro(PimplGlobals)` call, and replaced
`clear` and `push_back` calls by a simple assignment to `m_RegisteredFactories`.
  • Loading branch information
N-Dekker committed Sep 27, 2023
1 parent 82d7060 commit 9aecafd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 28 deletions.
7 changes: 1 addition & 6 deletions Modules/Core/Common/include/itkObjectFactoryBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,7 @@ class ITKCommon_EXPORT ObjectFactoryBase : public Object
(void)staticFactoryRegistration;
}

/** Initialize the static members of ObjectFactoryBase.
* RegisterInternal() and InitializeFactoryList() are called here. */
/** Initialize the static members of ObjectFactoryBase. */
static void
Initialize();

Expand Down Expand Up @@ -271,10 +270,6 @@ class ITKCommon_EXPORT ObjectFactoryBase : public Object

const std::unique_ptr<OverrideMap> m_OverrideMap;

/** Register default factories which are not loaded at run time. */
static void
RegisterInternal();

/** Load dynamic factories from the ITK_AUTOLOAD_PATH */
static void
LoadDynamicFactories();
Expand Down
28 changes: 6 additions & 22 deletions Modules/Core/Common/src/itkObjectFactoryBase.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -231,34 +231,18 @@ ObjectFactoryBase::Initialize()
// Atomically set m_Initialized to true. If it was false before, enter the if.
if (!m_PimplGlobals->m_Initialized.exchange(true))
{
ObjectFactoryBase::RegisterInternal();
// Guarantee that no internal factories have already been registered.
itkAssertInDebugAndIgnoreInReleaseMacro(m_PimplGlobals->m_RegisteredFactories.empty());

// Register all factories registered by the "RegisterFactoryInternal" method
m_PimplGlobals->m_RegisteredFactories = m_PimplGlobals->m_InternalFactories;

#if defined(ITK_DYNAMIC_LOADING) && !defined(ITK_WRAPPING)
ObjectFactoryBase::LoadDynamicFactories();
#endif
}
}

/**
* Register any factories that are always present in ITK like
* the OpenGL factory, currently this is not done.
*/
void
ObjectFactoryBase::RegisterInternal()
{
itkInitGlobalsMacro(PimplGlobals);

// Guarantee that no internal factories have already been registered.
itkAssertInDebugAndIgnoreInReleaseMacro(m_PimplGlobals->m_RegisteredFactories.empty());
m_PimplGlobals->m_RegisteredFactories.clear();

// Register all factories registered by the
// "RegisterFactoryInternal" method
for (auto & internalFactory : m_PimplGlobals->m_InternalFactories)
{
m_PimplGlobals->m_RegisteredFactories.push_back(internalFactory);
}
}

/**
* Load all libraries in ITK_AUTOLOAD_PATH
*/
Expand Down

0 comments on commit 9aecafd

Please sign in to comment.