Skip to content

Commit 2dbf8c6

Browse files
N-Dekkerhjmjohnson
authored andcommitted
ENH: Add protected helper function, ProcessObject::MakeRequiredOutputs
Meant to be used in constructors of derived classes that would otherwise directly call `MakeOutput` for each of their required outputs.
1 parent 328606b commit 2dbf8c6

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Modules/Core/Common/include/itkProcessObject.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -920,6 +920,20 @@ class ITKCommon_EXPORT ProcessObject : public Object
920920
return static_cast<uint32_t>(temp);
921921
};
922922

923+
924+
/** Sets the required number of outputs, and creates each of them by MakeOutput. */
925+
template <typename TSourceObject>
926+
static void
927+
MakeRequiredOutputs(TSourceObject & sourceObject, const DataObjectPointerArraySizeType numberOfRequiredOutputs)
928+
{
929+
sourceObject.ProcessObject::SetNumberOfRequiredOutputs(numberOfRequiredOutputs);
930+
931+
for (unsigned int i{}; i < numberOfRequiredOutputs; ++i)
932+
{
933+
sourceObject.ProcessObject::SetNthOutput(i, sourceObject.TSourceObject::MakeOutput(i));
934+
}
935+
}
936+
923937
/** These ivars are made protected so filters like itkStreamingImageFilter
924938
* can access them directly. */
925939

0 commit comments

Comments
 (0)